From b3e44c5291f60c0d70af941514ab58c8d31f14a7 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 14 Aug 2011 19:04:16 +0200 Subject: [PATCH] preserve 'sticky bit' on 'add/change' events --- udev/udev-node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/udev/udev-node.c b/udev/udev-node.c index 6fbe250b..71488c93 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -52,7 +52,9 @@ int udev_node_mknod(struct udev_device *dev, const char *file, mode_t mode, uid_ if (lstat(file, &stats) == 0) { if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) && (stats.st_rdev == devnum)) { info(udev, "preserve file '%s', because it has correct dev_t\n", file); - if (stats.st_mode != mode || stats.st_uid != uid || stats.st_gid != gid) { + if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) { + /* preserve 'sticky' bit, if already set */ + mode |= stats.st_mode & 01000; info(udev, "set permissions %s, %#o, uid=%u, gid=%u\n", file, mode, uid, gid); chmod(file, mode); chown(file, uid, gid); -- 2.39.5