]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: drop pointless must_be_root() checks
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 18 Jan 2019 15:35:55 +0000 (16:35 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 8 May 2019 09:51:51 +0000 (11:51 +0200)
Checking if we are root on the client side is generally pointless, since the
privileged operation will fail anyway and we can than log what precisly went
wrong.

A check like this makes sense only if:
- we need to do some expensive unprivileged operation before attempting the
  privileged operation, and the check allows us avoid wasting resources.
- the privileged operation would fail but in an unclear way.

Neither of those cases applies here.

This fixes calls like 'udevadm control -h' as unprivileged user.

src/udev/udevadm-control.c
src/udev/udevadm-trigger.c

index f9b3e95794a91628ac0c5b5c284c233056ade353..82e25149325ecbc6606bc18a09dbd892afb85c63 100644 (file)
@@ -73,10 +73,6 @@ int control_main(int argc, char *argv[], void *userdata) {
                 {}
         };
 
-        r = must_be_root();
-        if (r < 0)
-                return r;
-
         if (running_in_chroot() > 0) {
                 log_info("Running in chroot, ignoring request.");
                 return 0;
index b7dafb775575d7e6bbafc8d4a4413ba266750fcc..144b464d24f6fdcf71b63577e8d3565a6f1c9d71 100644 (file)
@@ -301,12 +301,6 @@ int trigger_main(int argc, char *argv[], void *userdata) {
                 }
         }
 
-        if (!arg_dry_run || ping) {
-                r = must_be_root();
-                if (r < 0)
-                        return r;
-        }
-
         if (ping) {
                 _cleanup_(udev_ctrl_unrefp) struct udev_ctrl *uctrl = NULL;