about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJérémie Roquet <arkanosis@gmail.com>2014-10-16 16:14:49 +0200
committerPeter Stephenson <pws@zsh.org>2014-10-31 10:02:36 +0000
commit52d37d7ff437017334f912651bd4af909960db10 (patch)
tree1b0e7d3e5aaac36c76c029291dcf6b36e66845b8
parentfd302c9837b0034962471b9288b182e2525ba1d8 (diff)
downloadzsh-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.
-rw-r--r--ChangeLog5
-rw-r--r--Src/options.c12
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 146f1b8c1..4f9544dc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
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)