Add a new option to ftpd(8), "-h", to disable printing any
host-specific information in FTP server messages (so paranoid admins can sleep at night :-) PR: bin/16705 MFC after: 1 week
This commit is contained in:
parent
ce9287fc02
commit
c152df28e5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110037
@ -75,6 +75,7 @@ static const char rcsid[] =
|
||||
#include "pathnames.h"
|
||||
|
||||
extern union sockunion data_dest, his_addr;
|
||||
extern int hostinfo;
|
||||
extern int logged_in;
|
||||
extern struct passwd *pw;
|
||||
extern int guest;
|
||||
@ -1554,7 +1555,10 @@ help(struct tab *ctab, char *s)
|
||||
printf("\r\n");
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
reply(214, "Direct comments to ftp-bugs@%s.", hostname);
|
||||
if (hostinfo)
|
||||
reply(214, "Direct comments to ftp-bugs@%s.", hostname);
|
||||
else
|
||||
reply(214, "End.");
|
||||
return;
|
||||
}
|
||||
upper(s);
|
||||
|
@ -40,7 +40,7 @@
|
||||
.Nd Internet File Transfer Protocol server
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl 46ADdEMmOoRrSUvW
|
||||
.Op Fl 46ADdEhMmOoRrSUvW
|
||||
.Op Fl l Op Fl l
|
||||
.Op Fl a Ar address
|
||||
.Op Fl P Ar port
|
||||
@ -108,6 +108,9 @@ Debugging information is written to the syslog using
|
||||
.It Fl E
|
||||
Disable the EPSV command.
|
||||
This is useful for servers behind older firewalls.
|
||||
.It Fl h
|
||||
Disable printing host-specific information, such as the
|
||||
server software version or hostname, in server messages.
|
||||
.It Fl l
|
||||
Each successful and failed
|
||||
.Xr ftp 1
|
||||
|
@ -116,6 +116,7 @@ union sockunion pasv_addr;
|
||||
int daemon_mode;
|
||||
int data;
|
||||
int dataport;
|
||||
int hostinfo = 1; /* print host-specific info in messages */
|
||||
int logged_in;
|
||||
struct passwd *pw;
|
||||
char *homedir;
|
||||
@ -299,7 +300,8 @@ main(int argc, char *argv[], char **envp)
|
||||
#endif /* OLD_SETPROCTITLE */
|
||||
|
||||
|
||||
while ((ch = getopt(argc, argv, "46a:AdDElmMoOp:P:rRSt:T:u:UvW")) != -1) {
|
||||
while ((ch = getopt(argc, argv,
|
||||
"46a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) {
|
||||
switch (ch) {
|
||||
case '4':
|
||||
enable_v4 = 1;
|
||||
@ -331,6 +333,10 @@ main(int argc, char *argv[], char **envp)
|
||||
noepsv = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
hostinfo = 0;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
logging++; /* > 1 == extra logging */
|
||||
break;
|
||||
@ -638,7 +644,10 @@ main(int argc, char *argv[], char **envp)
|
||||
(void) gethostname(hostname, MAXHOSTNAMELEN - 1);
|
||||
hostname[MAXHOSTNAMELEN - 1] = '\0';
|
||||
#endif
|
||||
reply(220, "%s FTP server (%s) ready.", hostname, version);
|
||||
if (hostinfo)
|
||||
reply(220, "%s FTP server (%s) ready.", hostname, version);
|
||||
else
|
||||
reply(220, "FTP server ready.");
|
||||
for (;;)
|
||||
(void) yyparse();
|
||||
/* NOTREACHED */
|
||||
@ -2228,8 +2237,11 @@ statcmd(void)
|
||||
char hname[NI_MAXHOST];
|
||||
int ispassive;
|
||||
|
||||
lreply(211, "%s FTP server status:", hostname);
|
||||
printf(" %s\r\n", version);
|
||||
if (hostinfo) {
|
||||
lreply(211, "%s FTP server status:", hostname);
|
||||
printf(" %s\r\n", version);
|
||||
} else
|
||||
lreply(211, "FTP server status:");
|
||||
printf(" Connected to %s", remotehost);
|
||||
if (!getnameinfo((struct sockaddr *)&his_addr, his_addr.su_len,
|
||||
hname, sizeof(hname) - 1, NULL, 0, NI_NUMERICHOST)) {
|
||||
|
Loading…
Reference in New Issue
Block a user