From c892816ceb19378f5079eee37d89f18e5c202447 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 12 Nov 2024 14:18:31 +0100 Subject: [PATCH] run0: when changing privileges to non-root, do not show superhero emoji Let's show an idcard logo instead, to indicate that we changed ids. --- src/basic/glyph-util.c | 2 ++ src/basic/glyph-util.h | 1 + src/run/run.c | 2 +- src/test/test-locale-util.c | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/basic/glyph-util.c b/src/basic/glyph-util.c index 1108afdf03e..64f6685cb4f 100644 --- a/src/basic/glyph-util.c +++ b/src/basic/glyph-util.c @@ -81,6 +81,7 @@ const char* special_glyph_full(SpecialGlyph code, bool force_utf) { [SPECIAL_GLYPH_BLUE_CIRCLE] = "o", [SPECIAL_GLYPH_GREEN_CIRCLE] = "o", [SPECIAL_GLYPH_SUPERHERO] = "S", + [SPECIAL_GLYPH_IDCARD] = "@", }, /* UTF-8 */ @@ -151,6 +152,7 @@ const char* special_glyph_full(SpecialGlyph code, bool force_utf) { [SPECIAL_GLYPH_BLUE_CIRCLE] = u8"🔵", [SPECIAL_GLYPH_GREEN_CIRCLE] = u8"🟢", [SPECIAL_GLYPH_SUPERHERO] = u8"🦸", + [SPECIAL_GLYPH_IDCARD] = u8"🪪", }, }; diff --git a/src/basic/glyph-util.h b/src/basic/glyph-util.h index c31c3c18bba..ca4d4eda71a 100644 --- a/src/basic/glyph-util.h +++ b/src/basic/glyph-util.h @@ -56,6 +56,7 @@ typedef enum SpecialGlyph { SPECIAL_GLYPH_BLUE_CIRCLE, SPECIAL_GLYPH_GREEN_CIRCLE, SPECIAL_GLYPH_SUPERHERO, + SPECIAL_GLYPH_IDCARD, _SPECIAL_GLYPH_MAX, _SPECIAL_GLYPH_INVALID = -EINVAL, } SpecialGlyph; diff --git a/src/run/run.c b/src/run/run.c index 5a1df9ce8f6..c62dce8950f 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -1038,7 +1038,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) { if (!arg_shell_prompt_prefix) return log_oom(); } else if (emoji_enabled()) { - arg_shell_prompt_prefix = strjoin(special_glyph(SPECIAL_GLYPH_SUPERHERO), " "); + arg_shell_prompt_prefix = strjoin(special_glyph(privileged_execution() ? SPECIAL_GLYPH_SUPERHERO : SPECIAL_GLYPH_IDCARD), " "); if (!arg_shell_prompt_prefix) return log_oom(); } diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c index 7afa446bfb6..f9b2712444a 100644 --- a/src/test/test-locale-util.c +++ b/src/test/test-locale-util.c @@ -82,7 +82,7 @@ TEST(keymaps) { #define dump_glyph(x) log_info(STRINGIFY(x) ": %s", special_glyph(x)) TEST(dump_special_glyphs) { - assert_cc(SPECIAL_GLYPH_SUPERHERO + 1 == _SPECIAL_GLYPH_MAX); + assert_cc(SPECIAL_GLYPH_IDCARD + 1 == _SPECIAL_GLYPH_MAX); log_info("is_locale_utf8: %s", yes_no(is_locale_utf8())); @@ -134,6 +134,7 @@ TEST(dump_special_glyphs) { dump_glyph(SPECIAL_GLYPH_BLUE_CIRCLE); dump_glyph(SPECIAL_GLYPH_GREEN_CIRCLE); dump_glyph(SPECIAL_GLYPH_SUPERHERO); + dump_glyph(SPECIAL_GLYPH_IDCARD); } DEFINE_TEST_MAIN(LOG_INFO); -- 2.47.3