1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-29 01:13:08 +00:00

Switch to OPIE

This commit is contained in:
Andrey A. Chernov 2001-07-30 15:51:33 +00:00
parent c8d50ea6f1
commit 919e336a9b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=45625
6 changed files with 186 additions and 138 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= qpopper
PORTVERSION= 2.53
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= mail
MASTER_SITES= ftp://ftp.qualcomm.com/eudora/servers/unix/popper/old/
DISTNAME= ${PORTNAME}${PORTVERSION}
@ -28,10 +28,8 @@ O_DEFS= -DSETPROCTITLE -DKEEP_TEMP_DROP -DBSD44_DBM -DBIND43 \
-DBULLDB -DNONAUTHFILE='\"/etc/ftpusers\"'
.if !defined(APOP_ONLY)
.if exists(/usr/lib/libskey.a)
P_LIBS= -lskey
O_DEFS+= -DSKEY
.endif
P_LIBS= -lopie
O_DEFS+= -DOPIE
.else
O_DEFS+= -DAPOP_ONLY
.endif

View File

@ -1,123 +1,74 @@
SKEY + pw_expire patches
*** pop_pass.c.orig Fri May 24 22:26:25 1996
--- pop_pass.c Tue Dec 10 23:52:23 1996
***************
*** 482,497 ****
POP * p;
struct passwd * pw;
{
/* We don't accept connections from users with null passwords */
/* Compare the supplied password with the password file entry */
! if ((pw->pw_passwd == NULL) || (*pw->pw_passwd == '\0') ||
! strcmp(crypt(p->pop_parm[1], pw->pw_passwd), pw->pw_passwd)) {
! sleep(SLEEP_SECONDS);
! return (pop_msg(p,POP_FAILURE, pwerrmsg, p->user));
}
return(POP_SUCCESS);
}
#endif /* AUTH */
--- 482,530 ----
POP * p;
struct passwd * pw;
{
+ #ifdef SKEY
+ int pass_ok;
+ #endif
+ #if defined(BSD) && (BSD >= 199306)
+ /* Check password change and expire times before granting access */
+ time_t now = time((time_t *) NULL);
+
+ if ((pw->pw_change && now > pw->pw_change) ||
+ (pw->pw_expire && now > pw->pw_expire))
+ goto error;
+ #endif
+
/* We don't accept connections from users with null passwords */
+ if ((pw->pw_passwd == NULL) || (*pw->pw_passwd == '\0'))
+ goto error;
+
/* Compare the supplied password with the password file entry */
+ #ifdef SKEY
+ pass_ok = skeyaccess(p->user, NULL, p->client, p->ipaddr);
+ if (strcmp(skey_crypt(p->pop_parm[1], pw->pw_passwd, pw, pass_ok),
+ pw->pw_passwd)) {
+ static char buf[128];
+ struct skey skey;
! if (skeychallenge(&skey, p->user, buf))
! goto error;
! if (pass_ok)
! sleep(SLEEP_SECONDS);
! return (pop_msg(p,POP_FAILURE,
! "\"%s\" %s%s, password is incorrect.",
! p->user, buf,
! pass_ok ? "" : " (required)"));
}
+ #else
+ if (strcmp(crypt(p->pop_parm[1], pw->pw_passwd), pw->pw_passwd))
+ goto error;
+ #endif
return(POP_SUCCESS);
+
+ error:
+ sleep(SLEEP_SECONDS);
+ return (pop_msg(p,POP_FAILURE, pwerrmsg, p->user));
}
#endif /* AUTH */
*** pop_user.c.orig Sat Mar 29 07:30:36 1997
--- pop_user.c Wed Apr 23 07:03:37 1997
***************
*** 163,168 ****
--- 163,180 ----
}
#endif /* APOP */
+ #ifdef SKEY
+ {
+ static char buf[128];
+ struct skey skey;
+
+ if (!skeychallenge(&skey, p->user, buf))
+ return(pop_msg(p,POP_SUCCESS,"%s%s", buf,
+ skeyaccess(p->user, NULL, p->client, p->ipaddr) ?
+ "" : " (required)"));
--- pop_pass.c.orig Mon Jul 30 19:29:19 2001
+++ pop_pass.c Mon Jul 30 19:29:25 2001
@@ -19,6 +19,12 @@
#include <pwd.h>
#include "popper.h"
+#ifdef OPIE
+#include <opie.h>
+extern int pwok;
+extern struct opie opiestate;
+#endif /* OPIE */
+
#define SLEEP_SECONDS 10
@@ -487,16 +493,28 @@
POP * p;
struct passwd * pw;
{
+#if defined(BSD) && (BSD >= 199306)
+ /* Check password change and expire times before granting access */
+ time_t now = time((time_t *) NULL);
+
+ if ((pw->pw_change && now > pw->pw_change) ||
+ (pw->pw_expire && now > pw->pw_expire))
+ goto error;
+#endif
+
/* We don't accept connections from users with null passwords */
- /* Compare the supplied password with the password file entry */
+ if ((pw->pw_passwd == NULL) || (*pw->pw_passwd == '\0'))
+ goto error;
- if ((pw->pw_passwd == NULL) || (*pw->pw_passwd == '\0') ||
- strcmp(crypt(p->pop_parm[1], pw->pw_passwd), pw->pw_passwd)) {
- sleep(SLEEP_SECONDS);
- return (pop_msg(p,POP_FAILURE, pwerrmsg, p->user));
- }
+ /* Compare the supplied password with the password file entry */
+ if (strcmp(crypt(p->pop_parm[1], pw->pw_passwd), pw->pw_passwd))
+ goto error;
return(POP_SUCCESS);
+
+ error:
+ sleep(SLEEP_SECONDS);
+ return (pop_msg(p,POP_FAILURE, pwerrmsg, p->user));
}
#endif /* AUTH_SPECIAL */
@@ -611,12 +629,23 @@
return(pop_msg(p, POP_FAILURE, "\"%s\": shell not found.", p->user));
#endif
+#ifdef OPIE
+ if (opieverify(&opiestate, p->pop_parm[1])) {
+ if (pwok) {
+#endif /* OPIE */
if ((p->kerberos ? auth_user_kerberos(p, pw) : auth_user(p, pwp))
!= POP_SUCCESS) {
pop_log(p,POP_PRIORITY,"Failed attempted login to %s from host %s",
p->user, p->client);
return(POP_FAILURE);
}
+#ifdef OPIE
+ } else {
+ sleep(SLEEP_SECONDS);
+ return (pop_msg(p,POP_FAILURE, pwerrmsg, p->user));
+ }
+ }
+ #endif
+
/* Tell the user that the password is required */
return (pop_msg(p,POP_SUCCESS,"Password required for %s.",p->user));
}
*** popper.h.orig Thu Nov 20 00:20:39 1997
--- popper.h Thu Nov 20 16:27:10 1997
***************
*** 31,41 ****
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
- # if (defined(BSD) && (BSD >= 199103))
- # define HAVE_UNISTD_H
- # define HAVE_VPRINTF
- # define BIND43
- # endif
#endif
#ifdef BSDI
--- 31,36 ----
***************
*** 308,313 ****
--- 303,311 ----
extern AUTH_DAT kdata;
#endif /* KERBEROS */
+ #if defined(SKEY)
+ #include <skey.h>
+ #endif
#if defined(AUTHFILE)
extern int checkauthfile();
#endif
+#endif /* OPIE */
#ifdef SECURENISPLUS
seteuid(uid_save);

View File

@ -0,0 +1,45 @@
--- pop_user.c.orig Fri Jul 10 03:44:08 1998
+++ pop_user.c Mon Jul 30 19:30:00 2001
@@ -40,6 +40,12 @@
#include "popper.h"
+#ifdef OPIE
+#include <opie.h>
+int pwok, af_pwok;
+struct opie opiestate;
+#endif /* OPIE */
+
/*
* user: Prompt for the user name at the start of a POP session
*/
@@ -62,6 +68,9 @@
struct stat st;
datum key, value;
# endif
+#ifdef OPIE
+ char prompt[OPIE_CHALLENGE_MAX + 1];
+#endif /* OPIE */
#ifdef KERBEROS
if (p->kerberos && strcmp(p->pop_parm[1], p->user)) {
@@ -167,6 +176,19 @@
#endif /* APOP */
/* Tell the user that the password is required */
+#ifdef OPIE
+ if (((pw = getpwnam(p->user)) == NULL) || (pw->pw_passwd == NULL) ||
+ (*pw->pw_passwd == '\0'))
+ return (pop_auth_fail(p, POP_FAILURE, pwerrmsg, p->user));
+
+ pwok = af_pwok && opiealways(pw->pw_dir);
+
+ opiechallenge(&opiestate, p->user, prompt);
+
+ return (pop_msg(p,POP_SUCCESS,"OTP response %s %s for %s.", prompt,
+ pwok ? "requested" : "required", p->user));
+#else /* OPIE */
return (pop_msg(p,POP_SUCCESS,"Password required for %s.",p->user));
+#endif /* OPIE */
}

View File

@ -1,6 +1,18 @@
--- popper.h.orig Mon Apr 17 22:33:43 2000
+++ popper.h Mon Apr 17 22:50:27 2000
@@ -55,11 +55,14 @@
--- popper.h.orig Mon Jul 30 19:28:19 2001
+++ popper.h Mon Jul 30 19:30:20 2001
@@ -31,11 +31,6 @@
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
-# if (defined(BSD) && (BSD >= 199103))
-# define HAVE_UNISTD_H
-# define HAVE_VPRINTF
-# define BIND43
-# endif
#endif
#ifdef BSDI
@@ -60,11 +55,14 @@
#define MAXUSERNAMELEN 65
#define MAXDROPLEN 64

View File

@ -1,34 +1,76 @@
--- pop_init.c.orig Thu Jul 9 19:44:07 1998
+++ pop_init.c Mon Jul 12 22:56:01 1999
@@ -237,4 +237,4 @@
--- pop_init.c.orig Fri Jul 10 03:44:07 1998
+++ pop_init.c Mon Jul 30 19:29:00 2001
@@ -32,6 +32,11 @@
# include <strings.h>
#endif
+#ifdef OPIE
+#include <opie.h>
+extern int af_pwok;
+#endif /* OPIE */
+
#ifndef HAVE_INDEX
# define index(s,c) strchr(s,c)
# define rindex(s,c) strrchr(s,c)
@@ -113,6 +118,10 @@
}
#endif /* KERBEROS */
+#ifdef OPIE
+ af_pwok = opieaccessfile(p->client);
+#endif /* OPIE */
+
return(POP_SUCCESS);
}
@@ -235,8 +244,8 @@
if ((p->trace = fopen(optarg,"a+")) == NULL) {
pop_log(p,POP_PRIORITY,
- "Unable to open trace file \"%s\", err = %d",
- optarg,errno);
+ "Unable to open trace file \"%s\": ",
+ optarg, strerror(errno));
exit(1);
@@ -268,3 +268,4 @@
}
trace_file_name = optarg;
@@ -266,7 +275,8 @@
len = sizeof(cs);
if (getpeername(sp,(struct sockaddr *)&cs,&len) < 0){
pop_log(p,POP_PRIORITY,
- "Unable to obtain socket and address of client, err = %d",errno);
+ "Unable to obtain socket and address of client: %s",
+ strerror(errno));
exit(1);
@@ -283,4 +284,4 @@
}
@@ -281,8 +291,8 @@
ch = gethostbyaddr((char *) &cs.sin_addr, sizeof(cs.sin_addr), AF_INET);
if (ch == NULL){
pop_log(p,POP_PRIORITY,
- "(v%s) Unable to get canonical name of client, err = %d",
- VERSION, errno);
+ "(v"VERSION") Unable to get canonical name of client %s: %s",
+ p->ipaddr, hstrerror(h_errno));
p->client = p->ipaddr;
@@ -362,3 +363,4 @@
}
/* Save the cannonical name of the client host in
@@ -360,14 +370,16 @@
/* Create input file stream for TCP/IP communication */
if ((p->input = fdopen(sp,"r")) == NULL){
pop_log(p,POP_PRIORITY,
- "Unable to open communication stream for input, err = %d",errno);
+ "Unable to open communication stream for input: ",
+ strerror(errno));
exit (1);
@@ -369,3 +371,4 @@
}
/* Create output file stream for TCP/IP communication */
if ((p->output = fdopen(sp,"w")) == NULL){
pop_log(p,POP_PRIORITY,
- "Unable to open communication stream for output, err = %d",errno);
+ "Unable to open communication stream for output: ",
+ strerror(errno));
exit (1);
}

View File

@ -12,5 +12,5 @@ usrdir=${PREFIX}/etc/popper
if [ ! -d $usrdir ]; then
mkdir -p $usrdir
fi
chown pop.daemon $usrdir
chown pop:daemon $usrdir
chmod 700 $usrdir