1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 10:01:11 +02:00

Take more care with errors from setuid().

This is to ensure the user is aware of errors unsetting the
PRIVELEGED option.
This commit is contained in:
Jérémie Roquet 2014-10-16 16:14:49 +02:00 committed by Peter Stephenson
parent fd302c9837
commit 52d37d7ff4
2 changed files with 16 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2014-10-31 Peter Stephenson <p.stephenson@samsung.com>
* via private email: Jérémie Roquet: Src/options.c: more care
with errors using setuid().
2014-10-30 Oliver Kiddle <opk@zsh.org>
* 33570, 33576: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list, Src/Zle/zle.h,

View file

@ -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)