09b44afcb6
- pam_unix: split out passwd change to a new helper binary (#236316) - pam_namespace: add support for temporary logons (#241226)
127 lines
3.5 KiB
Diff
127 lines
3.5 KiB
Diff
--- Linux-PAM-0.99.7.1/modules/pam_unix/support.c.bigcrypt 2007-01-23 10:41:21.000000000 +0100
|
|
+++ Linux-PAM-0.99.7.1/modules/pam_unix/support.c 2007-06-01 15:11:51.000000000 +0200
|
|
@@ -679,7 +679,7 @@
|
|
}
|
|
}
|
|
} else {
|
|
- int salt_len = strlen(salt);
|
|
+ size_t salt_len = strlen(salt);
|
|
if (!salt_len) {
|
|
/* the stored password is NULL */
|
|
if (off(UNIX__NONULL, ctrl)) {/* this means we've succeeded */
|
|
@@ -689,19 +689,19 @@
|
|
D(("user has empty password - access denied"));
|
|
retval = PAM_AUTH_ERR;
|
|
}
|
|
- } else if (!p || (*salt == '*')) {
|
|
+ } else if (!p || *salt == '*' || *salt == '!') {
|
|
retval = PAM_AUTH_ERR;
|
|
} else {
|
|
if (!strncmp(salt, "$1$", 3)) {
|
|
pp = Goodcrypt_md5(p, salt);
|
|
- if (strcmp(pp, salt) != 0) {
|
|
+ if (pp && strcmp(pp, salt) != 0) {
|
|
_pam_delete(pp);
|
|
pp = Brokencrypt_md5(p, salt);
|
|
}
|
|
} else if (*salt != '$' && salt_len >= 13) {
|
|
pp = bigcrypt(p, salt);
|
|
- if (strlen(pp) > salt_len) {
|
|
- pp[salt_len] = '\0';
|
|
+ if (pp && salt_len == 13 && strlen(pp) > salt_len) {
|
|
+ _pam_overwrite(pp + salt_len);
|
|
}
|
|
} else {
|
|
/*
|
|
@@ -715,7 +715,7 @@
|
|
/* the moment of truth -- do we agree with the password? */
|
|
D(("comparing state of pp[%s] and salt[%s]", pp, salt));
|
|
|
|
- if (strcmp(pp, salt) == 0) {
|
|
+ if (pp && strcmp(pp, salt) == 0) {
|
|
retval = PAM_SUCCESS;
|
|
} else {
|
|
retval = PAM_AUTH_ERR;
|
|
--- Linux-PAM-0.99.7.1/modules/pam_unix/unix_chkpwd.c.bigcrypt 2006-10-24 12:01:49.000000000 +0200
|
|
+++ Linux-PAM-0.99.7.1/modules/pam_unix/unix_chkpwd.c 2007-06-01 15:08:46.000000000 +0200
|
|
@@ -144,7 +144,7 @@
|
|
char *salt = NULL;
|
|
char *pp = NULL;
|
|
int retval = PAM_AUTH_ERR;
|
|
- int salt_len;
|
|
+ size_t salt_len;
|
|
|
|
/* UNIX passwords area */
|
|
setpwent();
|
|
@@ -189,6 +189,8 @@
|
|
return (nullok == 0) ? PAM_AUTH_ERR : PAM_SUCCESS;
|
|
}
|
|
if (p == NULL || strlen(p) == 0) {
|
|
+ _pam_overwrite(salt);
|
|
+ _pam_drop(salt);
|
|
return PAM_AUTHTOK_ERR;
|
|
}
|
|
|
|
@@ -196,11 +198,13 @@
|
|
retval = PAM_AUTH_ERR;
|
|
if (!strncmp(salt, "$1$", 3)) {
|
|
pp = Goodcrypt_md5(p, salt);
|
|
- if (strcmp(pp, salt) == 0) {
|
|
+ if (pp && strcmp(pp, salt) == 0) {
|
|
retval = PAM_SUCCESS;
|
|
} else {
|
|
+ _pam_overwrite(pp);
|
|
+ _pam_drop(pp);
|
|
pp = Brokencrypt_md5(p, salt);
|
|
- if (strcmp(pp, salt) == 0)
|
|
+ if (pp && strcmp(pp, salt) == 0)
|
|
retval = PAM_SUCCESS;
|
|
}
|
|
} else if (*salt == '$') {
|
|
@@ -209,10 +213,10 @@
|
|
* libcrypt nows about it? We should try it.
|
|
*/
|
|
pp = x_strdup (crypt(p, salt));
|
|
- if (strcmp(pp, salt) == 0) {
|
|
+ if (pp && strcmp(pp, salt) == 0) {
|
|
retval = PAM_SUCCESS;
|
|
}
|
|
- } else if ((*salt == '*') || (salt_len < 13)) {
|
|
+ } else if (*salt == '*' || *salt == '!' || salt_len < 13) {
|
|
retval = PAM_AUTH_ERR;
|
|
} else {
|
|
pp = bigcrypt(p, salt);
|
|
@@ -223,24 +227,21 @@
|
|
* have been truncated for storage relative to the output
|
|
* of bigcrypt here. As such we need to compare only the
|
|
* stored string with the subset of bigcrypt's result.
|
|
- * Bug 521314: the strncmp comparison is for legacy support.
|
|
+ * Bug 521314.
|
|
*/
|
|
- if (strncmp(pp, salt, salt_len) == 0) {
|
|
+ if (pp && salt_len == 13 && strlen(pp) > salt_len) {
|
|
+ _pam_overwrite(pp+salt_len);
|
|
+ }
|
|
+
|
|
+ if (pp && strcmp(pp, salt) == 0) {
|
|
retval = PAM_SUCCESS;
|
|
}
|
|
}
|
|
p = NULL; /* no longer needed here */
|
|
|
|
/* clean up */
|
|
- {
|
|
- char *tp = pp;
|
|
- if (pp != NULL) {
|
|
- while (tp && *tp)
|
|
- *tp++ = '\0';
|
|
- free(pp);
|
|
- }
|
|
- pp = tp = NULL;
|
|
- }
|
|
+ _pam_overwrite(pp);
|
|
+ _pam_drop(pp);
|
|
|
|
return retval;
|
|
}
|