From: Kay Sievers Date: Sun, 14 Aug 2011 17:04:16 +0000 (+0200) Subject: preserve 'sticky bit' on 'add/change' events X-Git-Tag: 174~36 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3e44c5291f60c0d70af941514ab58c8d31f14a7;p=systemd preserve 'sticky bit' on 'add/change' events --- 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);