Skip to contentSkip to conversation

Restoring permissions on existing nodes

DISCUSSION Martin Orr 2 participants 2 messages Dec 3, 2007

lore
Share & tools
lore

Martin Orr

author
#0 lore raw

Is there a reason why udev sets the permissions and SELinux context every time it finds an existing node or symlink?

The code in question is (from udev_node.c):

in udev_node_mknod():

if ((stats.st_mode & S_IFMT) == (mode & S_IFMT) && (stats.st_rdev == devt)) {
	info("preserve file '%s', because it has correct dev_t", file);
	selinux_setfilecon(file, udev->dev->kernel, stats.st_mode);
	goto perms;
}

in node_symlink():

if (strcmp(target, buf) == 0) {
	info("preserve already existing symlink '%s' to '%s'", slink, target);
	selinux_setfilecon(slink, NULL, S_IFLNK);
	goto exit;
}
Signature · 1 line
Martin Orr

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 12 lines · Martin Orr

Is there a reason why udev sets the permissions and SELinux context every time it finds an existing node or symlink?

The code in question is (from udev_node.c):

in udev_node_mknod():

if ((stats.st_mode & S_IFMT) = (mode & S_IFMT) && (stats.st_rdev = devt)) {
        info("preserve file '%s', because it has correct dev_t", file);
        selinux_setfilecon(file, udev->dev->kernel, stats.st_mode);
        goto perms;
}
Quoted 6 lines

in node_symlink():

if (strcmp(target, buf) = 0) {
        info("preserve already existing symlink '%s' to '%s'", slink, target);
        selinux_setfilecon(slink, NULL, S_IFLNK);
        goto exit;
}

Because it should match what the configuration specifies, you can't expect that the properties of a pre-existing node are correct. The node does not get replaced, because it should not change the inode number, but all other properties get re-applied with the configured values or the built-in default.

Kay

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel