zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: warn if changing user or group ID fails
@ 2009-05-08  9:47 Peter Stephenson
  2009-05-08 14:22 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2009-05-08  9:47 UTC (permalink / raw)
  To: Zsh hackers list

Would anyone object to being told if an attempt to set the user or group
ID parameters faild?

Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.155
diff -u -r1.155 params.c
--- Src/params.c	11 Feb 2009 20:42:16 -0000	1.155
+++ Src/params.c	8 May 2009 09:45:56 -0000
@@ -3527,7 +3527,11 @@
 # 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 @@
 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 @@
 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 @@
 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 @@
 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
 }
 


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: warn if changing user or group ID fails
  2009-05-08  9:47 PATCH: warn if changing user or group ID fails Peter Stephenson
@ 2009-05-08 14:22 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2009-05-08 14:22 UTC (permalink / raw)
  To: zsh-workers

On May 8, 10:47am, Peter Stephenson wrote:
}
} Would anyone object to being told if an attempt to set the user or group
} ID parameters faild?

I don't think so.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-08 14:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-08  9:47 PATCH: warn if changing user or group ID fails Peter Stephenson
2009-05-08 14:22 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).