diff options
author | Jérémie Roquet <arkanosis@gmail.com> | 2014-10-16 16:14:49 +0200 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2014-10-31 10:02:36 +0000 |
commit | 52d37d7ff437017334f912651bd4af909960db10 (patch) | |
tree | 1b0e7d3e5aaac36c76c029291dcf6b36e66845b8 /Src | |
parent | fd302c9837b0034962471b9288b182e2525ba1d8 (diff) | |
download | zsh-52d37d7ff437017334f912651bd4af909960db10.tar.gz zsh-52d37d7ff437017334f912651bd4af909960db10.tar.xz zsh-52d37d7ff437017334f912651bd4af909960db10.zip |
Take more care with errors from setuid().
This is to ensure the user is aware of errors unsetting the PRIVELEGED option.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/options.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Src/options.c b/Src/options.c index 6e4e7b911..3e3e07474 100644 --- a/Src/options.c +++ b/Src/options.c @@ -766,7 +766,17 @@ dosetopt(int optno, int value, int force, char *new_opts) #ifdef HAVE_SETUID setuid(getuid()); setgid(getgid()); -#endif /* HAVE_SETUID */ + if (setuid(getuid())) { + zwarn("failed to change user ID: %e", errno); + return -1; + } else if (setgid(getgid())) { + zwarn("failed to change group ID: %e", errno); + return -1; + } +#else + zwarn("setuid not available"); + return -1; +#endif /* not HAVE_SETUID */ #ifdef JOB_CONTROL } else if (!force && optno == MONITOR && value) { if (new_opts[optno] == value) |