summaryrefslogtreecommitdiff
path: root/src/udev/udev-node.c
diff options
context:
space:
mode:
authorIan Stakenvicius <axs@gentoo.org>2013-01-25 13:04:37 -0500
committerAnthony G. Basile <blueness@gentoo.org>2013-01-28 17:42:47 -0500
commit34bcd6cd8c8f5dc7f01bef9a294a132cf856345e (patch)
tree660f565333d17118662f10065de9d2600240482f /src/udev/udev-node.c
parent760eeae32acdad527ee5a1eb98d44a084655f159 (diff)
Set device node permissions only at "add" events
New behavioural change -- has potential to fix bugs..? systemd commit 48a849ee17fb25e0001bfcc0f28a4aa633d016a1 Author: Kay Sievers <kay@vrfy.org> Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev/udev-node.c')
-rw-r--r--src/udev/udev-node.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index df3fac8ab6..23df10f0f9 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -279,23 +279,24 @@ static int node_fixup(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid
goto out;
}
- if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
- log_debug("set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
- chmod(devnode, mode);
- if (chown(devnode, uid, gid) < 0)
- log_debug("Failed to change ownership of %s to uid=%u, gid=%u\n", devnode, uid, gid);
- } else {
- log_debug("preserve permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
- }
-
/*
- * Set initial selinux file context only on add events.
- * We set the proper context on bootup (triger) or for newly
- * added devices, but we don't change it later, in case
- * something else has set a custom context in the meantime.
+ * Set permissions and selinux file context only on add events. We always
+ * set it on bootup (coldplug) with "trigger --action=add" for all devices
+ * and for any newly added devices (hotplug). We don't want to change it
+ * later, in case something else has applied custom settings in the meantime.
*/
- if (strcmp(udev_device_get_action(dev), "add") == 0)
- label_fix(devnode, true, false);
+ if (strcmp(udev_device_get_action(dev), "add") == 0) {
+ if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
+ log_debug("set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
+ chmod(devnode, mode);
+ if (chown(devnode, uid, gid) < 0)
+ log_debug("Failed to change ownership of %s to uid=%u, gid=%u\n", devnode, uid, gid);
+ } else {
+ log_debug("preserve permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
+ }
+
+ label_fix(devnode, true, false);
+ }
/* always update timestamp when we re-use the node, like on media change events */
utimensat(AT_FDCWD, devnode, NULL, 0);