Index: kern_exec.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_exec.c,v
retrieving revision 1.129
diff -u -r1.129 kern_exec.c
--- kern_exec.c	2001/05/25 16:59:06	1.129
+++ kern_exec.c	2001/05/26 16:42:54
@@ -334,14 +334,19 @@
 	 * (replaced) euid and egid as the source, which may or may not be
 	 * the right ones to use.
 	 */
-	if (oldcred->cr_svuid != oldcred->cr_uid ||
-	    oldcred->cr_svgid != oldcred->cr_gid) {
-		/*
-		 * Avoid allocating a newcred if we don't have one yet and
-		 * the saved uid/gid update would be a noop.
-		 */
-		if (newcred == NULL)
-			newcred = crdup(oldcred);
+	if (newcred == NULL) {
+		if (oldcred->cr_svuid != oldcred->cr_uid ||
+		    oldcred->cr_svgid != oldcred->cr_gid) {
+			/*
+			 * Avoid allocating a newcred if we don't have one
+			 * yet and the saved uid/gid update would be a noop.
+			 */
+			if (newcred == NULL)
+				newcred = crdup(oldcred);
+			change_svuid(newcred, newcred->cr_uid);
+			change_svgid(newcred, newcred->cr_gid);
+		}
+	} else {
 		change_svuid(newcred, newcred->cr_uid);
 		change_svgid(newcred, newcred->cr_gid);
 	}

