CVS commit: src/libexec/ftpd

2021-07-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jul  3 14:59:49 UTC 2021

Modified Files:
src/libexec/ftpd: ftpd.c

Log Message:
Treat failed chdir/chroot for guest and chroot accounts as fatal.
Also treat failed set{e,}(u,g}id calls as fatal.
Addresses CVE-2020-7468, via FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.205 src/libexec/ftpd/ftpd.c:1.206
--- src/libexec/ftpd/ftpd.c:1.205	Tue Oct 15 14:29:32 2019
+++ src/libexec/ftpd/ftpd.c	Sat Jul  3 10:59:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.205 2019/10/15 18:29:32 christos Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.206 2021/07/03 14:59:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = "@(#)ftpd.c	8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ftpd.c,v 1.205 2019/10/15 18:29:32 christos Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.206 2021/07/03 14:59:49 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -1547,8 +1547,7 @@ do_pass(int pass_checked, int pass_rval,
 			"GUEST user %s: can't chdir to %s: %m",
 			pw->pw_name, homedir);
  bad_guest:
-			reply(550, "Can't set guest privileges.");
-			goto bad;
+			fatal("Can't set guest privileges.");
 		}
 		break;
 	case CLASS_CHROOT:
@@ -1571,8 +1570,7 @@ do_pass(int pass_checked, int pass_rval,
 			"CHROOT user %s: can't chdir to %s: %m",
 			pw->pw_name, homedir);
  bad_chroot:
-			reply(550, "Can't change root.");
-			goto bad;
+			fatal("Can't change root.");
 		}
 		break;
 	case CLASS_REAL:
@@ -1618,16 +1616,16 @@ do_pass(int pass_checked, int pass_rval,
 		dropprivs++;
 		if (setgid((gid_t)pw->pw_gid) < 0) {
 			reply(550, "Can't set gid.");
-			goto bad;
+			goto bad_perms;
 		}
 		if (setuid((uid_t)pw->pw_uid) < 0) {
 			reply(550, "Can't set uid.");
-			goto bad;
+			goto bad_perms;
 		}
 	} else {
 		if (seteuid((uid_t)pw->pw_uid) < 0) {
 			reply(550, "Can't set uid.");
-			goto bad;
+			goto bad_perms;
 		}
 	}
 	setenv("HOME", homedir, 1);
@@ -1686,6 +1684,11 @@ do_pass(int pass_checked, int pass_rval,
 #endif
 			/* Forget all about it... */
 	end_login();
+	return;
+
+bad_perms:
+	syslog(LOG_NOTICE, "user %s: can't setuid/gid: %m", pw->pw_name);
+	fatal("Can't drop privileges.");
 }
 
 void



CVS commit: src/libexec/ftpd

2020-08-22 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Aug 22 08:08:48 UTC 2020

Modified Files:
src/libexec/ftpd: ftpd.conf.5

Log Message:
ftpd.conf(5): remove duplicate "be"

Two be or not two be.
Noted by SAITOH Masanobu in private mail.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/libexec/ftpd/ftpd.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.conf.5
diff -u src/libexec/ftpd/ftpd.conf.5:1.37 src/libexec/ftpd/ftpd.conf.5:1.38
--- src/libexec/ftpd/ftpd.conf.5:1.37	Thu Apr  9 02:25:45 2009
+++ src/libexec/ftpd/ftpd.conf.5	Sat Aug 22 08:08:47 2020
@@ -1,6 +1,6 @@
-.\"	$NetBSD: ftpd.conf.5,v 1.37 2009/04/09 02:25:45 joerg Exp $
+.\"	$NetBSD: ftpd.conf.5,v 1.38 2020/08/22 08:08:47 lukem Exp $
 .\"
-.\" Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
+.\" Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 13, 2007
+.Dd August 22, 2020
 .Dt FTPD.CONF 5
 .Os
 .Sh NAME
@@ -476,7 +476,7 @@ Set the range of port number which will 
 .Ar max
 must be greater than
 .Ar min ,
-and both numbers must be be between
+and both numbers must be between
 .Dv IPPORT_RESERVED
 (1024) and 65535.
 If



CVS commit: src/libexec/ftpd

2020-07-03 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jul  4 05:18:37 UTC 2020

Modified Files:
src/libexec/ftpd: pfilter.c pfilter.h

Log Message:
add missing RCSIDs

(copyrights could be added too - that's up to christos@)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/libexec/ftpd/pfilter.c
cvs rdiff -u -r1.1 -r1.2 src/libexec/ftpd/pfilter.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/pfilter.c
diff -u src/libexec/ftpd/pfilter.c:1.3 src/libexec/ftpd/pfilter.c:1.4
--- src/libexec/ftpd/pfilter.c:1.3	Mon Jun 15 01:57:31 2020
+++ src/libexec/ftpd/pfilter.c	Sat Jul  4 05:18:37 2020
@@ -1,3 +1,5 @@
+/*	$NetBSD: pfilter.c,v 1.4 2020/07/04 05:18:37 lukem Exp $	*/
+
 #include 
 #include 
 #include 

Index: src/libexec/ftpd/pfilter.h
diff -u src/libexec/ftpd/pfilter.h:1.1 src/libexec/ftpd/pfilter.h:1.2
--- src/libexec/ftpd/pfilter.h:1.1	Sun Jan 25 15:53:49 2015
+++ src/libexec/ftpd/pfilter.h	Sat Jul  4 05:18:37 2020
@@ -1,2 +1,4 @@
+/*	$NetBSD: pfilter.h,v 1.2 2020/07/04 05:18:37 lukem Exp $	*/
+
 void pfilter_open(void);
 void pfilter_notify(int, const char *);



CVS commit: src/libexec/ftpd

2020-07-03 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jul  4 01:20:42 UTC 2020

Modified Files:
src/libexec/ftpd: version.h

Log Message:
NetBSD-ftpd 20200615

Update version to "NetBSD-ftpd 20200615" for changes:
- Increase some buffer sizes.
- Rename blacklist to blocklist.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/libexec/ftpd/version.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/version.h
diff -u src/libexec/ftpd/version.h:1.76 src/libexec/ftpd/version.h:1.77
--- src/libexec/ftpd/version.h:1.76	Tue Jan 29 11:51:05 2019
+++ src/libexec/ftpd/version.h	Sat Jul  4 01:20:42 2020
@@ -1,6 +1,6 @@
-/*	$NetBSD: version.h,v 1.76 2019/01/29 11:51:05 lukem Exp $	*/
+/*	$NetBSD: version.h,v 1.77 2020/07/04 01:20:42 lukem Exp $	*/
 /*-
- * Copyright (c) 1999-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -29,5 +29,5 @@
  */
 
 #ifndef FTPD_VERSION
-#define	FTPD_VERSION	"NetBSD-ftpd 20180428"
+#define	FTPD_VERSION	"NetBSD-ftpd 20200615"
 #endif



CVS commit: src/libexec/ftpd

2019-01-29 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue Jan 29 23:19:31 UTC 2019

Modified Files:
src/libexec/ftpd: pfilter.c

Log Message:
clarify the fd used for blacklisting.

Use STDIN_FILENO instead of 0 as the fd to blacklist_r(),
since we use the former in ftpd.c


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/libexec/ftpd/pfilter.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/pfilter.c
diff -u src/libexec/ftpd/pfilter.c:1.1 src/libexec/ftpd/pfilter.c:1.2
--- src/libexec/ftpd/pfilter.c:1.1	Sun Jan 25 15:53:49 2015
+++ src/libexec/ftpd/pfilter.c	Tue Jan 29 23:19:30 2019
@@ -1,4 +1,5 @@
 #include 
+#include 
 #include 
 
 #include "pfilter.h"
@@ -20,5 +21,5 @@ pfilter_notify(int what, const char *msg
 	if (blstate == NULL)
 		return;
 
-	blacklist_r(blstate, what, 0, msg);
+	blacklist_r(blstate, what, STDIN_FILENO, msg);
 }



CVS commit: src/libexec/ftpd

2019-01-29 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue Jan 29 11:51:05 UTC 2019

Modified Files:
src/libexec/ftpd: version.h

Log Message:
NetBSD-ftpd 20180428

Update version to "NetBSD-ftpd 20180428" for changes:
- Fix violations of the sequence point rule.
- Check that stat and fstat succeed.
- Support blacklistd(8) hooks.
- Clear utmpx struct before writing it to wtmpx files.
- Fix directory stream leaks.
- Use explicit_memset(3) instead of memset(3) to clear password.
- Fix scope of variable. PR misc/50665.
- Ensure that closing socket exists. CID 603440.
- Add -f option to ftpd to stay in foreground with -D. PR bin/53221.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/libexec/ftpd/version.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/version.h
diff -u src/libexec/ftpd/version.h:1.75 src/libexec/ftpd/version.h:1.76
--- src/libexec/ftpd/version.h:1.75	Thu Mar 21 00:17:26 2013
+++ src/libexec/ftpd/version.h	Tue Jan 29 11:51:05 2019
@@ -1,6 +1,6 @@
-/*	$NetBSD: version.h,v 1.75 2013/03/21 00:17:26 lukem Exp $	*/
+/*	$NetBSD: version.h,v 1.76 2019/01/29 11:51:05 lukem Exp $	*/
 /*-
- * Copyright (c) 1999-2013 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -29,5 +29,5 @@
  */
 
 #ifndef FTPD_VERSION
-#define	FTPD_VERSION	"NetBSD-ftpd 20110904"
+#define	FTPD_VERSION	"NetBSD-ftpd 20180428"
 #endif



CVS commit: src/libexec/ftpd

2018-06-23 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jun 23 07:21:00 UTC 2018

Modified Files:
src/libexec/ftpd: extern.h

Log Message:
No semicolon after macro do ... while (0) wrapper.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/libexec/ftpd/extern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/extern.h
diff -u src/libexec/ftpd/extern.h:1.63 src/libexec/ftpd/extern.h:1.64
--- src/libexec/ftpd/extern.h:1.63	Thu Mar 21 05:53:01 2013
+++ src/libexec/ftpd/extern.h	Sat Jun 23 07:21:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.63 2013/03/21 05:53:01 lukem Exp $	*/
+/*	$NetBSD: extern.h,v 1.64 2018/06/23 07:21:00 gson Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -358,7 +358,7 @@ extern	struct tab	cmdtab[];
 
 #define	CPUTC(c, f)	do { \
 putc(c, f); total_bytes++; total_bytes_out++; \
-			} while (0);
+			} while (0)
 
 #define CURCLASSTYPE	curclass.type == CLASS_GUEST  ? "GUEST"  : \
 			curclass.type == CLASS_CHROOT ? "CHROOT" : \



CVS commit: src/libexec/ftpd

2018-04-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr 28 13:38:00 UTC 2018

Modified Files:
src/libexec/ftpd: ftpd.8 ftpd.c

Log Message:
Add -f option to ftpd to stay in foreground with -D.

>From nia in PR bin/53221.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/libexec/ftpd/ftpd.8
cvs rdiff -u -r1.203 -r1.204 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.8
diff -u src/libexec/ftpd/ftpd.8:1.86 src/libexec/ftpd/ftpd.8:1.87
--- src/libexec/ftpd/ftpd.8:1.86	Mon Jul  3 21:35:48 2017
+++ src/libexec/ftpd/ftpd.8	Sat Apr 28 13:38:00 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ftpd.8,v 1.86 2017/07/03 21:35:48 wiz Exp $
+.\"	$NetBSD: ftpd.8,v 1.87 2018/04/28 13:38:00 riastradh Exp $
 .\"
 .\" Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -65,7 +65,7 @@
 Internet File Transfer Protocol server
 .Sh SYNOPSIS
 .Nm
-.Op Fl 46DdHlnQqrsUuWwX
+.Op Fl 46DdfHlnQqrsUuWwX
 .Op Fl a Ar anondir
 .Op Fl C Ar user Ns Op @ Ns Ar host
 .Op Fl c Ar confdir
@@ -154,6 +154,10 @@ for the
 .Dq "\&%E"
 escape sequence (see
 .Sx Display file escape sequences )
+.It Fl f
+Stops the
+.Fl D
+flag from detaching from the tty and going into the background.
 .It Fl H
 Equivalent to
 .Do

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.203 src/libexec/ftpd/ftpd.c:1.204
--- src/libexec/ftpd/ftpd.c:1.203	Tue Jul 19 21:25:38 2016
+++ src/libexec/ftpd/ftpd.c	Sat Apr 28 13:38:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.203 2016/07/19 21:25:38 shm Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.204 2018/04/28 13:38:00 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = "@(#)ftpd.c	8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ftpd.c,v 1.203 2016/07/19 21:25:38 shm Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.204 2018/04/28 13:38:00 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -177,6 +177,7 @@ static sig_atomic_t	urgflag;
 
 int	data;
 int	Dflag;
+int	fflag;
 int	sflag;
 int	stru;			/* avoid C keyword */
 int	mode;
@@ -298,6 +299,7 @@ main(int argc, char *argv[])
 	logging = 0;
 	pdata = -1;
 	Dflag = 0;
+	fflag = 0;
 	sflag = 0;
 	dataport = 0;
 	dopidfile = 1;		/* default: DO use a pid file to count users */
@@ -323,7 +325,7 @@ main(int argc, char *argv[])
 	openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP);
 
 	while ((ch = getopt(argc, argv,
-	"46a:c:C:Dde:h:HlL:nP:qQrst:T:uUvV:wWX")) != -1) {
+	"46a:c:C:Dde:fh:HlL:nP:qQrst:T:uUvV:wWX")) != -1) {
 		switch (ch) {
 		case '4':
 			af = AF_INET;
@@ -377,6 +379,10 @@ main(int argc, char *argv[])
 			emailaddr = optarg;
 			break;
 
+		case 'f':
+			fflag = 1;
+			break;
+
 		case 'h':
 			strlcpy(hostname, optarg, sizeof(hostname));
 			break;
@@ -505,7 +511,7 @@ main(int argc, char *argv[])
 		struct pollfd *fds;
 		struct addrinfo hints, *res, *res0;
 
-		if (daemon(1, 0) == -1) {
+		if (!fflag && daemon(1, 0) == -1) {
 			syslog(LOG_ERR, "failed to daemonize: %m");
 			exit(1);
 		}



CVS commit: src/libexec/ftpd

2016-07-19 Thread Mateusz Kocielski
Module Name:src
Committed By:   shm
Date:   Tue Jul 19 21:25:38 UTC 2016

Modified Files:
src/libexec/ftpd: ftpd.c

Log Message:
CID 603440: ensure that closing socket exists


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.202 src/libexec/ftpd/ftpd.c:1.203
--- src/libexec/ftpd/ftpd.c:1.202	Mon Aug 10 07:32:49 2015
+++ src/libexec/ftpd/ftpd.c	Tue Jul 19 21:25:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.202 2015/08/10 07:32:49 shm Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.203 2016/07/19 21:25:38 shm Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = "@(#)ftpd.c	8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ftpd.c,v 1.202 2015/08/10 07:32:49 shm Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.203 2016/07/19 21:25:38 shm Exp $");
 #endif
 #endif /* not lint */
 
@@ -1967,7 +1967,8 @@ getdatasock(const char *fmode)
 	t = errno;
 	if (! dropprivs)
 		(void) seteuid((uid_t)pw->pw_uid);
-	(void) close(s);
+	if (s >= 0)
+		(void) close(s);
 	errno = t;
 	return (NULL);
 }



CVS commit: src/libexec/ftpd

2016-03-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 17 00:17:58 UTC 2016

Modified Files:
src/libexec/ftpd: popen.c

Log Message:
volatile for gcc 5


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/libexec/ftpd/popen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/popen.c
diff -u src/libexec/ftpd/popen.c:1.37 src/libexec/ftpd/popen.c:1.38
--- src/libexec/ftpd/popen.c:1.37	Sat Mar 20 14:23:30 2010
+++ src/libexec/ftpd/popen.c	Wed Mar 16 20:17:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: popen.c,v 1.37 2010/03/20 18:23:30 christos Exp $	*/
+/*	$NetBSD: popen.c,v 1.38 2016/03/17 00:17:58 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)popen.c	8.3 (Berkeley) 4/6/94";
 #else
-__RCSID("$NetBSD: popen.c,v 1.37 2010/03/20 18:23:30 christos Exp $");
+__RCSID("$NetBSD: popen.c,v 1.38 2016/03/17 00:17:58 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -107,7 +107,7 @@ extern int ls_main(int, char *[]);
 FILE *
 ftpd_popen(const char *argv[], const char *ptype, int stderrfd)
 {
-	FILE *iop;
+	FILE * volatile iop;
 	int argc, pdes[2], pid;
 	volatile int isls;
 	char **pop;



CVS commit: src/libexec/ftpd

2016-01-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 17 14:46:07 UTC 2016

Modified Files:
src/libexec/ftpd: cmds.c

Log Message:
PR/50665: David Binderman: move "dir" to the outer scope so it stays alive
when the pointer is used later.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/libexec/ftpd/cmds.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/cmds.c
diff -u src/libexec/ftpd/cmds.c:1.34 src/libexec/ftpd/cmds.c:1.35
--- src/libexec/ftpd/cmds.c:1.34	Mon Aug 10 03:32:49 2015
+++ src/libexec/ftpd/cmds.c	Sun Jan 17 09:46:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmds.c,v 1.34 2015/08/10 07:32:49 shm Exp $	*/
+/*	$NetBSD: cmds.c,v 1.35 2016/01/17 14:46:07 christos Exp $	*/
 
 /*
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: cmds.c,v 1.34 2015/08/10 07:32:49 shm Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.35 2016/01/17 14:46:07 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -600,7 +600,7 @@ static void
 fact_perm(const char *fact, FILE *fd, factelem *fe)
 {
 	int		rok, wok, xok, pdirwok;
-	struct stat	*pdir;
+	struct stat	*pdir, dir;
 
 	if (fe->stat->st_uid == geteuid()) {
 		rok = ((fe->stat->st_mode & S_IRUSR) != 0);
@@ -627,7 +627,6 @@ fact_perm(const char *fact, FILE *fd, fa
 	if (pdir == NULL && CURCLASS_FLAGS_ISSET(modify)) {
 		size_t		len;
 		char		realdir[MAXPATHLEN], *p;
-		struct stat	dir;
 
 		len = strlcpy(realdir, fe->path, sizeof(realdir));
 		if (len < sizeof(realdir) - 4) {



CVS commit: src/libexec/ftpd

2015-08-10 Thread Mateusz Kocielski
Module Name:src
Committed By:   shm
Date:   Mon Aug 10 07:45:50 UTC 2015

Modified Files:
src/libexec/ftpd: ftpcmd.y

Log Message:
Use explicit_memset(3) instead of memset(3) to clear password


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/libexec/ftpd/ftpcmd.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpcmd.y
diff -u src/libexec/ftpd/ftpcmd.y:1.93 src/libexec/ftpd/ftpcmd.y:1.94
--- src/libexec/ftpd/ftpcmd.y:1.93	Fri Sep 16 16:13:17 2011
+++ src/libexec/ftpd/ftpcmd.y	Mon Aug 10 07:45:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpcmd.y,v 1.93 2011/09/16 16:13:17 plunky Exp $	*/
+/*	$NetBSD: ftpcmd.y,v 1.94 2015/08/10 07:45:50 shm Exp $	*/
 
 /*-
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = @(#)ftpcmd.y	8.3 (Berkeley) 4/6/94;
 #else
-__RCSID($NetBSD: ftpcmd.y,v 1.93 2011/09/16 16:13:17 plunky Exp $);
+__RCSID($NetBSD: ftpcmd.y,v 1.94 2015/08/10 07:45:50 shm Exp $);
 #endif
 #endif /* not lint */
 
@@ -193,7 +193,7 @@ cmd
 	| PASS SP password CRLF
 		{
 			pass($3);
-			memset($3, 0, strlen($3));
+			explicit_memset($3, 0, strlen($3));
 			free($3);
 		}
 



CVS commit: src/libexec/ftpd

2015-08-10 Thread Mateusz Kocielski
Module Name:src
Committed By:   shm
Date:   Mon Aug 10 07:32:49 UTC 2015

Modified Files:
src/libexec/ftpd: cmds.c ftpd.c

Log Message:
Fix directory stream leaks


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/libexec/ftpd/cmds.c
cvs rdiff -u -r1.201 -r1.202 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/cmds.c
diff -u src/libexec/ftpd/cmds.c:1.33 src/libexec/ftpd/cmds.c:1.34
--- src/libexec/ftpd/cmds.c:1.33	Wed Jul  3 14:15:47 2013
+++ src/libexec/ftpd/cmds.c	Mon Aug 10 07:32:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $	*/
+/*	$NetBSD: cmds.c,v 1.34 2015/08/10 07:32:49 shm Exp $	*/
 
 /*
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $);
+__RCSID($NetBSD: cmds.c,v 1.34 2015/08/10 07:32:49 shm Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -249,8 +249,10 @@ mlsd(const char *path)
 		goto mlsdperror;
 
 	dout = dataconn(MLSD, (off_t)-1, w);
-	if (dout == NULL)
+	if (dout == NULL) {
+		(void) closedir(dirp);
 		return;
+	}
 
 	memset(f, 0, sizeof(f));
 	f.stat = sb;

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.201 src/libexec/ftpd/ftpd.c:1.202
--- src/libexec/ftpd/ftpd.c:1.201	Sun Jan 25 15:53:49 2015
+++ src/libexec/ftpd/ftpd.c	Mon Aug 10 07:32:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.201 2015/01/25 15:53:49 christos Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.202 2015/08/10 07:32:49 shm Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT(@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = @(#)ftpd.c	8.5 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: ftpd.c,v 1.201 2015/01/25 15:53:49 christos Exp $);
+__RCSID($NetBSD: ftpd.c,v 1.202 2015/08/10 07:32:49 shm Exp $);
 #endif
 #endif /* not lint */
 
@@ -3482,8 +3482,10 @@ send_file_list(const char *whichf)
 		while ((dir = readdir(dirp)) != NULL) {
 			char nbuf[MAXPATHLEN];
 
-			if (urgflag  handleoobcmd())
+			if (urgflag  handleoobcmd()) {
+(void) closedir(dirp);
 goto cleanup_send_file_list;
+			}
 
 			if (ISDOTDIR(dir-d_name) || ISDOTDOTDIR(dir-d_name))
 continue;
@@ -3506,8 +3508,10 @@ send_file_list(const char *whichf)
 if (dout == NULL) {
 	dout = dataconn(file list, (off_t)-1,
 		w);
-	if (dout == NULL)
+	if (dout == NULL) {
+		(void) closedir(dirp);
 		goto cleanup_send_file_list;
+	}
 	transflag = 1;
 }
 p = nbuf;



CVS commit: src/libexec/ftpd

2015-08-09 Thread Mateusz Kocielski
Module Name:src
Committed By:   shm
Date:   Sun Aug  9 12:17:30 UTC 2015

Modified Files:
src/libexec/ftpd: logwtmp.c

Log Message:
Clear utmpx struct before writing it to wtmpx files


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/libexec/ftpd/logwtmp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/logwtmp.c
diff -u src/libexec/ftpd/logwtmp.c:1.25 src/libexec/ftpd/logwtmp.c:1.26
--- src/libexec/ftpd/logwtmp.c:1.25	Sat Sep 23 16:03:50 2006
+++ src/libexec/ftpd/logwtmp.c	Sun Aug  9 12:17:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: logwtmp.c,v 1.25 2006/09/23 16:03:50 xtraeme Exp $	*/
+/*	$NetBSD: logwtmp.c,v 1.26 2015/08/09 12:17:30 shm Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -36,7 +36,7 @@
 #if 0
 static char sccsid[] = @(#)logwtmp.c	8.1 (Berkeley) 6/4/93;
 #else
-__RCSID($NetBSD: logwtmp.c,v 1.25 2006/09/23 16:03:50 xtraeme Exp $);
+__RCSID($NetBSD: logwtmp.c,v 1.26 2015/08/09 12:17:30 shm Exp $);
 #endif
 #endif /* not lint */
 
@@ -124,6 +124,7 @@ ftpd_logwtmpx(const char *line, const ch
 	if (fdx  0) 
 		return;
 	if (fstat(fdx, buf) == 0) {
+		(void)memset(ut, 0, sizeof(ut));
 		(void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
 		(void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
 		(void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));



CVS commit: src/libexec/ftpd

2015-08-09 Thread Mateusz Kocielski
Module Name:src
Committed By:   shm
Date:   Sun Aug  9 20:34:24 UTC 2015

Modified Files:
src/libexec/ftpd: logwtmp.c

Log Message:
Removed unnecessary memset(3) call


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/libexec/ftpd/logwtmp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/logwtmp.c
diff -u src/libexec/ftpd/logwtmp.c:1.26 src/libexec/ftpd/logwtmp.c:1.27
--- src/libexec/ftpd/logwtmp.c:1.26	Sun Aug  9 12:17:30 2015
+++ src/libexec/ftpd/logwtmp.c	Sun Aug  9 20:34:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: logwtmp.c,v 1.26 2015/08/09 12:17:30 shm Exp $	*/
+/*	$NetBSD: logwtmp.c,v 1.27 2015/08/09 20:34:24 shm Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -36,7 +36,7 @@
 #if 0
 static char sccsid[] = @(#)logwtmp.c	8.1 (Berkeley) 6/4/93;
 #else
-__RCSID($NetBSD: logwtmp.c,v 1.26 2015/08/09 12:17:30 shm Exp $);
+__RCSID($NetBSD: logwtmp.c,v 1.27 2015/08/09 20:34:24 shm Exp $);
 #endif
 #endif /* not lint */
 
@@ -130,8 +130,6 @@ ftpd_logwtmpx(const char *line, const ch
 		(void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
 		if (haddr)
 			(void)memcpy(ut.ut_ss, haddr-si_su, haddr-su_len);
-		else
-			(void)memset(ut.ut_ss, 0, sizeof(ut.ut_ss));
 		ut.ut_type = utx_type;
 		if (WIFEXITED(status))
 			ut.ut_exit.e_exit = (uint16_t)WEXITSTATUS(status);



CVS commit: src/libexec/ftpd

2015-01-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 25 15:53:49 UTC 2015

Modified Files:
src/libexec/ftpd: Makefile ftpd.c
Added Files:
src/libexec/ftpd: pfilter.c pfilter.h

Log Message:
blacklist hooks


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/libexec/ftpd/Makefile
cvs rdiff -u -r1.200 -r1.201 src/libexec/ftpd/ftpd.c
cvs rdiff -u -r0 -r1.1 src/libexec/ftpd/pfilter.c src/libexec/ftpd/pfilter.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/Makefile
diff -u src/libexec/ftpd/Makefile:1.63 src/libexec/ftpd/Makefile:1.64
--- src/libexec/ftpd/Makefile:1.63	Sun Aug 14 07:46:28 2011
+++ src/libexec/ftpd/Makefile	Sun Jan 25 10:53:49 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.63 2011/08/14 11:46:28 christos Exp $
+#	$NetBSD: Makefile,v 1.64 2015/01/25 15:53:49 christos Exp $
 #	@(#)Makefile	8.2 (Berkeley) 4/4/94
 
 .include bsd.own.mk
@@ -11,6 +11,10 @@ LDADD+=	-lcrypt -lutil
 MAN=	ftpd.conf.5 ftpusers.5 ftpd.8
 MLINKS=	ftpusers.5 ftpchroot.5
 
+SRCS+=	pfilter.c
+LDADD+=	-lblacklist
+DPADD+=	${LIBBLACKLIST}
+
 .if defined(NO_INTERNAL_LS)
 CPPFLAGS+=-DNO_INTERNAL_LS
 .else

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.200 src/libexec/ftpd/ftpd.c:1.201
--- src/libexec/ftpd/ftpd.c:1.200	Wed Jul 31 15:50:47 2013
+++ src/libexec/ftpd/ftpd.c	Sun Jan 25 10:53:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.200 2013/07/31 19:50:47 christos Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.201 2015/01/25 15:53:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT(@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = @(#)ftpd.c	8.5 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: ftpd.c,v 1.200 2013/07/31 19:50:47 christos Exp $);
+__RCSID($NetBSD: ftpd.c,v 1.201 2015/01/25 15:53:49 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -165,6 +165,8 @@ __RCSID($NetBSD: ftpd.c,v 1.200 2013/07
 #include security/pam_appl.h
 #endif
 
+#include pfilter.h
+
 #define	GLOBAL
 #include extern.h
 #include pathnames.h
@@ -471,6 +473,8 @@ main(int argc, char *argv[])
 	if (EMPTYSTR(confdir))
 		confdir = _DEFAULT_CONFDIR;
 
+	pfilter_open();
+
 	if (dowtmp) {
 #ifdef SUPPORT_UTMPX
 		ftpd_initwtmpx();
@@ -1401,6 +1405,7 @@ do_pass(int pass_checked, int pass_rval,
 		if (rval) {
 			reply(530, %s, rval == 2 ? Password expired. :
 			Login incorrect.);
+			pfilter_notify(1, rval == 2 ? exppass : badpass);
 			if (logging) {
 syslog(LOG_NOTICE,
 FTP LOGIN FAILED FROM %s, remoteloghost);
@@ -1444,6 +1449,7 @@ do_pass(int pass_checked, int pass_rval,
 *remote_ip = 0;
 		remote_ip[sizeof(remote_ip) - 1] = 0;
 		if (!auth_hostok(lc, remotehost, remote_ip)) {
+			pfilter_notify(1, bannedhost);
 			syslog(LOG_INFO|LOG_AUTH,
 			FTP LOGIN FAILED (HOST) as %s: permission denied.,
 			pw-pw_name);

Added files:

Index: src/libexec/ftpd/pfilter.c
diff -u /dev/null src/libexec/ftpd/pfilter.c:1.1
--- /dev/null	Sun Jan 25 10:53:49 2015
+++ src/libexec/ftpd/pfilter.c	Sun Jan 25 10:53:49 2015
@@ -0,0 +1,24 @@
+#include stdio.h
+#include blacklist.h
+
+#include pfilter.h
+
+static struct blacklist *blstate;
+
+void
+pfilter_open(void)
+{
+	if (blstate == NULL)
+		blstate = blacklist_open();
+}
+
+void
+pfilter_notify(int what, const char *msg)
+{
+	pfilter_open();
+
+	if (blstate == NULL)
+		return;
+
+	blacklist_r(blstate, what, 0, msg);
+}
Index: src/libexec/ftpd/pfilter.h
diff -u /dev/null src/libexec/ftpd/pfilter.h:1.1
--- /dev/null	Sun Jan 25 10:53:49 2015
+++ src/libexec/ftpd/pfilter.h	Sun Jan 25 10:53:49 2015
@@ -0,0 +1,2 @@
+void pfilter_open(void);
+void pfilter_notify(int, const char *);



CVS commit: src/libexec/ftpd

2013-07-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jul 31 19:50:47 UTC 2013

Modified Files:
src/libexec/ftpd: ftpd.c

Log Message:
fstat returns -1 on error (Maxime Villard)
also while (1) - for (;;)


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.199 src/libexec/ftpd/ftpd.c:1.200
--- src/libexec/ftpd/ftpd.c:1.199	Wed Jul  3 10:16:01 2013
+++ src/libexec/ftpd/ftpd.c	Wed Jul 31 15:50:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.199 2013/07/03 14:16:01 christos Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.200 2013/07/31 19:50:47 christos Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT(@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = @(#)ftpd.c	8.5 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: ftpd.c,v 1.199 2013/07/03 14:16:01 christos Exp $);
+__RCSID($NetBSD: ftpd.c,v 1.200 2013/07/31 19:50:47 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2149,7 +2149,7 @@ send_data_with_read(int filefd, int netf
 		(void)gettimeofday(then, NULL);
 	} else
 		bufrem = readsize;
-	while (1) {
+	for (;;) {
 		(void) alarm(curclass.timeout);
 		c = read(filefd, buf, readsize);
 		if (c == 0)
@@ -2392,7 +2392,7 @@ receive_data(FILE *instr, FILE *outstr)
 		(void) alarm(curclass.timeout);
 		if (curclass.readsize)
 			readsize = curclass.readsize;
-		else if (fstat(filefd, st))
+		else if (fstat(filefd, st) != -1)
 			readsize = (ssize_t)st.st_blksize;
 		else
 			readsize = BUFSIZ;



CVS commit: src/libexec/ftpd

2013-07-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jul  3 14:15:47 UTC 2013

Modified Files:
src/libexec/ftpd: cmds.c

Log Message:
check that stat succeeded before testing the guts of struct stat
(Manime Villard)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/libexec/ftpd/cmds.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/cmds.c
diff -u src/libexec/ftpd/cmds.c:1.32 src/libexec/ftpd/cmds.c:1.33
--- src/libexec/ftpd/cmds.c:1.32	Fri Jun 28 11:04:35 2013
+++ src/libexec/ftpd/cmds.c	Wed Jul  3 10:15:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmds.c,v 1.32 2013/06/28 15:04:35 joerg Exp $	*/
+/*	$NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $	*/
 
 /*
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: cmds.c,v 1.32 2013/06/28 15:04:35 joerg Exp $);
+__RCSID($NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -951,8 +951,8 @@ discover_path(char *last_path, const cha
 		tp[strlen(tp) - 1] = '\0';
 
 	/* check that the path is correct */
-	stat(tp, st1);
-	stat(., st2);
+	if (stat(tp, st1) == -1 || stat(., st2) == -1)
+		goto bad;
 	if ((st1.st_dev != st2.st_dev) || (st1.st_ino != st2.st_ino))
 		goto bad;
 



CVS commit: src/libexec/ftpd

2013-07-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jul  3 14:16:01 UTC 2013

Modified Files:
src/libexec/ftpd: ftpd.c

Log Message:
remove unneeded initialization.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.198 src/libexec/ftpd/ftpd.c:1.199
--- src/libexec/ftpd/ftpd.c:1.198	Tue Jun 19 02:06:34 2012
+++ src/libexec/ftpd/ftpd.c	Wed Jul  3 10:16:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.198 2012/06/19 06:06:34 dholland Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.199 2013/07/03 14:16:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT(@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = @(#)ftpd.c	8.5 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: ftpd.c,v 1.198 2012/06/19 06:06:34 dholland Exp $);
+__RCSID($NetBSD: ftpd.c,v 1.199 2013/07/03 14:16:01 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2830,7 +2830,6 @@ reply(int n, const char *fmt, ...)
 	size_t	b;
 	va_list	ap;
 
-	b = 0;
 	if (n == 0)
 		b = snprintf(msg, sizeof(msg), );
 	else if (n  0)



CVS commit: src/libexec/ftpd

2013-03-20 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu Mar 21 00:17:26 UTC 2013

Modified Files:
src/libexec/ftpd: version.h

Log Message:
Update version to 20110904 for the user-visible change I made back then:
   Reduce priority of syslog message if getpeername returns ENOTCONN.
   PR bin/18934 by Greg A. Woods (with supplied fix).


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/libexec/ftpd/version.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/version.h
diff -u src/libexec/ftpd/version.h:1.74 src/libexec/ftpd/version.h:1.75
--- src/libexec/ftpd/version.h:1.74	Sun Mar 21 20:27:26 2010
+++ src/libexec/ftpd/version.h	Thu Mar 21 00:17:26 2013
@@ -1,6 +1,6 @@
-/*	$NetBSD: version.h,v 1.74 2010/03/21 20:27:26 lukem Exp $	*/
+/*	$NetBSD: version.h,v 1.75 2013/03/21 00:17:26 lukem Exp $	*/
 /*-
- * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2013 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -29,5 +29,5 @@
  */
 
 #ifndef FTPD_VERSION
-#define	FTPD_VERSION	NetBSD-ftpd 20100320
+#define	FTPD_VERSION	NetBSD-ftpd 20110904
 #endif



CVS commit: src/libexec/ftpd

2013-03-20 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu Mar 21 05:53:01 UTC 2013

Modified Files:
src/libexec/ftpd: extern.h

Log Message:
Convert from __attribute__(foo) to the __foo equiv in sys/cdefs.h


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/libexec/ftpd/extern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/extern.h
diff -u src/libexec/ftpd/extern.h:1.62 src/libexec/ftpd/extern.h:1.63
--- src/libexec/ftpd/extern.h:1.62	Mon Aug 29 20:41:06 2011
+++ src/libexec/ftpd/extern.h	Thu Mar 21 05:53:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.62 2011/08/29 20:41:06 joerg Exp $	*/
+/*	$NetBSD: extern.h,v 1.63 2013/03/21 05:53:01 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -118,7 +118,7 @@ void	closedataconn(FILE *);
 char   *conffilename(const char *);
 void	count_users(void);
 void	cprintf(FILE *, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3)));
+	__printflike(2, 3);
 void	cwd(const char *);
 FILE   *dataconn(const char *, off_t, const char *);
 void	delete(const char *);
@@ -155,7 +155,7 @@ void	removedir(const char *);
 void	renamecmd(const char *, const char *);
 char   *renamefrom(const char *);
 void	reply(int, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3)));
+	__printflike(2, 3);
 void	retrieve(const char *[], const char *);
 void	send_file_list(const char *);
 void	show_chdir_messages(int);
@@ -295,7 +295,7 @@ struct ftpclass {
 	LLT		 sendlowat;	/* SO_SNDLOWAT size */
 };
 
-extern void		ftp_loop(void) __attribute__ ((noreturn));
+__dead extern void		ftp_loop(void);
 extern void		ftp_handle_line(char *);
 
 #ifndef	GLOBAL



CVS commit: src/libexec/ftpd

2012-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  4 20:46:46 UTC 2012

Modified Files:
src/libexec/ftpd: conf.c

Log Message:
include pwd.h for password stuff


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/libexec/ftpd/conf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/conf.c
diff -u src/libexec/ftpd/conf.c:1.63 src/libexec/ftpd/conf.c:1.64
--- src/libexec/ftpd/conf.c:1.63	Sun Aug 14 07:46:28 2011
+++ src/libexec/ftpd/conf.c	Sun Nov  4 15:46:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $	*/
+/*	$NetBSD: conf.c,v 1.64 2012/11/04 20:46:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $);
+__RCSID($NetBSD: conf.c,v 1.64 2012/11/04 20:46:46 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -42,6 +42,7 @@ __RCSID($NetBSD: conf.c,v 1.63 2011/08/
 #include ctype.h
 #include errno.h
 #include fcntl.h
+#include pwd.h
 #include glob.h
 #include netdb.h
 #include signal.h



CVS commit: src/libexec/ftpd

2012-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Jun 19 06:06:34 UTC 2012

Modified Files:
src/libexec/ftpd: cmds.c ftpd.c

Log Message:
Pass WARNS=5


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/libexec/ftpd/cmds.c
cvs rdiff -u -r1.197 -r1.198 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/cmds.c
diff -u src/libexec/ftpd/cmds.c:1.30 src/libexec/ftpd/cmds.c:1.31
--- src/libexec/ftpd/cmds.c:1.30	Sun Mar 15 07:48:36 2009
+++ src/libexec/ftpd/cmds.c	Tue Jun 19 06:06:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmds.c,v 1.30 2009/03/15 07:48:36 lukem Exp $	*/
+/*	$NetBSD: cmds.c,v 1.31 2012/06/19 06:06:34 dholland Exp $	*/
 
 /*
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: cmds.c,v 1.30 2009/03/15 07:48:36 lukem Exp $);
+__RCSID($NetBSD: cmds.c,v 1.31 2012/06/19 06:06:34 dholland Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -845,9 +845,7 @@ replydirname(const char *name, const cha
 }
 
 static void
-discover_path(last_path, new_path) 
-	char *last_path;
-	const char *new_path;
+discover_path(char *last_path, const char *new_path) 
 {
 	char tp[MAXPATHLEN + 1] = ;
 	char tq[MAXPATHLEN + 1] = ;

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.197 src/libexec/ftpd/ftpd.c:1.198
--- src/libexec/ftpd/ftpd.c:1.197	Fri Sep 16 16:13:17 2011
+++ src/libexec/ftpd/ftpd.c	Tue Jun 19 06:06:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.197 2011/09/16 16:13:17 plunky Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.198 2012/06/19 06:06:34 dholland Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ __COPYRIGHT(@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = @(#)ftpd.c	8.5 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: ftpd.c,v 1.197 2011/09/16 16:13:17 plunky Exp $);
+__RCSID($NetBSD: ftpd.c,v 1.198 2012/06/19 06:06:34 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -2938,7 +2938,7 @@ statxfer(void)
  * by setting transflag to 0. (c.f., ABOR).
  */
 static int
-handleoobcmd()
+handleoobcmd(void)
 {
 	char *cp;
 	int ret;



CVS commit: src/libexec/ftpd

2011-09-04 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun Sep  4 23:16:42 UTC 2011

Modified Files:
src/libexec/ftpd: ftpd.c

Log Message:
Reduce priority of syslog message if getpeername returns ENOTCONN.
PR bin/18934 by Greg A. Woods (with supplied fix).


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/libexec/ftpd/ftpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.195 src/libexec/ftpd/ftpd.c:1.196
--- src/libexec/ftpd/ftpd.c:1.195	Mon Aug 29 20:41:06 2011
+++ src/libexec/ftpd/ftpd.c	Sun Sep  4 23:16:41 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpd.c,v 1.195 2011/08/29 20:41:06 joerg Exp $	*/
+/*	$NetBSD: ftpd.c,v 1.196 2011/09/04 23:16:41 lukem Exp $	*/
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #if 0
 static char sccsid[] = @(#)ftpd.c	8.5 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: ftpd.c,v 1.195 2011/08/29 20:41:06 joerg Exp $);
+__RCSID($NetBSD: ftpd.c,v 1.196 2011/09/04 23:16:41 lukem Exp $);
 #endif
 #endif /* not lint */
 
@@ -601,7 +601,8 @@
 	memset((char *)his_addr, 0, sizeof(his_addr));
 	addrlen = sizeof(his_addr.si_su);
 	if (getpeername(0, (struct sockaddr *)his_addr.si_su, addrlen)  0) {
-		syslog(LOG_ERR, getpeername (%s): %m,argv[0]);
+		syslog((errno == ENOTCONN) ? LOG_NOTICE : LOG_ERR,
+		getpeername (%s): %m,argv[0]);
 		exit(1);
 	}
 	his_addr.su_len = addrlen;



CVS commit: src/libexec/ftpd

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 11:46:28 UTC 2011

Modified Files:
src/libexec/ftpd: Makefile conf.c

Log Message:
remove gcc-4.5 hack


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/libexec/ftpd/Makefile src/libexec/ftpd/conf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/Makefile
diff -u src/libexec/ftpd/Makefile:1.62 src/libexec/ftpd/Makefile:1.63
--- src/libexec/ftpd/Makefile:1.62	Tue Jun 21 22:49:43 2011
+++ src/libexec/ftpd/Makefile	Sun Aug 14 07:46:28 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.62 2011/06/22 02:49:43 mrg Exp $
+#	$NetBSD: Makefile,v 1.63 2011/08/14 11:46:28 christos Exp $
 #	@(#)Makefile	8.2 (Berkeley) 4/4/94
 
 .include bsd.own.mk
@@ -52,8 +52,3 @@
 #.endif
 
 .include bsd.prog.mk
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.conf.c+=	-Wno-error
-.endif
Index: src/libexec/ftpd/conf.c
diff -u src/libexec/ftpd/conf.c:1.62 src/libexec/ftpd/conf.c:1.63
--- src/libexec/ftpd/conf.c:1.62	Sun Mar 15 03:48:36 2009
+++ src/libexec/ftpd/conf.c	Sun Aug 14 07:46:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: conf.c,v 1.62 2009/03/15 07:48:36 lukem Exp $	*/
+/*	$NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: conf.c,v 1.62 2009/03/15 07:48:36 lukem Exp $);
+__RCSID($NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -811,7 +811,7 @@
 	int		 o_errno;
 	char		*base = NULL;
 	char		*cmd, *p, *lp;
-	const char	**argv;
+	char	   **argv;
 	StringList	*sl;
 
 	o_errno = errno;
@@ -860,10 +860,10 @@
 
 	if (sl_add(sl, NULL) == -1)
 		goto cleanup_do_conv;
-	argv = (const char **)sl-sl_str;
+	argv = sl-sl_str;
 	free(cmd);
 	free(sl);
-	return(argv);
+	return (void *)(intptr_t)argv;
 
  cleanup_do_conv:
 	if (sl)



CVS commit: src/libexec/ftpd

2011-06-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jul  1 02:46:15 UTC 2011

Modified Files:
src/libexec/ftpd: ftpcmd.y

Log Message:
Fix memcpy usage.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/libexec/ftpd/ftpcmd.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpcmd.y
diff -u src/libexec/ftpd/ftpcmd.y:1.91 src/libexec/ftpd/ftpcmd.y:1.92
--- src/libexec/ftpd/ftpcmd.y:1.91	Fri Jan 14 23:56:13 2011
+++ src/libexec/ftpd/ftpcmd.y	Fri Jul  1 02:46:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpcmd.y,v 1.91 2011/01/14 23:56:13 christos Exp $	*/
+/*	$NetBSD: ftpcmd.y,v 1.92 2011/07/01 02:46:15 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = @(#)ftpcmd.y	8.3 (Berkeley) 4/6/94;
 #else
-__RCSID($NetBSD: ftpcmd.y,v 1.91 2011/01/14 23:56:13 christos Exp $);
+__RCSID($NetBSD: ftpcmd.y,v 1.92 2011/07/01 02:46:15 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -974,7 +974,7 @@
 			data_dest.su_family = AF_INET6;
 			buf[0] = $39.i; buf[1] = $41.i;
 			(void)memcpy(data_dest.su_port, buf,
-			sizeof(data_dest.su_port));
+			sizeof(data_dest.su_port));
 			buf[0] = $5.i; buf[1] = $7.i;
 			buf[2] = $9.i; buf[3] = $11.i;
 			buf[4] = $13.i; buf[5] = $15.i;



CVS commit: src/libexec/ftpd

2011-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 14 23:56:13 UTC 2011

Modified Files:
src/libexec/ftpd: ftpcmd.y

Log Message:
PR/44390: Paul Koning: make code gcc-4.5.1 friendly.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/libexec/ftpd/ftpcmd.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpcmd.y
diff -u src/libexec/ftpd/ftpcmd.y:1.90 src/libexec/ftpd/ftpcmd.y:1.91
--- src/libexec/ftpd/ftpcmd.y:1.90	Mon Jul 13 15:05:40 2009
+++ src/libexec/ftpd/ftpcmd.y	Fri Jan 14 18:56:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftpcmd.y,v 1.90 2009/07/13 19:05:40 roy Exp $	*/
+/*	$NetBSD: ftpcmd.y,v 1.91 2011/01/14 23:56:13 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = @(#)ftpcmd.y	8.3 (Berkeley) 4/6/94;
 #else
-__RCSID($NetBSD: ftpcmd.y,v 1.90 2009/07/13 19:05:40 roy Exp $);
+__RCSID($NetBSD: ftpcmd.y,v 1.91 2011/01/14 23:56:13 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -967,18 +967,24 @@
 		NUMBER
 		{
 #ifdef INET6
-			char *a, *p;
+			unsigned char buf[16];
 
-			memset(data_dest, 0, sizeof(data_dest));
+			(void)memset(data_dest, 0, sizeof(data_dest));
 			data_dest.su_len = sizeof(struct sockaddr_in6);
 			data_dest.su_family = AF_INET6;
-			p = (char *)data_dest.su_port;
-			p[0] = $39.i; p[1] = $41.i;
-			a = (char *)data_dest.si_su.su_sin6.sin6_addr;
-			a[0] = $5.i; a[1] = $7.i; a[2] = $9.i; a[3] = $11.i;
-			a[4] = $13.i; a[5] = $15.i; a[6] = $17.i; a[7] = $19.i;
-			a[8] = $21.i; a[9] = $23.i; a[10] = $25.i; a[11] = $27.i;
-			a[12] = $29.i; a[13] = $31.i; a[14] = $33.i; a[15] = $35.i;
+			buf[0] = $39.i; buf[1] = $41.i;
+			(void)memcpy(data_dest.su_port, buf,
+			sizeof(data_dest.su_port));
+			buf[0] = $5.i; buf[1] = $7.i;
+			buf[2] = $9.i; buf[3] = $11.i;
+			buf[4] = $13.i; buf[5] = $15.i;
+			buf[6] = $17.i; buf[7] = $19.i;
+			buf[8] = $21.i; buf[9] = $23.i;
+			buf[10] = $25.i; buf[11] = $27.i;
+			buf[12] = $29.i; buf[13] = $31.i;
+			buf[14] = $33.i; buf[15] = $35.i;
+			(void)memcpy(data_dest.si_su.su_sin6.sin6_addr,
+			buf, sizeof(data_dest.si_su.su_sin6.sin6_addr));
 			if (his_addr.su_family == AF_INET6) {
 /* XXX: more sanity checks! */
 data_dest.su_scope_id = his_addr.su_scope_id;



CVS commit: src/libexec/ftpd

2010-03-21 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun Mar 21 20:27:26 UTC 2010

Modified Files:
src/libexec/ftpd: version.h

Log Message:
Update version to 20100320 for Christos' commit to popen.c 1.37 for:
 PR/43023: Bruce Cran: FTPD bug remote crash


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/libexec/ftpd/version.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/version.h
diff -u src/libexec/ftpd/version.h:1.73 src/libexec/ftpd/version.h:1.74
--- src/libexec/ftpd/version.h:1.73	Sat Nov  7 03:10:05 2009
+++ src/libexec/ftpd/version.h	Sun Mar 21 20:27:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: version.h,v 1.73 2009/11/07 03:10:05 lukem Exp $	*/
+/*	$NetBSD: version.h,v 1.74 2010/03/21 20:27:26 lukem Exp $	*/
 /*-
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,5 +29,5 @@
  */
 
 #ifndef FTPD_VERSION
-#define	FTPD_VERSION	NetBSD-ftpd 20091107
+#define	FTPD_VERSION	NetBSD-ftpd 20100320
 #endif



CVS commit: src/libexec/ftpd

2009-05-01 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Fri May  1 09:47:26 UTC 2009

Modified Files:
src/libexec/ftpd: ftpd.8

Log Message:
Simplify the example command used to extract a wu-ftpd compatible xferlog.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/libexec/ftpd/ftpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.8
diff -u src/libexec/ftpd/ftpd.8:1.83 src/libexec/ftpd/ftpd.8:1.84
--- src/libexec/ftpd/ftpd.8:1.83	Sun Mar 15 08:07:22 2009
+++ src/libexec/ftpd/ftpd.8	Fri May  1 09:47:26 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: ftpd.8,v 1.83 2009/03/15 08:07:22 joerg Exp $
+.\	$NetBSD: ftpd.8,v 1.84 2009/05/01 09:47:26 lukem Exp $
 .\
 .\ Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)ftpd.8	8.2 (Berkeley) 4/19/94
 .\
-.Dd September 21, 2008
+.Dd May 1, 2009
 .Dt FTPD 8
 .Os
 .Sh NAME
@@ -278,8 +278,7 @@
 .Pa xferlog
 file suitable for input into a third-party log analysis tool with a command
 similar to:
-.Dl grep 'xferlog: ' /var/log/xferlog | \e
-.Dl \ \ \ sed -e 's/^.*xferlog: //' \*[Gt] wuxferlog
+.Dl sed -ne 's/^.*xferlog: //p' /var/log/xferlog \*[Gt] wuxferlog
 .El
 .Pp
 The file



CVS commit: src/libexec/ftpd

2009-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri May  1 10:53:28 UTC 2009

Modified Files:
src/libexec/ftpd: ftpd.8

Log Message:
Drop trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/libexec/ftpd/ftpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ftpd/ftpd.8
diff -u src/libexec/ftpd/ftpd.8:1.84 src/libexec/ftpd/ftpd.8:1.85
--- src/libexec/ftpd/ftpd.8:1.84	Fri May  1 09:47:26 2009
+++ src/libexec/ftpd/ftpd.8	Fri May  1 10:53:27 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: ftpd.8,v 1.84 2009/05/01 09:47:26 lukem Exp $
+.\	$NetBSD: ftpd.8,v 1.85 2009/05/01 10:53:27 wiz Exp $
 .\
 .\ Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -867,5 +867,5 @@
 the current transfer
 .Sy TYPE
 is
-.Sq Li A 
+.Sq Li A
 (ASCII).