--- ftpd.c.orig Tue Apr 10 16:06:31 2001 +++ ftpd.c Tue Apr 10 16:32:12 2001 @@ -169,6 +169,7 @@ int data; jmp_buf urgcatch; +int Bflag; int sflag; int stru; /* avoid C keyword */ int mode; @@ -246,6 +247,7 @@ debug = 0; logging = 0; pdata = -1; + Bflag = 0; sflag = 0; dataport = 0; dopidfile = 1; /* default: DO use a pid file to count users */ @@ -267,13 +269,17 @@ */ openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); - while ((ch = getopt(argc, argv, "a:c:C:de:h:HlP:qQrst:T:uUvV:wWX")) + while ((ch = getopt(argc, argv, "a:Bc:C:de:h:HlP:qQrst:T:uUvV:wWX")) != -1) { switch (ch) { case 'a': anondir = optarg; break; + case 'B': + Bflag = 1; + break; + case 'c': confdir = optarg; break; @@ -621,6 +627,20 @@ if (!askpasswd && logging) syslog(LOG_NOTICE, "ANONYMOUS FTP LOGIN REFUSED FROM %s", remotehost); + return; + } + +/* + * If ran with -B, check whether user would be granted access + * under the ftpusers(5) restrictions BEFORE asking for password. + */ + if (Bflag && + ! checkaccess (name)) { + reply(530, "User %s may not use FTP.", name); + if (logging) + syslog(LOG_NOTICE, "FTP LOGIN REFUSED FROM %s, %s", + remotehost, name); + end_login(); return; }