udev_selinux.c revision 726687ad48bdececed1e7e44387c50e009e28208
/*
* Copyright (C) 2004 Daniel Walsh
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#include "udev.h"
#include "udev_selinux.h"
static int is_selinux_running(void)
{
static int selinux_enabled = -1;
if (selinux_enabled == -1)
selinux_enabled = (is_selinux_enabled() > 0);
return selinux_enabled;
}
{
char mediabuf[256];
int size;
return NULL;
if (!fp)
goto out;
goto close_out;
while (size-- > 0) {
} else {
break;
}
}
out:
return media;
}
{
if (is_selinux_running()) {
char *media;
int ret = -1;
if (devname) {
if (media) {
}
}
if (ret < 0)
return;
}
}
}
{
if (is_selinux_running()) {
char *media;
int ret = -1;
if (devname) {
if (media) {
}
}
if (ret < 0)
return;
}
if (setfscreatecon(scontext) < 0)
}
}
void selinux_resetfscreatecon(void)
{
if (is_selinux_running()) {
if (setfscreatecon(prev_scontext) < 0)
}
}
void selinux_init(void)
{
/*
* record the present security context, for file-creation
* restoration creation purposes.
*/
if (is_selinux_running()) {
if (!udev_root[0])
err("selinux_init: udev_root not set\n");
if (getfscreatecon(&prev_scontext) < 0) {
err("getfscreatecon failed\n");
}
}
}
void selinux_exit(void)
{
if (is_selinux_running() && prev_scontext) {
}
}