From: Yu Watanabe Date: Wed, 2 Jul 2025 23:15:51 +0000 (+0900) Subject: udev-builtin-uaccess: open device node with O_PATH X-Git-Tag: v258-rc1~200 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aada48970ed9d606331e636dab7da0ca520a5bdf;p=thirdparty%2Fsystemd.git udev-builtin-uaccess: open device node with O_PATH Some device node refuses to be opened with read-write mode. Let's not open with O_RDWR, but open with O_PATH, and use FORMAT_PROC_FD_PATH(). Follow-up for 1abb592f2f886913492e4967cc96816c167177a9. Fixes #38033. --- diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c index 9a9ba43b1c9..bd2f77c69d6 100644 --- a/src/udev/udev-builtin-uaccess.c +++ b/src/udev/udev-builtin-uaccess.c @@ -19,7 +19,7 @@ static int devnode_acl(int fd, uid_t uid) { assert(fd >= 0); _cleanup_(acl_freep) acl_t acl = NULL; - acl = acl_get_fd(fd); + acl = acl_get_file(FORMAT_PROC_FD_PATH(fd), ACL_TYPE_ACCESS); if (!acl) return -errno; @@ -99,7 +99,7 @@ static int devnode_acl(int fd, uid_t uid) { if (acl_calc_mask(&acl) < 0) return -errno; - if (acl_set_fd(fd, acl) < 0) + if (acl_set_file(FORMAT_PROC_FD_PATH(fd), ACL_TYPE_ACCESS, acl) < 0) return -errno; return 0; @@ -120,7 +120,7 @@ static int builtin_uaccess(UdevEvent *event, int argc, char *argv[]) { if (!logind_running()) return 0; - _cleanup_close_ int fd = sd_device_open(dev, O_CLOEXEC|O_RDWR); + _cleanup_close_ int fd = sd_device_open(dev, O_CLOEXEC|O_PATH); if (fd < 0) return log_device_error_errno(dev, fd, "Failed to open device node: %m");