about summary refs log tree commit diff
diff options
context:
space:
mode:
-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)