]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ask-password-api: return if read_credential() failed
authorDavid Tardon <dtardon@redhat.com>
Thu, 6 Nov 2025 13:04:32 +0000 (14:04 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 6 Nov 2025 23:38:13 +0000 (23:38 +0000)
The current code causes assertion in strv_parse_nulstr() if
read_credential() results in an error different from ENXIO or ENOENT
(strace shows I'm getting EACCES):

 # homectl create waldo --real-name=Waldo --disk-size=200M

Before:

 Assertion 's || l <= 0' failed at src/basic/nulstr-util.c:32, function strv_parse_nulstr_full(). Aborting.

After:

 Failed to acquire password: Permission denied

Follow-up-for: 8806bb4bc7fa15d6ca46e81b8d535730209a3b66
(cherry picked from commit 399c9f847e222d6e62c553ac9ea2bebeb7c1be7f)

src/shared/ask-password-api.c

index dd6b8abc654236a7a1f77951a880a8a882674b54..b8602eee788155fa0d6e663d8a0f1e1aa2640017 100644 (file)
@@ -1133,6 +1133,8 @@ static int ask_password_credential(const AskPasswordRequest *req, AskPasswordFla
         r = read_credential(req->credential, (void**) &buffer, &size);
         if (IN_SET(r, -ENXIO, -ENOENT)) /* No credentials passed or this credential not defined? */
                 return -ENOKEY;
+        if (r < 0)
+                return r;
 
         l = strv_parse_nulstr(buffer, size);
         if (!l)