From 03c16b9784151275e71db3f9a25dc42206f1b5d3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Dec 2022 23:50:48 +0100 Subject: [PATCH 1/3] glyph-util: add warning sign special glyph --- src/basic/glyph-util.c | 4 +++- src/basic/glyph-util.h | 1 + src/test/test-locale-util.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/basic/glyph-util.c b/src/basic/glyph-util.c index 67f2270daf..de1224f04f 100644 --- a/src/basic/glyph-util.c +++ b/src/basic/glyph-util.c @@ -71,6 +71,7 @@ const char *special_glyph(SpecialGlyph code) { [SPECIAL_GLYPH_RECYCLING] = "~", [SPECIAL_GLYPH_DOWNLOAD] = "\\", [SPECIAL_GLYPH_SPARKLES] = "*", + [SPECIAL_GLYPH_WARNING_SIGN] = "!", }, /* UTF-8 */ @@ -124,10 +125,11 @@ const char *special_glyph(SpecialGlyph code) { /* This emoji is a single character cell glyph in Unicode, and two in ASCII */ [SPECIAL_GLYPH_TOUCH] = u8"👆", /* actually called: BACKHAND INDEX POINTING UP */ - /* These three emojis are single character cell glyphs in Unicode and also in ASCII. */ + /* These four emojis are single character cell glyphs in Unicode and also in ASCII. */ [SPECIAL_GLYPH_RECYCLING] = u8"♻️", /* actually called: UNIVERSAL RECYCLNG SYMBOL */ [SPECIAL_GLYPH_DOWNLOAD] = u8"⤵️", /* actually called: RIGHT ARROW CURVING DOWN */ [SPECIAL_GLYPH_SPARKLES] = u8"✨", + [SPECIAL_GLYPH_WARNING_SIGN] = u8"⚠️", }, }; diff --git a/src/basic/glyph-util.h b/src/basic/glyph-util.h index 621d7a85b7..b64639622e 100644 --- a/src/basic/glyph-util.h +++ b/src/basic/glyph-util.h @@ -44,6 +44,7 @@ typedef enum SpecialGlyph { SPECIAL_GLYPH_RECYCLING, SPECIAL_GLYPH_DOWNLOAD, SPECIAL_GLYPH_SPARKLES, + SPECIAL_GLYPH_WARNING_SIGN, _SPECIAL_GLYPH_MAX, _SPECIAL_GLYPH_INVALID = -EINVAL, } SpecialGlyph; diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c index aa501b650a..dd96af6894 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_SPARKLES + 1 == _SPECIAL_GLYPH_MAX); + assert_cc(SPECIAL_GLYPH_WARNING_SIGN + 1 == _SPECIAL_GLYPH_MAX); log_info("is_locale_utf8: %s", yes_no(is_locale_utf8())); @@ -119,6 +119,7 @@ TEST(dump_special_glyphs) { dump_glyph(SPECIAL_GLYPH_RECYCLING); dump_glyph(SPECIAL_GLYPH_DOWNLOAD); dump_glyph(SPECIAL_GLYPH_SPARKLES); + dump_glyph(SPECIAL_GLYPH_WARNING_SIGN); } DEFINE_TEST_MAIN(LOG_INFO); From 2075b6dd394e09a0f203b9cc7e3253908397f933 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Dec 2022 23:50:57 +0100 Subject: [PATCH 2/3] chase-symlink: when converting directory O_PATH fd to real fd, don't bother with /proc/ Replaces: #25581 --- src/basic/chase-symlinks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c index 0bb07000ba..7a2aa9f94c 100644 --- a/src/basic/chase-symlinks.c +++ b/src/basic/chase-symlinks.c @@ -557,7 +557,7 @@ int chase_symlinks_and_opendir( return r; assert(path_fd >= 0); - d = opendir(FORMAT_PROC_FD_PATH(path_fd)); + d = xopendirat(path_fd, ".", O_NOFOLLOW); if (!d) return -errno; From 0f958c8d4fc13ed1c1af928b2a7d91d31c7576eb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Dec 2022 23:52:12 +0100 Subject: [PATCH 3/3] systemctl: print a clear warning if people invoke systemctl without /proc/ --- src/systemctl/systemctl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 4f2637f0f1..29f96681df 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -22,6 +22,7 @@ #include "rlimit-util.h" #include "sigbus.h" #include "signal-util.h" +#include "stat-util.h" #include "string-table.h" #include "systemctl-add-dependency.h" #include "systemctl-cancel-job.h" @@ -1148,6 +1149,13 @@ static int run(int argc, char *argv[]) { if (r <= 0) goto finish; + if (proc_mounted() == 0) + log_warning("%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n" + "your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway.\n" + "Your mileage may vary.", + emoji_enabled() ? special_glyph(SPECIAL_GLYPH_WARNING_SIGN) : "", + emoji_enabled() ? " " : ""); + if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) { if (!arg_quiet) log_info("Running in chroot, ignoring request.");