From 2c71aa77a5f600ad151f9d28e449cb96bf60e8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 29 Mar 2023 16:00:03 +0200 Subject: [PATCH 1/5] basic/mkdir: simplify error handling If we created the dir successfully, we let chmod_and_chown_at() do its thing and shouldn't go into the part where we check if the existing directory has the right permissions and ownership and possibly adjust them. The code was doing that, by relying on the fact that chmod_and_chown_at() does not return -EEXIST. That's probably true, but seems unnecessarilly complicated. Follow-up for c1b1492a94b43ca636eb383c3b058feff27ff7b1. --- src/basic/mkdir.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c index 3b7cf7a0bf..41af1482bc 100644 --- a/src/basic/mkdir.c +++ b/src/basic/mkdir.c @@ -33,11 +33,8 @@ int mkdirat_safe_internal( assert(_mkdirat && _mkdirat != mkdirat); r = _mkdirat(dir_fd, path, mode); - if (r >= 0) { - r = chmod_and_chown_at(dir_fd, path, mode, uid, gid); - if (r < 0) - return r; - } + if (r >= 0) + return chmod_and_chown_at(dir_fd, path, mode, uid, gid); if (r != -EEXIST) return r; From 0d6e0adef576871e8ccb5dd16a30565e7f10f8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 30 Mar 2023 09:40:14 +0200 Subject: [PATCH 2/5] man/systemd-sysext: minor grammar optimizations --- man/systemd-sysext.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/systemd-sysext.xml b/man/systemd-sysext.xml index 258c7142c9..96e40ddf95 100644 --- a/man/systemd-sysext.xml +++ b/man/systemd-sysext.xml @@ -83,12 +83,12 @@ service manager supports via /. Similar to them they may optionally carry Verity authentication information. - System extensions are automatically looked for in the directories + System extensions are searched for in the directories /etc/extensions/, /run/extensions/ and /var/lib/extensions/. The first two listed directories are not suitable for carrying large binary images, however are still useful for carrying symlinks to them. The primary place for installing system extensions is /var/lib/extensions/. Any directories found in - these search directories are considered directory based extension images, any files with the + these search directories are considered directory based extension images; any files with the .raw suffix are considered disk image based extension images. During boot OS extension images are activated automatically, if the From 2657d5bddc7f1cca6102243b65b912823de12da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 30 Mar 2023 16:19:25 +0200 Subject: [PATCH 3/5] basic/fs-util: typo fix --- src/basic/fs-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index cb323a6403..3722eb638b 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -824,7 +824,7 @@ int conservative_renameat( * have the exact same contents and basic file attributes already. In that case remove the new file * instead. This call is useful for reducing inotify wakeups on files that are updated but don't * actually change. This function is written in a style that we rather rename too often than suppress - * too much. i.e. whenever we are in doubt we rather rename than fail. After all reducing inotify + * too much. I.e. whenever we are in doubt, we rather rename than fail. After all reducing inotify * events is an optimization only, not more. */ old_fd = openat(olddirfd, oldpath, O_CLOEXEC|O_RDONLY|O_NOCTTY|O_NOFOLLOW); From 68e58ca95bea25a78190b464c24f42705ae287c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 14:59:48 +0200 Subject: [PATCH 4/5] core/service: inline one variable --- src/core/service.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index e0e56af19c..4fa96b38c0 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -875,7 +875,6 @@ static int service_load(Unit *u) { } static void service_dump(Unit *u, FILE *f, const char *prefix) { - ServiceExecCommand c; Service *s = SERVICE(u); const char *prefix2; @@ -977,8 +976,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) { kill_context_dump(&s->kill_context, f, prefix); exec_context_dump(&s->exec_context, f, prefix); - for (c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++) { - + for (ServiceExecCommand c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++) { if (!s->exec_command[c]) continue; From 73ed4874e9e65e1c15850752ccb9db611e7c8b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 21:22:17 +0200 Subject: [PATCH 5/5] shared/exec-util: reduce scope of iterator variables --- src/shared/exec-util.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index a2e8f428e6..56f16188e1 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -427,14 +427,14 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ex_opts) { _cleanup_strv_free_ char **ret_opts = NULL; ExecCommandFlags it = flags; const char *str; - int i, r; + int r; assert(ex_opts); if (flags < 0) return flags; - for (i = 0; it != 0; it &= ~(1 << i), i++) { + for (unsigned i = 0; it != 0; it &= ~(1 << i), i++) if (FLAGS_SET(flags, (1 << i))) { str = exec_command_flags_to_string(1 << i); if (!str) @@ -444,7 +444,6 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ex_opts) { if (r < 0) return r; } - } *ex_opts = TAKE_PTR(ret_opts); @@ -466,9 +465,7 @@ static const char* const exec_command_strings[] = { }; const char* exec_command_flags_to_string(ExecCommandFlags i) { - size_t idx; - - for (idx = 0; idx < ELEMENTSOF(exec_command_strings); idx++) + for (size_t idx = 0; idx < ELEMENTSOF(exec_command_strings); idx++) if (i == (1 << idx)) return exec_command_strings[idx];