X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogind-acl.c;h=7a06b501d45fbe420caae814abf40f54347e3011;hp=3df104ff2cc5a58e8c82b9550a080a54e009490f;hb=d2d4b038999d65826a2048a1a7829f9d5e762978;hpb=5eda94dda25bccda928c4b33c790dbe748573a22 diff --git a/src/logind-acl.c b/src/logind-acl.c index 3df104ff2..7a06b501d 100644 --- a/src/logind-acl.c +++ b/src/logind-acl.c @@ -54,7 +54,7 @@ static int find_acl(acl_t acl, uid_t uid, acl_entry_t *entry) { return -errno; b = *u == uid; - free(u); + acl_free(u); if (b) { *entry = i; @@ -105,7 +105,7 @@ int devnode_acl(const char *path, bool add, uid_t new_uid) { acl_t acl; - int r; + int r = 0; bool changed = false; assert(path); @@ -222,18 +222,20 @@ int devnode_acl_all(struct udev *udev, assert(udev); - if (!seat) + if (isempty(seat)) seat = "seat0"; e = udev_enumerate_new(udev); if (!e) return -ENOMEM; - r = udev_enumerate_add_match_tag(e, "uaccess"); - if (r < 0) - goto finish; + /* We can only match by one tag in libudev. We choose + * "uaccess" for that. If we could match for two tags here we + * could add the seat name as second match tag, but this would + * be hardly optimizable in libudev, and hence checking the + * second tag manually in our loop is a good solution. */ - r = udev_enumerate_add_match_tag(e, seat); + r = udev_enumerate_add_match_tag(e, "uaccess"); if (r < 0) goto finish; @@ -252,8 +254,8 @@ int devnode_acl_all(struct udev *udev, goto finish; } - sn = udev_device_get_property_value(d, "SEAT"); - if (!sn) + sn = udev_device_get_property_value(d, "ID_SEAT"); + if (isempty(sn)) sn = "seat0"; if (!streq(seat, sn)) { @@ -262,14 +264,17 @@ int devnode_acl_all(struct udev *udev, } node = udev_device_get_devnode(d); - udev_device_unref(d); - if (!node) { - r = -ENOMEM; - goto finish; + /* In case people mistag devices with nodes, we need to ignore this */ + udev_device_unref(d); + continue; } + log_debug("Fixing up %s for seat %s...", node, sn); + r = devnode_acl(node, flush, del, old_uid, add, new_uid); + udev_device_unref(d); + if (r < 0) goto finish; }