]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: restore ability that SetCredential= can act as fallback for LoadCredential=
authorLennart Poettering <lennart@poettering.net>
Thu, 14 Apr 2022 16:01:28 +0000 (18:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Apr 2022 09:32:47 +0000 (11:32 +0200)
If SetCredential= and LoadCredentials= are combined for the same
credential name, then the former shall act as fallback for the latter in
case the source file does not exist. That's documented, but didn't work.
Let's fix that.

src/core/execute.c

index 5e6b1131e47c130157c81db8090999ae6cf250e7..fac3be8e29fc1d3de5ffea384321b557485bbd53 100644 (file)
@@ -2792,8 +2792,10 @@ static int acquire_credentials(
 
                 if (path_is_absolute(lc->path)) {
                         sub_fd = open(lc->path, O_DIRECTORY|O_CLOEXEC|O_RDONLY);
-                        if (sub_fd < 0 && errno != ENOTDIR)
-                                return -errno;
+                        if (sub_fd < 0 && !IN_SET(errno,
+                                                  ENOTDIR,  /* Not a directory */
+                                                  ENOENT))  /* Doesn't exist? */
+                                return log_debug_errno(errno, "Failed to open '%s': %m", lc->path);
                 }
 
                 if (sub_fd < 0)