if (r != 0)
return r;
+ {
+ _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+
+ (void) bus_query_sender_pidref(message, &pidref);
+ log_shutdown_caller(&pidref, handle_action_to_string(a->handle));
+ }
+
if (m->delayed_action)
return sd_bus_error_setf(error, BUS_ERROR_OPERATION_IN_PROGRESS,
"Action %s already in progress, refusing requested %s operation.",
#include "bus-common-errors.h"
#include "bus-polkit.h"
+#include "cgroup-util.h"
+#include "format-util.h"
#include "fs-util.h"
#include "hashmap.h"
+#include "log.h"
#include "login-util.h"
#include "logind.h"
#include "logind-dbus.h"
#include "logind-session.h"
#include "logind-shutdown.h"
#include "logind-user.h"
+#include "pidref.h"
+#include "process-util.h"
#include "user-record.h"
int manager_have_multiple_sessions(
return false;
}
+void log_shutdown_caller(const PidRef *caller, const char *method) {
+ _cleanup_free_ char *comm = NULL, *unit = NULL;
+
+ assert(method);
+
+ if (!pidref_is_set(caller)) {
+ return log_notice("%s requested from unknown client PID...", method);
+ }
+
+ (void) pidref_get_comm(caller, &comm);
+ (void) cg_pidref_get_unit(caller, &unit);
+
+ log_notice("%s requested from client PID " PID_FMT "%s%s%s%s%s%s...",
+ method, caller->pid,
+ comm ? " ('" : "", strempty(comm), comm ? "')" : "",
+ unit ? " (unit " : "", strempty(unit), unit ? ")" : "");
+}
+
int manager_verify_shutdown_creds(
Manager *m,
sd_bus_message *message,
int manager_have_multiple_sessions(Manager *m, uid_t uid);
+void log_shutdown_caller(const PidRef *caller, const char *method);
+
/* manager_verify_shutdown_creds() takes *either* a "message" or "link" depending on if it is used
* to validate a D-Bus or Varlink shutdown request. When varlink is used the sd_bus_error *error
* must be NULL */
if (r != 0)
return r;
+ {
+ _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+
+ (void) varlink_get_peer_pidref(link, &pidref);
+ log_shutdown_caller(&pidref, handle_action_to_string(action));
+ }
+
if (m->delayed_action)
return sd_varlink_error(link, "io.systemd.Shutdown.AlreadyInProgress", /* parameters= */ NULL);