summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2001-05-26 19:59:44 +0000
committerrwatson <rwatson@FreeBSD.org>2001-05-26 19:59:44 +0000
commit69376917898375a29aec49173210a6130a26c667 (patch)
tree942e4ce54552d17c95e63ea560c36e38871bc2eb /sys
parentb7626578b01ad84d2b9b7b9f80663b36e0e92372 (diff)
downloadFreeBSD-src-69376917898375a29aec49173210a6130a26c667.zip
FreeBSD-src-69376917898375a29aec49173210a6130a26c667.tar.gz
o pcred-removal changes included modifications to optimize the setting of
the saved uid and gid during execve(). Unfortunately, the optimizations were incorrect in the case where the credential was updated, skipping the setting of the saved uid and gid when new credentials were generated. This change corrects that problem by handling the newcred!=NULL case correctly. Reported/tested by: David Malone <dwmalone@maths.tcd.ie> Obtained from: TrustedBSD Project
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_exec.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index e3ae485..0d7da41 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -334,17 +334,18 @@ interpret:
* (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)
+ if (newcred == NULL) {
+ if (oldcred->cr_svuid != oldcred->cr_uid ||
+ oldcred->cr_svgid != oldcred->cr_gid) {
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);
}
+
if (newcred != NULL) {
PROC_LOCK(p);
p->p_ucred = newcred;
OpenPOWER on IntegriCloud