summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-04-05 19:20:11 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-04-06 07:46:13 +0200
commite5ddfe3ec586c9ab174d39f4b6202155d92d24e4 (patch)
treeac2a487962f2978eee3f43db8669157ab26b3d43 /src/udev
parentudev: split udev_node_apply_permissions() into two (diff)
downloadsystemd-e5ddfe3ec586c9ab174d39f4b6202155d92d24e4.tar.xz
systemd-e5ddfe3ec586c9ab174d39f4b6202155d92d24e4.zip
udev: upgrade mode in udev_node_apply_permissions_impl()
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-event.c3
-rw-r--r--src/udev/udev-node.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index d9af8bfd20..78e8f3018c 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -966,9 +966,6 @@ static int update_devnode(UdevEvent *event) {
if (r < 0 && r != -ENOENT)
return log_device_error_errno(dev, r, "Failed to get devnode mode: %m");
}
- if (event->mode == MODE_INVALID && gid_is_valid(event->gid) && event->gid > 0)
- /* If group is set, but mode is not set, "upgrade" mode for the group. */
- event->mode = 0660;
bool apply_mac = device_for_action(dev, SD_DEVICE_ADD);
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 83d3242a25..493feffe00 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -610,6 +610,10 @@ static int udev_node_apply_permissions_impl(
if (fstat(node_fd, &stats) < 0)
return log_device_debug_errno(dev, errno, "cannot stat() node %s: %m", devnode);
+ /* If group is set, but mode is not set, "upgrade" mode for the group. */
+ if (mode == MODE_INVALID && gid_is_valid(gid) && gid > 0)
+ mode = 0660;
+
apply_mode = mode != MODE_INVALID && (stats.st_mode & 0777) != (mode & 0777);
apply_uid = uid_is_valid(uid) && stats.st_uid != uid;
apply_gid = gid_is_valid(gid) && stats.st_gid != gid;