diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-04-25 17:58:34 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-04-25 18:08:15 +0200 |
commit | 55ace8e5c58441d1a2c64b297a38b232ef0c0e28 (patch) | |
tree | f1947154f32a1afc8216d36c4171de70cc66cad5 /src/shared/creds-util.c | |
parent | 4a75704b166de533cedf8f9fab16ffae77bf2093 (diff) | |
download | systemd-55ace8e5c58441d1a2c64b297a38b232ef0c0e28.tar.gz |
shared/creds-util: return 0 for missing creds in read_credential_strings_many
Realistically, the only thing that the caller can do is ignore failures related
to missing credentials. If the caller requires some credentials to be present,
they should just check which output variables are not NULL. One of the callers
was already doing that, and the other wanted to, but missed -ENOENT. By
suppressing -ENOENT and -ENXIO, both callers are simplified.
Fixes a warning at boot:
systemd-vconsole-setup[221]: Failed to import credentials, ignoring: No such file or directory
Diffstat (limited to 'src/shared/creds-util.c')
-rw-r--r-- | src/shared/creds-util.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c index d570f49e7b..59f580775d 100644 --- a/src/shared/creds-util.c +++ b/src/shared/creds-util.c @@ -96,17 +96,21 @@ int read_credential_strings_many_internal( /* Reads a bunch of credentials into the specified buffers. If the specified buffers are already * non-NULL frees them if a credential is found. Only supports string-based credentials - * (i.e. refuses embedded NUL bytes) */ + * (i.e. refuses embedded NUL bytes). + * + * 0 is returned when some or all credentials are missing. + */ if (!first_name) return 0; r = read_credential(first_name, &b, NULL); - if (r == -ENXIO) /* no creds passed at all? propagate this */ - return r; - if (r < 0) - ret = r; - else + if (r == -ENXIO) /* No creds passed at all? Bail immediately. */ + return 0; + if (r < 0) { + if (r != -ENOENT) + ret = r; + } else free_and_replace(*first_value, b); va_list ap; @@ -127,7 +131,7 @@ int read_credential_strings_many_internal( r = read_credential(name, &bb, NULL); if (r < 0) { - if (ret >= 0) + if (ret >= 0 && r != -ENOENT) ret = r; } else free_and_replace(*value, bb); |