summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2003-02-02 21:03:28 +0000
committerobrien <obrien@FreeBSD.org>2003-02-02 21:03:28 +0000
commit2d3aea237652e8506a1e409886e8d9b1fbee4ba5 (patch)
treefd45b104270d517a3bf48c3431a6037bcab2abcc /contrib
parentd4aea93bfdd3031745a1bce5622fcb1417e9cb4e (diff)
downloadFreeBSD-src-2d3aea237652e8506a1e409886e8d9b1fbee4ba5.zip
FreeBSD-src-2d3aea237652e8506a1e409886e8d9b1fbee4ba5.tar.gz
Merge our rev 1.2 PAM support into 'nbsd_20030122'.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/lukemftpd/src/ftpd.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/contrib/lukemftpd/src/ftpd.c b/contrib/lukemftpd/src/ftpd.c
index a709c9c..b623919 100644
--- a/contrib/lukemftpd/src/ftpd.c
+++ b/contrib/lukemftpd/src/ftpd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ftpd.c,v 1.147 2002/11/29 14:40:00 lukem Exp $ */
+/* $NetBSD: ftpd.c,v 1.150 2003/01/22 04:46:08 lukem Exp $ */
/*
* Copyright (c) 1997-2001 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: ftpd.c,v 1.147 2002/11/29 14:40:00 lukem Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.150 2003/01/22 04:46:08 lukem Exp $");
#endif
#endif /* not lint */
__FBSDID("$FreeBSD$");
@@ -686,8 +686,7 @@ user(const char *name)
} else
pw = sgetpwnam(name);
- if (logging)
- strlcpy(curname, name, sizeof(curname));
+ strlcpy(curname, name, sizeof(curname));
/* check user in /etc/ftpusers, and setup class */
permitted = checkuser(_PATH_FTPUSERS, curname, 1, 0, &class);
@@ -1650,7 +1649,7 @@ dataconn(const char *name, off_t size, const char *fmode)
{
char sizebuf[32];
FILE *file;
- int retry = 0, tos, keepalive;
+ int retry, tos, keepalive, conerrno;
file_size = size;
byte_count = 0;
@@ -1704,30 +1703,38 @@ dataconn(const char *name, off_t size, const char *fmode)
if (usedefault)
data_dest = his_addr;
usedefault = 1;
- file = getdatasock(fmode);
- if (file == NULL) {
- char hbuf[NI_MAXHOST];
- char pbuf[NI_MAXSERV];
-
- if (getnameinfo((struct sockaddr *)&data_source.si_su,
- data_source.su_len, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
- NI_NUMERICHOST | NI_NUMERICSERV))
- strlcpy(hbuf, "?", sizeof(hbuf));
- reply(425, "Can't create data socket (%s,%s): %s.",
- hbuf, pbuf, strerror(errno));
- return (NULL);
- }
- data = fileno(file);
- while (connect(data, (struct sockaddr *)&data_dest.si_su,
- data_dest.su_len) < 0) {
- if (errno == EADDRINUSE && retry < swaitmax) {
+ retry = conerrno = 0;
+ do {
+ file = getdatasock(fmode);
+ if (file == NULL) {
+ char hbuf[NI_MAXHOST];
+ char pbuf[NI_MAXSERV];
+
+ if (getnameinfo((struct sockaddr *)&data_source.si_su,
+ data_source.su_len, hbuf, sizeof(hbuf), pbuf,
+ sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV))
+ strlcpy(hbuf, "?", sizeof(hbuf));
+ reply(425, "Can't create data socket (%s,%s): %s.",
+ hbuf, pbuf, strerror(errno));
+ return (NULL);
+ }
+ data = fileno(file);
+ conerrno = 0;
+ if (connect(data, (struct sockaddr *)&data_dest.si_su,
+ data_dest.su_len) == 0)
+ break;
+ conerrno = errno;
+ (void) fclose(file);
+ data = -1;
+ if (conerrno == EADDRINUSE) {
sleep((unsigned) swaitint);
retry += swaitint;
- continue;
+ } else {
+ break;
}
+ } while (retry <= swaitmax);
+ if (conerrno != 0) {
perror_reply(425, "Can't build data connection");
- (void) fclose(file);
- data = -1;
return (NULL);
}
reply(150, "Opening %s mode data connection for '%s'%s.",
OpenPOWER on IntegriCloud