From: Zbigniew Jędrzejewski-Szmek Date: Thu, 16 Apr 2020 11:46:37 +0000 (+0200) Subject: logind: skip polkit query with --no-wall X-Git-Tag: v246-rc1~577^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15448%2Fhead;p=thirdparty%2Fsystemd.git logind: skip polkit query with --no-wall Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1800875. --- diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 15201f900f8..047f835327b 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -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); }