From a603c87b0251c5b6077c28864b1aeb21c40f4086 Mon Sep 17 00:00:00 2001 From: eadler Date: Mon, 22 Oct 2012 03:07:05 +0000 Subject: 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. Submitted by: Erik Cederstrand Approved by: cperciva MFC after: 3 days --- usr.sbin/edquota/edquota.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.sbin/edquota') diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 0957011..930a460 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -453,8 +453,10 @@ editit(char *tmpf) const char *ed; sigsetmask(omask); - setgid(getgid()); - setuid(getuid()); + if (setgid(getgid()) != 0) + err(1, "setgid failed"); + if (setuid(getuid()) != 0) + err(1, "setuid failed"); if ((ed = getenv("EDITOR")) == (char *)0) ed = _PATH_VI; execlp(ed, ed, tmpf, (char *)0); -- cgit v1.1