From 78435d620ca7c2e7e982b2cc9e0aa02242ebd8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 23 May 2023 13:46:59 +0200 Subject: [PATCH 1/5] basic/user-util: attach pointer symbol to return type, not function Surrounding code was predominantly using this style already, let's make things consistent. --- src/basic/user-util.c | 8 ++++---- src/basic/user-util.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 3325aabe4d..6bdf26b42a 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -127,7 +127,7 @@ char* getlogname_malloc(void) { return uid_to_name(uid); } -char *getusername_malloc(void) { +char* getusername_malloc(void) { const char *e; e = secure_getenv("USER"); @@ -171,7 +171,7 @@ const char* default_root_shell_at(int rfd) { return "/bin/sh"; } -const char *default_root_shell(const char *root) { +const char* default_root_shell(const char *root) { _cleanup_close_ int rfd = -EBADF; rfd = open(empty_to_root(root), O_CLOEXEC | O_DIRECTORY | O_PATH); @@ -847,7 +847,7 @@ bool valid_gecos(const char *d) { return true; } -char *mangle_gecos(const char *d) { +char* mangle_gecos(const char *d) { char *mangled; /* Makes sure the provided string becomes valid as a GEGOS field, by dropping bad chars. glibc's @@ -1059,7 +1059,7 @@ int is_this_me(const char *username) { return uid == getuid(); } -const char *get_home_root(void) { +const char* get_home_root(void) { const char *e; /* For debug purposes allow overriding where we look for home dirs */ diff --git a/src/basic/user-util.h b/src/basic/user-util.h index c82941dd81..8b829a9ae2 100644 --- a/src/basic/user-util.h +++ b/src/basic/user-util.h @@ -103,7 +103,7 @@ typedef enum ValidUserFlags { bool valid_user_group_name(const char *u, ValidUserFlags flags); bool valid_gecos(const char *d); -char *mangle_gecos(const char *d); +char* mangle_gecos(const char *d); bool valid_home(const char *p); static inline bool valid_shell(const char *p) { @@ -136,7 +136,7 @@ const char* default_root_shell(const char *root); int is_this_me(const char *username); -const char *get_home_root(void); +const char* get_home_root(void); static inline bool hashed_password_is_locked_or_invalid(const char *password) { return password && password[0] != '$'; From 5fdec39796f4defce1863b8c3c7c277ecbf42c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 23 May 2023 21:26:57 +0200 Subject: [PATCH 2/5] dissect: use pager for --help This output is already too long to fit on an normal terminal, and the interesting parts are towards the top. --- src/dissect/dissect.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 2d33a967ca..45e0abc63d 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -96,6 +96,8 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; + pager_open(arg_pager_flags); + r = terminal_urlify_man("systemd-dissect", "1", &link); if (r < 0) return log_oom(); From e80444729fbfc05d4b22e775072165eba72fae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 29 May 2023 12:28:34 +0200 Subject: [PATCH 3/5] tests: drop unnecessary redirection of stderr command -v doesn't print anything to stderr, let's use the canonical form with just >/dev/null. --- test/units/testsuite-35.sh | 4 ++-- test/units/testsuite-58.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 659882ed7a..2dd1a560c4 100755 --- a/test/units/testsuite-35.sh +++ b/test/units/testsuite-35.sh @@ -102,11 +102,11 @@ testcase_suspend_on_lid() { echo "suspend not supported on this testbed, skipping" return fi - if ! command -v evemu-device &>/dev/null; then + if ! command -v evemu-device >/dev/null; then echo "command evemu-device not found, skipping" return fi - if ! command -v evemu-event &>/dev/null; then + if ! command -v evemu-event >/dev/null; then echo "command evemu-event not found, skipping" return fi diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index acd03d2fdf..5ebbd305c8 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -7,7 +7,7 @@ set -o pipefail # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh -if ! command -v systemd-repart &>/dev/null; then +if ! command -v systemd-repart >/dev/null; then echo "no systemd-repart" >/skipped exit 0 fi From 6483bcef54d36916b14c07f2b164c6faa8433fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 30 May 2023 15:56:45 +0200 Subject: [PATCH 4/5] shared/loop-util: add comment Requested in https://github.com/systemd/systemd/commit/afbe20b7d4ed4c3aebbd1b3de00b9b7385dd0ae8#r115653459. --- src/shared/loop-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c index 5418871093..a70c5509d5 100644 --- a/src/shared/loop-util.c +++ b/src/shared/loop-util.c @@ -818,7 +818,8 @@ static LoopDevice* loop_device_free(LoopDevice *d) { /* Now that the block device is released, let's also try to remove it */ if (control >= 0) { - useconds_t delay = 5 * USEC_PER_MSEC; + useconds_t delay = 5 * USEC_PER_MSEC; /* A total delay of 5090 ms between 39 attempts, + * (4*5 + 5*10 + 5*20 + … + 3*640) = 5090. */ for (unsigned attempt = 1;; attempt++) { if (ioctl(control, LOOP_CTL_REMOVE, d->nr) >= 0) From 5ad6600364f644b70cdb13d1596ec25831ac2449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Apr 2023 11:37:52 +0200 Subject: [PATCH 5/5] test-dlopen: allow loading of multiple libraries This is useful for debugging, for example if we want to test multiple different dlls being loaded in the same namespace. --- src/test/test-dlopen.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/test-dlopen.c b/src/test/test-dlopen.c index 35981ebc3b..9c315373b4 100644 --- a/src/test/test-dlopen.c +++ b/src/test/test-dlopen.c @@ -6,10 +6,14 @@ #include "macro.h" int main(int argc, char **argv) { - void *handle; + void *handles[argc - 1]; + int i; - assert_se(handle = dlopen(argv[1], RTLD_NOW)); - assert_se(dlclose(handle) == 0); + for (i = 0; i < argc - 1; i++) + assert_se(handles[i] = dlopen(argv[i + 1], RTLD_NOW)); + + for (i--; i >= 0; i--) + assert_se(dlclose(handles[i]) == 0); return EXIT_SUCCESS; }