}
}
+ /* set sticky bit, so we do not remove the node on module unload */
+ if (event->static_node)
+ event->mode |= 01000;
+
err = udev_node_add(dev, event->mode, event->uid, event->gid);
}
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 */
rule->rule.filename_line);
break;
case TK_A_STATIC_NODE:
+ event->static_node = true;
break;
case TK_A_ENV: {
const char *name = &rules->buf[cur->key.attr_off];
goto next;
if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
goto next;
-
- if (mode == 0 && gid > 0)
- mode = 0660;
- if (mode != (stats.st_mode & 0777)) {
+ if (mode == 0) {
+ if (gid > 0)
+ mode = 0660;
+ else
+ mode = 0600;
+ }
+ /* set sticky bit, so we do not remove the node on module unload */
+ mode |= 01000;
+ if (mode != (stats.st_mode & 01777)) {
chmod(filename, mode);
info(rules->udev, "chmod '%s' %#o\n", filename, mode);
}
bool owner_final;
bool mode_set;
bool mode_final;
+ bool static_node;
bool name_final;
bool devlink_final;
bool run_final;
if (sscanf(devno, "%c%u:%u", &type, &maj, &min) != 3)
continue;
+ /* set sticky bit, so we do not remove the node on module unload */
if (type == 'c')
- mode = 0600 | S_IFCHR;
+ mode = 01600|S_IFCHR;
else if (type == 'b')
- mode = 0600 | S_IFBLK;
+ mode = 01600|S_IFBLK;
else
continue;