summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2016-07-21 14:17:31 +1000
committerColin Watson <cjwatson@debian.org>2016-07-22 14:03:47 +0100
commitabde8dda29c2db2405d6fbca2fe022430e2c1177 (patch)
tree90e719f0f91195cf697ae0d4b13f24a6a760ff12 /openbsd-compat
parentdde63f7f998ac3812a26bbb2c1b2947f24fcd060 (diff)
Search users for one with a valid salt.
If the root account is locked (eg password "!!" or "*LK*") keep looking until we find a user with a valid salt to use for crypting passwords of invalid users. ok djm@ Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=dbf788b4d9d9490a5fff08a7b09888272bb10fcc Bug-Debian: https://bugs.debian.org/831902 Last-Update: 2016-07-22 Patch-Name: CVE-2016-6210-3.patch
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/xcrypt.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/openbsd-compat/xcrypt.c b/openbsd-compat/xcrypt.c
index 8913bb81a..cf6a9b99f 100644
--- a/openbsd-compat/xcrypt.c
+++ b/openbsd-compat/xcrypt.c
@@ -65,7 +65,9 @@
65 65
66/* 66/*
67 * Pick an appropriate password encryption type and salt for the running 67 * Pick an appropriate password encryption type and salt for the running
68 * system. 68 * system by searching through accounts until we find one that has a valid
69 * salt. Usually this will be root unless the root account is locked out.
70 * If we don't find one we return a traditional DES-based salt.
69 */ 71 */
70static const char * 72static const char *
71pick_salt(void) 73pick_salt(void)
@@ -78,14 +80,18 @@ pick_salt(void)
78 if (salt[0] != '\0') 80 if (salt[0] != '\0')
79 return salt; 81 return salt;
80 strlcpy(salt, "xx", sizeof(salt)); 82 strlcpy(salt, "xx", sizeof(salt));
81 if ((pw = getpwuid(0)) == NULL) 83 setpwent();
82 return salt; 84 while ((pw = getpwent()) != NULL) {
83 passwd = shadow_pw(pw); 85 passwd = shadow_pw(pw);
84 if (passwd[0] != '$' || (p = strrchr(passwd + 1, '$')) == NULL) 86 if (passwd[0] == '$' && (p = strrchr(passwd+1, '$')) != NULL) {
85 return salt; /* no $, DES */ 87 typelen = p - passwd + 1;
86 typelen = p - passwd + 1; 88 strlcpy(salt, passwd, MIN(typelen, sizeof(salt)));
87 strlcpy(salt, passwd, MIN(typelen, sizeof(salt))); 89 explicit_bzero(passwd, strlen(passwd));
88 explicit_bzero(passwd, strlen(passwd)); 90 goto out;
91 }
92 }
93 out:
94 endpwent();
89 return salt; 95 return salt;
90} 96}
91 97