summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2018-03-10 01:35:26 +0000
committerAlan Somers <asomers@FreeBSD.org>2018-03-10 01:35:26 +0000
commitd89aca7618ee5e1e27828b5581b565f358f199e7 (patch)
tree432c5786a90162816d84e3a76c7b1771b1102b8b /libexec
parent2e1fccf2cf9ea48d28bce65e80ff99fd16a4a1e7 (diff)
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/tftpd/tests/functional.c13
-rw-r--r--libexec/tftpd/tftpd.c10
2 files changed, 17 insertions, 6 deletions
diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c
index d7f5ac77f81b..4d0992e29e0e 100644
--- a/libexec/tftpd/tests/functional.c
+++ b/libexec/tftpd/tests/functional.c
@@ -350,6 +350,10 @@ setup(struct sockaddr_storage *to, uint16_t idx)
ATF_REQUIRE((client_s = socket(protocol, SOCK_DGRAM, 0)) > 0);
break;
}
+
+ /* Clear the client's umask. Test cases will specify exact modes */
+ umask(0000);
+
return (client_s);
}
@@ -714,7 +718,7 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,)
for (i = 0; i < nitems(contents); i++)
contents[i] = i;
- fd = open("medium.txt", O_RDWR | O_CREAT, 0644);
+ fd = open("medium.txt", O_RDWR | O_CREAT, 0666);
ATF_REQUIRE(fd >= 0);
close(fd);
@@ -747,7 +751,7 @@ TFTPD_TC_DEFINE(wrq_dropped_data,)
size_t contents_len;
char buffer[1024];
- fd = open("small.txt", O_RDWR | O_CREAT, 0644);
+ fd = open("small.txt", O_RDWR | O_CREAT, 0666);
ATF_REQUIRE(fd >= 0);
close(fd);
contents_len = strlen(contents) + 1;
@@ -782,7 +786,7 @@ TFTPD_TC_DEFINE(wrq_duped_data,)
for (i = 0; i < nitems(contents); i++)
contents[i] = i;
- fd = open("medium.txt", O_RDWR | O_CREAT, 0644);
+ fd = open("medium.txt", O_RDWR | O_CREAT, 0666);
ATF_REQUIRE(fd >= 0);
close(fd);
@@ -831,7 +835,8 @@ TFTPD_TC_DEFINE(wrq_eaccess_world_readable,)
close(fd);
SEND_WRQ("empty.txt", "octet");
- atf_tc_expect_fail("PR 226004 with relative pathnames, tftpd doesn't validate world writability");
+ atf_tc_expect_fail("PR 225996 tftpd doesn't abort on a WRQ access "
+ "violation");
RECV_ERROR(2, "Access violation");
}
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index a167395d5832..94f2f52be808 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -743,8 +743,12 @@ validate_access(int peer, char **filep, int mode)
dirp->name, filename);
if (stat(pathname, &stbuf) == 0 &&
(stbuf.st_mode & S_IFMT) == S_IFREG) {
- if ((stbuf.st_mode & S_IROTH) != 0) {
- break;
+ if (mode == RRQ) {
+ if ((stbuf.st_mode & S_IROTH) != 0)
+ break;
+ } else {
+ if ((stbuf.st_mode & S_IWOTH) != 0)
+ break;
}
err = EACCESS;
}
@@ -753,6 +757,8 @@ validate_access(int peer, char **filep, int mode)
*filep = filename = pathname;
else if (mode == RRQ)
return (err);
+ else if (err != ENOTFOUND || !create_new)
+ return (err);
}
/*