aboutsummaryrefslogtreecommitdiff
path: root/libexec/tftpd/tftpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/tftpd/tftpd.c')
-rw-r--r--libexec/tftpd/tftpd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index b25e8b0c762f..9ae7575f3d23 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -100,6 +100,7 @@ static struct dirlist {
static int suppress_naks;
static int logging;
static int ipchroot;
+static int check_woth = 1;
static int create_new = 0;
static const char *newfile_format = "%Y%m%d";
static int increase_name = 0;
@@ -141,7 +142,7 @@ main(int argc, char *argv[])
acting_as_client = 0;
tftp_openlog("tftpd", LOG_PID | LOG_NDELAY, LOG_FTP);
- while ((ch = getopt(argc, argv, "cCd::F:lnoOp:s:u:U:wW")) != -1) {
+ while ((ch = getopt(argc, argv, "cCd::F:lnoOp:sS:u:U:wW")) != -1) {
switch (ch) {
case 'c':
ipchroot = 1;
@@ -181,6 +182,9 @@ main(int argc, char *argv[])
case 's':
chroot_dir = optarg;
break;
+ case 'S':
+ check_woth = -1;
+ break;
case 'u':
chuser = optarg;
break;
@@ -361,7 +365,11 @@ main(int argc, char *argv[])
tftp_log(LOG_ERR, "setuid failed");
exit(1);
}
+ if (check_woth == -1)
+ check_woth = 0;
}
+ if (check_woth == -1)
+ check_woth = 1;
len = sizeof(me_sock);
if (getsockname(0, (struct sockaddr *)&me_sock, &len) == 0) {
@@ -704,7 +712,7 @@ validate_access(int peer, char **filep, int mode)
if ((stbuf.st_mode & S_IROTH) == 0)
return (EACCESS);
} else {
- if ((stbuf.st_mode & S_IWOTH) == 0)
+ if (check_woth && ((stbuf.st_mode & S_IWOTH) == 0))
return (EACCESS);
}
} else {
@@ -734,7 +742,7 @@ validate_access(int peer, char **filep, int mode)
if ((stbuf.st_mode & S_IROTH) != 0)
break;
} else {
- if ((stbuf.st_mode & S_IWOTH) != 0)
+ if (!check_woth || ((stbuf.st_mode & S_IWOTH) != 0))
break;
}
err = EACCESS;