aboutsummaryrefslogtreecommitdiff
path: root/libexec/ftpd
diff options
context:
space:
mode:
authorjoyu liaonull <joyul@juniper.netnull>2025-06-26 12:07:31 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2025-06-26 12:10:14 +0000
commit0804e60df19b393c37238596c9f37a0b8972a7da (patch)
treec98e422fd1026fddbb681451521c5dd7a0e530f6 /libexec/ftpd
parent19a7ea3cc4de5af80e2913fda70bd65ad72835c0 (diff)
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.812
-rw-r--r--libexec/ftpd/ftpd.c15
2 files changed, 23 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index 3474c379fbc7..96db4753209e 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 9, 2023
+.Dd June 26, 2025
.Dt FTPD 8
.Os
.Sh NAME
@@ -33,7 +33,8 @@
.Nd Internet File Transfer Protocol server
.Sh SYNOPSIS
.Nm
-.Op Fl 468ABDdEhMmOoRrSUvW
+.Op Fl 468BDdEhMmOoRrSUvW
+.Bq Fl A | Fl n
.Op Fl l Op Fl l
.Op Fl a Ar address
.Op Fl P Ar port
@@ -147,6 +148,13 @@ Permit anonymous users to overwrite or modify
existing files if allowed by file system permissions.
By default, anonymous users cannot modify existing files;
in particular, files to upload will be created under a unique name.
+.It Fl n
+Disable anonymous FTP access.
+The
+.Fl n
+option is mutually exclusive with the
+.Fl A
+option.
.It Fl O
Put server in write-only mode for anonymous users only.
RETR is disabled for anonymous users, preventing anonymous downloads.
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index f3a1105f6437..751d77b218b7 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -106,6 +106,7 @@ int logging;
int restricted_data_ports = 1;
int paranoid = 1; /* be extra careful about security */
int anon_only = 0; /* Only anonymous ftp allowed */
+int noanon = 0; /* disable anonymous ftp */
int assumeutf8 = 0; /* Assume that server file names are in UTF-8 */
int guest;
int dochroot;
@@ -269,7 +270,7 @@ main(int argc, char *argv[], char **envp)
openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP);
while ((ch = getopt(argc, argv,
- "468a:ABdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) {
+ "468a:ABdDEhlmMnoOp:P:rRSt:T:u:UvW")) != -1) {
switch (ch) {
case '4':
family = (family == AF_INET6) ? AF_UNSPEC : AF_INET;
@@ -327,6 +328,10 @@ main(int argc, char *argv[], char **envp)
noguestmkd = 1;
break;
+ case 'n':
+ noanon = 1;
+ break;
+
case 'o':
noretr = 1;
break;
@@ -396,6 +401,11 @@ main(int argc, char *argv[], char **envp)
}
}
+ if (noanon && anon_only) {
+ syslog(LOG_ERR, "-n and -A are mutually exclusive");
+ exit(1);
+ }
+
/* handle filesize limit gracefully */
sa.sa_handler = SIG_IGN;
(void)sigaction(SIGXFSZ, &sa, NULL);
@@ -995,7 +1005,8 @@ user(char *name)
#else
pw = sgetpwnam("ftp");
#endif
- if (strcmp(name, "ftp") == 0 || strcmp(name, "anonymous") == 0) {
+ if (!noanon &&
+ (strcmp(name, "ftp") == 0 || strcmp(name, "anonymous") == 0)) {
if (checkuser(_PATH_FTPUSERS, "ftp", 0, NULL, &ecode) ||
(ecode != 0 && ecode != ENOENT))
reply(530, "User %s access denied.", name);