summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-08-14 19:04:16 +0200
committerKay Sievers <kay.sievers@vrfy.org>2011-08-14 19:04:16 +0200
commitb3e44c5291f60c0d70af941514ab58c8d31f14a7 (patch)
treec53cdc5999fd75fd0543ce677126916bf5652f30 /udev
parent38f6aefc47799f6ba313621661ecef833a01e0d9 (diff)
preserve 'sticky bit' on 'add/change' events
Diffstat (limited to 'udev')
-rw-r--r--udev/udev-node.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/udev/udev-node.c b/udev/udev-node.c
index 6fbe250b85..71488c93ad 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);