~ubuntu-branches/ubuntu/breezy/pam/breezy

« back to all changes in this revision

Viewing changes to debian/patches-applied/035_pam_unix_security

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2004-06-28 14:28:08 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040628142808-adikk7vtfg3pzcjw
Tags: 0.76-22
* Add uploaders
* Document location of repository
* Fix options containing arguments in pam_unix, Closes: #254904

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
This is roughly an upstream patch version 1.15 of support.c
 
2
and 1.9 of   unix_chkpwd.c
 
3
However those patches conflicted with the password aging stuff and the password aging stuff was wrong for unix_chkpwd,
 
4
so this patch depends on the Debian pam_unix patch and changes that patch.
 
5
In short a real mess.
 
6
l
 
7
Index: Linux-PAM/modules/pam_unix/support.c
 
8
===================================================================
 
9
RCS file: /afs/sipb/project/debian/cvs/pam/Linux-PAM/modules/pam_unix/support.c,v
 
10
retrieving revision 1.6
 
11
diff -u -r1.6 support.c
 
12
--- Linux-PAM/modules/pam_unix/support.c        21 Sep 2002 18:35:57 -0000      1.6
 
13
+++ Linux-PAM/modules/pam_unix/support.c        15 Oct 2002 14:21:11 -0000
 
14
@@ -608,49 +608,50 @@
 
15
                        retval = PAM_AUTHINFO_UNAVAIL;
 
16
                }
 
17
        } else {
 
18
-               if (!strlen(salt)) {
 
19
-                       /* the stored password is NULL */
 
20
-                       if (off(UNIX__NONULL, ctrl)) {  /* this means we've succeeded */
 
21
-                               D(("user has empty password - access granted"));
 
22
-                               retval = PAM_SUCCESS;
 
23
-                       } else {
 
24
-                               D(("user has empty password - access denied"));
 
25
-                               retval = PAM_AUTH_ERR;
 
26
-                       }
 
27
-               } else if (!p) {
 
28
-                               retval = PAM_AUTH_ERR;
 
29
+           int salt_len = strlen(salt);
 
30
+           if (!salt_len) {
 
31
+               /* the stored password is NULL */
 
32
+               if (off(UNIX__NONULL, ctrl)) {/* this means we've succeeded */
 
33
+                   D(("user has empty password - access granted"));
 
34
+                   retval = PAM_SUCCESS;
 
35
                } else {
 
36
+                   D(("user has empty password - access denied"));
 
37
+                   retval = PAM_AUTH_ERR;
 
38
+               }
 
39
+           } else if (!p || (*salt == '*') || (salt_len < 13)) {
 
40
+               retval = PAM_AUTH_ERR;
 
41
+           } else {
 
42
                        /* Hack off sysv pw aging foo */
 
43
                        if (strrchr(salt, ',')) *(strrchr(salt, ',')) = '\0';
 
44
-                       if (!strncmp(salt, "$1$", 3)) {
 
45
-                               pp = Goodcrypt_md5(p, salt);
 
46
-                               if (strcmp(pp, salt) != 0) {
 
47
-                                       _pam_delete(pp);
 
48
-                                       pp = Brokencrypt_md5(p, salt);
 
49
-                               }
 
50
-                       } else {
 
51
-                               pp = bigcrypt(p, salt);
 
52
-                       }
 
53
-                       p = NULL;               /* no longer needed here */
 
54
+               if (!strncmp(salt, "$1$", 3)) {
 
55
+                   pp = Goodcrypt_md5(p, salt);
 
56
+                   if (strcmp(pp, salt) != 0) {
 
57
+                       _pam_delete(pp);
 
58
+                       pp = Brokencrypt_md5(p, salt);
 
59
+                   }
 
60
+               } else {
 
61
+                   pp = bigcrypt(p, salt);
 
62
+               }
 
63
+               p = NULL;               /* no longer needed here */
 
64
 
 
65
-                       /* the moment of truth -- do we agree with the password? */
 
66
-                       D(("comparing state of pp[%s] and salt[%s]", pp, salt));
 
67
+               /* the moment of truth -- do we agree with the password? */
 
68
+               D(("comparing state of pp[%s] and salt[%s]", pp, salt));
 
69
 
 
70
-                       /*
 
71
-                        * Note, we are comparing the bigcrypt of the password with
 
72
-                        * the contents of the password field. If the latter was
 
73
-                        * encrypted with regular crypt (and not bigcrypt) it will
 
74
-                        * have been truncated for storage relative to the output
 
75
-                        * of bigcrypt here. As such we need to compare only the
 
76
-                        * stored string with the subset of bigcrypt's result.
 
77
-                        * Bug 521314: The strncmp comparison is for legacy support.
 
78
-                        */
 
79
-                       if (strncmp(pp, salt, strlen(salt)) == 0) {
 
80
-                               retval = PAM_SUCCESS;
 
81
-                       } else {
 
82
-                               retval = PAM_AUTH_ERR;
 
83
-                       }
 
84
+               /*
 
85
+                * Note, we are comparing the bigcrypt of the password with
 
86
+                * the contents of the password field. If the latter was
 
87
+                * encrypted with regular crypt (and not bigcrypt) it will
 
88
+                * have been truncated for storage relative to the output
 
89
+                * of bigcrypt here. As such we need to compare only the
 
90
+                * stored string with the subset of bigcrypt's result.
 
91
+                * Bug 521314: The strncmp comparison is for legacy support.
 
92
+                */
 
93
+               if (strncmp(pp, salt, salt_len) == 0) {
 
94
+                   retval = PAM_SUCCESS;
 
95
+               } else {
 
96
+                   retval = PAM_AUTH_ERR;
 
97
                }
 
98
+           }
 
99
        }
 
100
 
 
101
        if (retval == PAM_SUCCESS) {
 
102
Index: Linux-PAM/modules/pam_unix/unix_chkpwd.c
 
103
===================================================================
 
104
RCS file: /afs/sipb/project/debian/cvs/pam/Linux-PAM/modules/pam_unix/unix_chkpwd.c,v
 
105
retrieving revision 1.10
 
106
diff -u -r1.10 unix_chkpwd.c
 
107
--- Linux-PAM/modules/pam_unix/unix_chkpwd.c    21 Sep 2002 18:35:58 -0000      1.10
 
108
+++ Linux-PAM/modules/pam_unix/unix_chkpwd.c    15 Oct 2002 14:21:11 -0000
 
109
@@ -101,6 +101,7 @@
 
110
        char *salt = NULL;
 
111
        char *pp = NULL;
 
112
        int retval = UNIX_FAILED;
 
113
+       int salt_len;
 
114
 
 
115
        /* UNIX passwords area */
 
116
        setpwent();
 
117
@@ -140,8 +141,10 @@
 
118
                return retval;
 
119
        }
 
120
 
 
121
-       if (strlen(salt) == 0)
 
122
+       salt_len = strlen(salt);
 
123
+       if (salt_len == 0) {
 
124
                return (opt == 0) ? UNIX_FAILED : UNIX_PASSED;
 
125
+       }
 
126
        else if (p == NULL || strlen(p) == 0)
 
127
                return UNIX_FAILED;
 
128
 
 
129
@@ -149,7 +152,7 @@
 
130
        {
 
131
            char *tmp;
 
132
 
 
133
-           if ((tmp = strrchr(p, ',')) != NULL) *tmp = '\0';
 
134
+           if ((tmp = strrchr(salt, ',')) != NULL) *tmp = '\0';
 
135
        }
 
136
 
 
137
        /* the moment of truth -- do we agree with the password? */
 
138
@@ -163,6 +166,8 @@
 
139
                        if (strcmp(pp, salt) == 0)
 
140
                                retval = UNIX_PASSED;
 
141
                }
 
142
+       } else if ((*salt == '*') || (salt_len < 13)) {
 
143
+           retval = UNIX_FAILED;
 
144
        } else {
 
145
                pp = bigcrypt(p, salt);
 
146
                /*
 
147
@@ -174,7 +179,7 @@
 
148
                 * stored string with the subset of bigcrypt's result.
 
149
                 * Bug 521314: the strncmp comparison is for legacy support.
 
150
                 */
 
151
-               if (strncmp(pp, salt, strlen(salt)) == 0) {
 
152
+               if (strncmp(pp, salt, salt_len) == 0) {
 
153
                        retval = UNIX_PASSED;
 
154
                }
 
155
        }