]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: skip polkit query with --no-wall 15448/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 16 Apr 2020 11:46:37 +0000 (13:46 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 16 Apr 2020 12:07:39 +0000 (14:07 +0200)
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1800875.

src/login/logind-dbus.c

index 15201f900f8c8d885aca58a092235a04326185dc..047f835327be7ebb2db189edad9e911154fe0d4b 100644 (file)
@@ -3170,6 +3170,12 @@ static int method_set_wall_message(
         if (r < 0)
                 return r;
 
+        /* Short-circuit the operation if the desired state is already in place, to
+         * avoid an unnecessary polkit permission check. */
+        if (streq_ptr(m->wall_message, empty_to_null(wall_message)) &&
+            m->enable_wall_messages == enable_wall_messages)
+                goto done;
+
         r = bus_verify_polkit_async(message,
                                     CAP_SYS_ADMIN,
                                     "org.freedesktop.login1.set-wall-message",
@@ -3189,6 +3195,7 @@ static int method_set_wall_message(
 
         m->enable_wall_messages = enable_wall_messages;
 
+ done:
         return sd_bus_reply_method_return(message, NULL);
 }