1
*** uucpd.c Fri Jul 27 16:16:23 2001
2
--- uucpd-pam.c Sat Jul 28 11:12:08 2001
6
* Does utmp/wtmp accounting.
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
12
#include <sys/types.h>
21
#include <sys/socket.h>
22
#include <netinet/in.h>
23
#include <arpa/inet.h>
34
! #include <security/pam_appl.h>
35
! #include <security/pam_misc.h>
37
#include <sys/socket.h>
38
#include <netinet/in.h>
39
#include <arpa/inet.h>
42
+ int myconv(int n,const struct pam_message **msg, struct pam_response **resp, void *ap)
47
+ misc_conv(n,msg,resp,ap);
49
+ * The supplied misc_conv function doesn't seem to strip the
50
+ * trailing return character so I do it here...
53
+ for (cp=((*resp)->resp);*cp!=0;cp++)
54
+ if (*cp=='\r') *cp=0;
58
+ static struct pam_conv conv = {
75
struct sockaddr_in sin;
85
+ pam_handle_t *pamh=NULL;
88
* Make sure we have fds 0, 1 and 2.
91
strcpy(host, inet_ntoa(sin.sin_addr));
102
if (login[0] != 0) break;
104
- printf("Password: ");
106
- if (getstr(0, pass, 32) < 0)
111
! if ((pwd = getpwnam(login)) == NULL)
114
! if ((spwd = getspnam(login)) != NULL)
115
! pwd->pw_passwd = spwd->sp_pwdp;
117
! s = crypt(pass, pwd->pw_passwd);
118
! if (strcmp(s, pwd->pw_passwd) != 0) {
120
syslog(LOG_AUTHPRIV|LOG_NOTICE,
121
"invalid password for `%s' on `TCP' from `%s'",
124
if (login[0] != 0) break;
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));
138
! if ((pwd = getpwnam(login)) == NULL) {
140
syslog(LOG_AUTHPRIV|LOG_NOTICE,
141
"invalid password for `%s' on `TCP' from `%s'",
147
- * Account may have expired.
149
- if (spwd && spwd->sp_expire > 0 && spwd->sp_expire < time(NULL))
153
* See if we have a valid shell: the basename must
156
if ((s = strrchr(pwd->pw_shell, '/')) == NULL)
162
* See if we have a valid shell: the basename must
165
+ * Note: arguably this check should be done by PAM, but
166
+ * an appropriate PAM module doesn't exist to my knowledge.
168
if ((s = strrchr(pwd->pw_shell, '/')) == NULL)
173
/* FIXME: SCREAM (oh well..) */
176
+ pam_open_session(pamh, 0);
179
sprintf(ut.ut_line, "uucp%d", ut.ut_pid);
185
updwtmp(WTMP_FILE, &ut);
186
+ pam_close_session(pamh, 0);
187
+ pam_end(pamh,PAM_SUCCESS);