X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev%2Fudev-node.c;h=71488c93ad00f4ffd7303f583f804c153e568600;hp=dc7d9c365a64efaa6b53eff9b75d8b0077104f07;hb=b3e44c5291f60c0d70af941514ab58c8d31f14a7;hpb=cbfad6af1fdc73c6f3c6b001047ff4a86c8a6efd diff --git a/udev/udev-node.c b/udev/udev-node.c index dc7d9c365..71488c93a 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); @@ -425,6 +427,11 @@ int udev_node_remove(struct udev_device *dev) goto out; } + if (stats.st_mode & 01000) { + info(udev, "device node '%s' has sticky bit set, skip removal\n", devnode); + goto out; + } + dev_check = udev_device_new_from_syspath(udev, udev_device_get_syspath(dev)); if (dev_check != NULL) { /* do not remove device node if the same sys-device is re-created in the meantime */