summaryrefslogtreecommitdiff
path: root/udev_add.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2005-02-04 21:38:26 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:24:19 -0700
commitfbda4a34d846946bf8ed63deadfd6e65b2299792 (patch)
treece9ccdb18666fa01b16705d2221be426b7203e37 /udev_add.c
parent9badc83e4f6d67e7d646c5f438597154f34ad0ab (diff)
[PATCH] selinux: cleanup udev integration
Move code into a .c-file instead of big inline functions in a header file. Pass the device name down instead of relying that the node name is equal to the kernel name.
Diffstat (limited to 'udev_add.c')
-rw-r--r--udev_add.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/udev_add.c b/udev_add.c
index d4cccfc085..24a20bba9b 100644
--- a/udev_add.c
+++ b/udev_add.c
@@ -43,8 +43,7 @@
#include "logging.h"
#include "namedev.h"
#include "udev_db.h"
-
-#include "selinux.h"
+#include "udev_selinux.h"
/*
* the major/minor of a device is stored in a file called "dev"
@@ -68,7 +67,7 @@ error:
return -1;
}
-static int make_node(char *file, int major, int minor, unsigned int mode, uid_t uid, gid_t gid)
+static int make_node(struct udevice *udev, char *file, int major, int minor, unsigned int mode, uid_t uid, gid_t gid)
{
struct stat stats;
int retval = 0;
@@ -80,7 +79,7 @@ static int make_node(char *file, int major, int minor, unsigned int mode, uid_t
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);
+ selinux_setfilecon(file, udev->kernel_name, stats.st_mode);
goto perms;
}
@@ -90,7 +89,7 @@ static int make_node(char *file, int major, int minor, unsigned int mode, uid_t
dbg("already present file '%s' unlinked", file);
create:
- selinux_setfscreatecon(file, mode);
+ selinux_setfscreatecon(file, udev->kernel_name, mode);
retval = mknod(file, mode, makedev(major, minor));
if (retval != 0) {
dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
@@ -184,7 +183,7 @@ static int create_node(struct udevice *udev)
if (!udev->test_run) {
info("creating device node '%s'", filename);
- if (make_node(filename, udev->major, udev->minor, udev->mode, uid, gid) != 0)
+ if (make_node(udev, filename, udev->major, udev->minor, udev->mode, uid, gid) != 0)
goto error;
} else {
info("creating device node '%s', major = '%d', minor = '%d', "
@@ -199,7 +198,7 @@ static int create_node(struct udevice *udev)
for (i = 1; i <= udev->partitions; i++) {
strfieldcpy(partitionname, filename);
strintcat(partitionname, i);
- make_node(partitionname, udev->major, udev->minor + i, udev->mode, uid, gid);
+ make_node(udev, partitionname, udev->major, udev->minor + i, udev->mode, uid, gid);
}
}
}
@@ -237,7 +236,7 @@ static int create_node(struct udevice *udev)
dbg("symlink(%s, %s)", linktarget, filename);
if (!udev->test_run) {
- selinux_setfscreatecon(filename, S_IFLNK);
+ selinux_setfscreatecon(filename, udev->kernel_name, S_IFLNK);
unlink(filename);
if (symlink(linktarget, filename) != 0)
dbg("symlink(%s, %s) failed with error '%s'",