summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-09-11 16:08:46 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-09-11 16:08:46 -0400
commitb579bbdac0413a94b64d500c7b919d2a47173f00 (patch)
tree78d9d03d64f0dd5b21a4ab2ac2d75a93389feedd
parentbb6cc24d4a6a6ae49e46572d5cdf472c663df581 (diff)
suid wrapper: handle errors from getpwuid() and setreuid()
-rw-r--r--.local/bin/autobuild.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/.local/bin/autobuild.c b/.local/bin/autobuild.c
index 48ff48d..c8a319d 100644
--- a/.local/bin/autobuild.c
+++ b/.local/bin/autobuild.c
@@ -37,8 +37,13 @@ mysetenv(const char *name, const char *value)
int
main(int argc, char **argv)
{
+ errno = 0;
struct passwd *user = getpwuid(geteuid());
- setreuid(geteuid(), -1);
+ if (!user)
+ error(127, errno, "could not look up effective user (%ld) info", (long)geteuid());
+
+ if (setreuid(geteuid(), -1) < 0)
+ error(127, errno, "could not set real UID to match effective UID (%ld)", (long)geteuid());
const char *env_term = getenv("TERM");
const char *env_lang = getenv("LANG");