]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysusers: do not reject non-simplified paths for shell/home
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Aug 2022 13:49:16 +0000 (15:49 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 22 Aug 2022 10:52:25 +0000 (12:52 +0200)
/home/zbyszek/src/systemd-work/testcase.conf:3: '//sbin//nologin' is not a valid login shell field.

This isn't very useful. The usual argument holds: people use templates to
construct config, so paths may have doubled slashes and similar. Let's simplify
paths so that the value that is pushed to /etc/passwd is nice and clean.

src/sysusers/sysusers.c

index 36d86fb6cbaff937a1ab143a8bb8a45450edc89a..4bb173da46f0cd4f61d32dffd1373456327cafb2 100644 (file)
@@ -1573,6 +1573,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                         return log_syntax(NULL, LOG_ERR, fname, line, r,
                                           "Failed to replace specifiers in '%s': %m", home);
 
+                path_simplify(resolved_home);
+
                 if (!valid_home(resolved_home))
                         return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EINVAL),
                                           "'%s' is not a valid home directory field.", resolved_home);
@@ -1588,6 +1590,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                         return log_syntax(NULL, LOG_ERR, fname, line, r,
                                           "Failed to replace specifiers in '%s': %m", shell);
 
+                path_simplify(resolved_shell);
+
                 if (!valid_shell(resolved_shell))
                         return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EINVAL),
                                           "'%s' is not a valid login shell field.", resolved_shell);