From bd8bbd99ee83fc40a8dfc0ba1863f4f0a60551ce Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Sat, 27 Oct 2012 01:20:48 +0000 Subject: MFC r241848: Check the return error of set[e][ug]id. While this can never fail in the current version of FreeBSD, this isn't guarenteed by the API. Custom security modules, or future implementations of the setuid and setgid may fail. Approved by: cperciva (implicit) --- libexec/tftpd/tftpd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libexec') diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index 16702b70cb1f..634e0f821276 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -371,7 +371,10 @@ main(int argc, char *argv[]) } chdir("/"); setgroups(1, &nobody->pw_gid); - setuid(nobody->pw_uid); + if (setuid(nobody->pw_uid) != 0) { + tftp_log(LOG_ERR, "setuid failed"); + exit(1); + } } len = sizeof(me_sock); -- cgit v1.3