~ubuntu-branches/ubuntu/breezy/uucp/breezy

« back to all changes in this revision

Viewing changes to debian/patch.uucpd.pam

  • Committer: Bazaar Package Importer
  • Author(s): Peter Palfrader
  • Date: 2004-12-30 15:30:22 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041230153022-mx4cdr9j3u9bldo3
Tags: 1.07-12
Add cs localisation for debconf templates (closes: #287305).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
*** uucpd.c     Fri Jul 27 16:16:23 2001
2
 
--- uucpd-pam.c Sat Jul 28 11:12:08 2001
3
 
***************
4
 
*** 4,9 ****
5
 
--- 4,10 ----
6
 
   *            Does utmp/wtmp accounting.
7
 
   *
8
 
   * Version:   @(#)uucpd.c  1.00  19-May-1998  miquels@cistron.nl
9
 
+  * Version:   @(#)uucpd.c  1.10  28-Jul-2001  alex@king.net.nz
10
 
   *
11
 
   */
12
 
  #include <sys/types.h>
13
 
***************
14
 
*** 19,32 ****
15
 
  
16
 
  #include <pwd.h>
17
 
  #include <grp.h>
18
 
! #include <shadow.h>
19
 
! #include <crypt.h>
20
 
  
21
 
  #include <sys/socket.h>
22
 
  #include <netinet/in.h>
23
 
  #include <arpa/inet.h>
24
 
  #include <netdb.h>
25
 
  
26
 
  
27
 
  void chop(char *s)
28
 
  {
29
 
--- 20,54 ----
30
 
  
31
 
  #include <pwd.h>
32
 
  #include <grp.h>
33
 
34
 
! #include <security/pam_appl.h>
35
 
! #include <security/pam_misc.h>
36
 
  
37
 
  #include <sys/socket.h>
38
 
  #include <netinet/in.h>
39
 
  #include <arpa/inet.h>
40
 
  #include <netdb.h>
41
 
  
42
 
+ int myconv(int n,const struct pam_message **msg, struct pam_response **resp, void *ap)
43
 
+ {
44
 
+       int k;
45
 
+       char *cp;
46
 
47
 
+       misc_conv(n,msg,resp,ap);
48
 
+       /* 
49
 
+        * The supplied misc_conv function doesn't seem to strip the
50
 
+        * trailing return character so I do it here...
51
 
+        */
52
 
+       for (k=0;k<n;k++)
53
 
+               for (cp=((*resp)->resp);*cp!=0;cp++)
54
 
+                       if (*cp=='\r') *cp=0;
55
 
+       return PAM_SUCCESS;
56
 
+ }
57
 
58
 
+ static struct pam_conv conv = {
59
 
+       myconv,
60
 
+       NULL
61
 
+ };
62
 
  
63
 
  void chop(char *s)
64
 
  {
65
 
***************
66
 
*** 73,82 ****
67
 
  int main(void)
68
 
  {
69
 
        char login[32];
70
 
-       char pass[32];
71
 
        char host[256];
72
 
        struct passwd *pwd;
73
 
-       struct spwd *spwd;
74
 
        char *s;
75
 
        struct sockaddr_in sin;
76
 
        int sinlen;
77
 
--- 95,102 ----
78
 
***************
79
 
*** 84,89 ****
80
 
--- 104,111 ----
81
 
        struct utmp ut;
82
 
        pid_t pid;
83
 
        int st;
84
 
+       int rv;
85
 
+       pam_handle_t *pamh=NULL;
86
 
  
87
 
        /*
88
 
         *      Make sure we have fds 0, 1 and 2.
89
 
***************
90
 
*** 110,116 ****
91
 
                strcpy(host, inet_ntoa(sin.sin_addr));
92
 
  
93
 
        login[0] = 0;
94
 
-       pass[0] = 0;
95
 
  
96
 
        alarm(60);
97
 
  
98
 
--- 132,137 ----
99
 
***************
100
 
*** 122,142 ****
101
 
                chop(login);
102
 
                if (login[0] != 0) break;
103
 
        }
104
 
-       printf("Password: ");
105
 
-       fflush(stdout);
106
 
-       if (getstr(0, pass, 32) < 0)
107
 
-               exit(1);
108
 
-       chop(pass);
109
 
-       alarm(0);
110
 
  
111
 
!       if ((pwd = getpwnam(login)) == NULL)
112
 
                goto incorrect;
113
 
114
 
!       if ((spwd = getspnam(login)) != NULL)
115
 
!               pwd->pw_passwd = spwd->sp_pwdp;
116
 
117
 
!       s = crypt(pass, pwd->pw_passwd);
118
 
!       if (strcmp(s, pwd->pw_passwd) != 0) {
119
 
  incorrect:
120
 
                syslog(LOG_AUTHPRIV|LOG_NOTICE,
121
 
                        "invalid password for `%s' on `TCP' from `%s'",
122
 
--- 143,161 ----
123
 
                chop(login);
124
 
                if (login[0] != 0) break;
125
 
        }
126
 
  
127
 
!       rv=pam_start("uucp",login,&conv,&pamh);
128
 
!       if (rv==PAM_SUCCESS)
129
 
!               rv=pam_authenticate(pamh, 0);
130
 
!       if (rv==PAM_SUCCESS)
131
 
!               rv=pam_set_item(pamh,PAM_RHOST,host);
132
 
!       if (rv==PAM_SUCCESS) 
133
 
!               rv=pam_acct_mgmt(pamh,0);
134
 
!       if (rv!=PAM_SUCCESS) {
135
 
!               syslog(LOG_AUTHPRIV|LOG_NOTICE,pam_strerror(pamh,rv));
136
 
                goto incorrect;
137
 
!       }
138
 
!       if ((pwd = getpwnam(login)) == NULL) {
139
 
  incorrect:
140
 
                syslog(LOG_AUTHPRIV|LOG_NOTICE,
141
 
                        "invalid password for `%s' on `TCP' from `%s'",
142
 
***************
143
 
*** 146,159 ****
144
 
        }
145
 
  
146
 
        /*
147
 
-        *      Account may have expired.
148
 
-        */
149
 
-       if (spwd && spwd->sp_expire > 0 && spwd->sp_expire < time(NULL))
150
 
-               goto incorrect;
151
 
152
 
-       /*
153
 
         *      See if we have a valid shell: the basename must
154
 
         *      match uucico*
155
 
         */
156
 
        if ((s = strrchr(pwd->pw_shell, '/')) == NULL)
157
 
                s = pwd->pw_shell;
158
 
--- 165,175 ----
159
 
        }
160
 
  
161
 
        /*
162
 
         *      See if we have a valid shell: the basename must
163
 
         *      match uucico*
164
 
+        *
165
 
+        *      Note: arguably this check should be done by PAM, but
166
 
+        *      an appropriate PAM module doesn't exist to my knowledge.
167
 
         */
168
 
        if ((s = strrchr(pwd->pw_shell, '/')) == NULL)
169
 
                s = pwd->pw_shell;
170
 
***************
171
 
*** 187,192 ****
172
 
--- 203,209 ----
173
 
                        /* FIXME: SCREAM (oh well..) */
174
 
                        return 1;
175
 
                }
176
 
+               pam_open_session(pamh, 0);
177
 
  
178
 
                ut.ut_pid = pid;
179
 
                sprintf(ut.ut_line, "uucp%d", ut.ut_pid);
180
 
***************
181
 
*** 204,209 ****
182
 
--- 221,228 ----
183
 
                pututline(&ut);
184
 
                endutent();
185
 
                updwtmp(WTMP_FILE, &ut);
186
 
+               pam_close_session(pamh, 0);
187
 
+               pam_end(pamh,PAM_SUCCESS);
188
 
  
189
 
                return 0;
190
 
        }