]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
auth:credentials: Check if password_obtained > obtained
authorSamuel Cabrero <scabrero@samba.org>
Thu, 7 Sep 2023 12:51:15 +0000 (14:51 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 11 Sep 2023 03:36:28 +0000 (03:36 +0000)
Fixes reading the password from STDIN or environment vars if it was already
given in the command line:

$ export PASSWD_FD=0
$ ./bin/net offlinejoin composeodj <...> --password=FOO
<Waiting to read password from STDIN>

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Sep 11 03:36:28 UTC 2023 on atb-devel-224

auth/credentials/credentials.c

index 3690ac8c3a436385eb1d1212613b5987e14563ad..ab5efd90f26646c0abfff42829a7d5f38d89ffbb 100644 (file)
@@ -1555,6 +1555,10 @@ _PUBLIC_ bool cli_credentials_parse_password_fd(struct cli_credentials *credenti
        char *p;
        char pass[128];
 
+       if (credentials->password_obtained >= obtained) {
+               return false;
+       }
+
        for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */
                p && p - pass < sizeof(pass) - 1;) {
                switch (read(fd, p, 1)) {