diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-11-30 15:05:15 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-11-30 15:05:24 +0100 |
commit | 16edfadc6773265967be37b63ab6ce00f8b49157 (patch) | |
tree | 1ecebe9634d3ae988a3c4d55a1559e515d77df2a /src/shared/ask-password-api.c | |
parent | sd-dhcp6-client: fix error handling (diff) | |
download | systemd-16edfadc6773265967be37b63ab6ce00f8b49157.tar.xz systemd-16edfadc6773265967be37b63ab6ce00f8b49157.zip |
ask-password: fix error handling
ERRNO_IS_NOT_SUPPORTED() also matches positive values.
Fortunately, lookup_key() does not return positive values.
Diffstat (limited to 'src/shared/ask-password-api.c')
-rw-r--r-- | src/shared/ask-password-api.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index 07e301276f..b6cdb99596 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -153,15 +153,16 @@ static int ask_password_keyring(const char *keyname, AskPasswordFlags flags, cha return -EUNATCH; r = lookup_key(keyname, &serial); - if (ERRNO_IS_NOT_SUPPORTED(r) || r == -EPERM) /* when retrieving the distinction between "kernel or - * container manager don't support or allow this" and - * "no matching key known" doesn't matter. Note that we - * propagate EACCESS here (even if EPERM not) since - * that is used if the keyring is available but we lack - * access to the key. */ - return -ENOKEY; - if (r < 0) + if (r < 0) { + /* when retrieving the distinction between "kernel or container manager don't support + * or allow this" and "no matching key known" doesn't matter. Note that we propagate + * EACCESS here (even if EPERM not) since that is used if the keyring is available but + * we lack access to the key. */ + if (ERRNO_IS_NOT_SUPPORTED(r) || r == -EPERM) + return -ENOKEY; + return r; + } return retrieve_key(serial, ret); } |