}
static bool become_root(void) {
- return !arg_exec_user || STR_IN_SET(arg_exec_user, "root", "0");
-}
-
-static bool privileged_execution(void) {
if (arg_runtime_scope != RUNTIME_SCOPE_SYSTEM)
return false;
- return become_root();
+ if (!arg_exec_user) {
+ assert(!arg_empower); /* assume default user has been set */
+ return true;
+ }
+
+ return STR_IN_SET(arg_exec_user, "root", "0");
}
static int add_timer_property(const char *name, const char *val) {
}
static double shell_prompt_hue(void) {
- if (privileged_execution())
+ if (become_root())
return 0; /* red */
if (arg_empower)
}
static Glyph shell_prompt_glyph(void) {
- if (privileged_execution())
+ if (become_root())
return GLYPH_SUPERHERO;
if (arg_empower)
}
static Glyph pty_window_glyph(void) {
- if (privileged_execution())
+ if (become_root())
return GLYPH_RED_CIRCLE;
if (arg_empower)
* default. Note that pam_logind/systemd-logind doesn't distinguish between run0-style privilege
* escalation on a TTY and first class (getty-style) TTY logins (and thus gives root a per-session
* manager for interactive TTY sessions), hence let's override the logic explicitly here. We only do
- * this for root though, under the assumption that if a regular user temporarily transitions into
- * another regular user it's a better default that the full user environment is uniformly
- * available. */
- if (arg_lightweight < 0 && (privileged_execution() || arg_empower))
+ * this for root or --empower though, under the assumption that if a regular user temporarily
+ * transitions into another regular user it's a better default that the full user environment is
+ * uniformly available. */
+ if (arg_lightweight < 0 && (become_root() || arg_empower))
arg_lightweight = true;
if (arg_lightweight >= 0) {