#define LOCAL_USER "$local"
+#include "selinux.h"
+
/*
* Right now the major/minor of a device is stored in a file called
* "dev" in sysfs.
break;
*pos = 0x00;
if (stat(p, &stats)) {
+ selinux_setfscreatecon(p, S_IFDIR);
retval = mkdir(p, 0755);
if (retval != 0) {
dbg("mkdir(%s) failed with error '%s'",
return retval;
}
dbg("created '%s'", p);
+ } else {
+ selinux_setfilecon(p, S_IFDIR);
}
*pos = '/';
}
if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) &&
(stats.st_rdev == makedev(major, minor))) {
dbg("preserve file '%s', cause it has correct dev_t", file);
+ selinux_setfilecon(file,stats.st_mode);
goto perms;
}
dbg("already present file '%s' unlinked", file);
create:
+ selinux_setfscreatecon(file, mode);
retval = mknod(file, mode, makedev(major, minor));
if (retval != 0) {
dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
dbg("symlink(%s, %s)", linktarget, filename);
if (!fake) {
+ selinux_setfscreatecon(filename, S_IFLNK);
unlink(filename);
if (symlink(linktarget, filename) != 0)
dbg("symlink(%s, %s) failed with error '%s'",
return -1;
}
-static struct sysfs_class_device *get_class_dev(char *device_name)
+static struct sysfs_class_device *get_class_dev(const char *device_name)
{
char dev_path[SYSFS_PATH_MAX];
struct sysfs_class_device *class_dev = NULL;
* If it doesn't happen in about 10 seconds, give up.
*/
#define SECONDS_TO_WAIT_FOR_FILE 10
-static int sleep_for_file(char *path, char* file)
+static int sleep_for_file(const char *path, char* file)
{
char filename[SYSFS_PATH_MAX + 6];
int loop = SECONDS_TO_WAIT_FOR_FILE;
return retval;
}
-int udev_add_device(char *path, char *subsystem, int fake)
+int udev_add_device(const char *path, const char *subsystem, int fake)
{
struct sysfs_class_device *class_dev;
struct udevice dev;
dbg("name='%s'", dev.name);
+ selinux_init();
switch (dev.type) {
case 'b':
case 'c':
}
exit:
+ selinux_restore();
sysfs_close_class_device(class_dev);
return retval;