summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-05-08 14:30:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-05-08 14:30:31 +0000
commitff0b4ebdd56b2986bccc35185ac85762f2d41d07 (patch)
tree3a2eafc0bbc148aaf12928b734f3c4effa0fdb8a /Src
parentb2176aa525517dd17827c06a6b9c38db08628b52 (diff)
downloadzsh-ff0b4ebdd56b2986bccc35185ac85762f2d41d07.tar.gz
zsh-ff0b4ebdd56b2986bccc35185ac85762f2d41d07.tar.xz
zsh-ff0b4ebdd56b2986bccc35185ac85762f2d41d07.zip
26950: warn on failed attempt to change user or group ID
26593: print warning but dont fail test if simple Unicode conversion fails
Diffstat (limited to 'Src')
-rw-r--r--Src/params.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Src/params.c b/Src/params.c
index 6a7ab0fa6..4767aaa34 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3527,7 +3527,11 @@ usernamesetfn(UNUSED(Param pm), char *x)
 # ifdef USE_INITGROUPS
 	initgroups(x, pswd->pw_gid);
 # endif
-	if(!setgid(pswd->pw_gid) && !setuid(pswd->pw_uid)) {
+	if (setgid(pswd->pw_gid))
+	    zwarn("failed to change group ID: %e", errno);
+	else if (setuid(pswd->pw_uid))
+	    zwarn("failed to change user ID: %e", errno);
+	else {
 	    zsfree(cached_username);
 	    cached_username = ztrdup(pswd->pw_name);
 	    cached_uid = pswd->pw_uid;
@@ -3553,7 +3557,8 @@ void
 uidsetfn(UNUSED(Param pm), zlong x)
 {
 #ifdef HAVE_SETUID
-    setuid((uid_t)x);
+    if (setuid((uid_t)x))
+	zwarn("failed to change user ID: %e", errno);
 #endif
 }
 
@@ -3573,7 +3578,8 @@ void
 euidsetfn(UNUSED(Param pm), zlong x)
 {
 #ifdef HAVE_SETEUID
-    seteuid((uid_t)x);
+    if (seteuid((uid_t)x))
+	zwarn("failed to change effective user ID: %e", errno);
 #endif
 }
 
@@ -3593,7 +3599,8 @@ void
 gidsetfn(UNUSED(Param pm), zlong x)
 {
 #ifdef HAVE_SETUID
-    setgid((gid_t)x);
+    if (setgid((gid_t)x))
+	zwarn("failed to change group ID: %e", errno);
 #endif
 }
 
@@ -3613,7 +3620,8 @@ void
 egidsetfn(UNUSED(Param pm), zlong x)
 {
 #ifdef HAVE_SETEUID
-    setegid((gid_t)x);
+    if (setegid((gid_t)x))
+	zwarn("failed to change effective group ID: %e", errno);
 #endif
 }