chiark / gitweb /
udev-acl: properly handle CK change events for root user
[elogind.git] / extras / udev-acl / udev-acl.c
index e670ce707fa0edd76bf55983cb3c89c6de1b80bd..f2b50051c1121fa4bf80932f0f1a3553d1533f05 100644 (file)
@@ -224,14 +224,10 @@ static int consolekit_called(const char *ck_action, uid_t *uid, uid_t *uid2, con
                if (s == NULL)
                        return -1;
                u = strtoul(s, NULL, 10);
-               if (u == 0)
-                       return 0;
                s = getenv("CK_SEAT_SESSION_USER_UID");
                if (s == NULL)
                        return -1;
                u2 = strtoul(s, NULL, 10);
-               if (u2 == 0)
-                       return 0;
 
                s = getenv("CK_SEAT_OLD_SESSION_IS_LOCAL");
                s2 = getenv("CK_SEAT_SESSION_IS_LOCAL");
@@ -263,12 +259,11 @@ static int consolekit_called(const char *ck_action, uid_t *uid, uid_t *uid2, con
                        a = ACTION_ADD;
                        u = u2;
                }
-
                break;
        case ACTION_NONE:
                break;
        default:
-               g_assert_not_reached ();
+               g_assert_not_reached();
                break;
        }
 
@@ -289,7 +284,7 @@ static void apply_acl_to_devices(uid_t uid, int add)
        /* iterate over all devices tagged with ACL_SET */
        udev = udev_new();
        enumerate = udev_enumerate_new(udev);
-       udev_enumerate_add_match_property(enumerate, "ACL_MANAGE", "*");
+       udev_enumerate_add_match_tag(enumerate, "udev-acl");
        udev_enumerate_scan_devices(enumerate);
        udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(enumerate)) {
                struct udev_device *device;
@@ -353,12 +348,10 @@ int main (int argc, char* argv[])
 
                switch (option) {
                case 'a':
-                       if (strcmp(optarg, "add") == 0 || strcmp(optarg, "change") == 0)
-                               action = ACTION_ADD;
-                       else if (strcmp(optarg, "remove") == 0)
+                       if (strcmp(optarg, "remove") == 0)
                                action = ACTION_REMOVE;
                        else
-                               goto out;
+                               action = ACTION_ADD;
                        break;
                case 'D':
                        device = optarg;