+ /*
+ * Set the P_SUID* flags early so that we won't be fiddled with when
+ * we sleep later in this code.
+ * XXX - this could give us a few false positives and the caller must
+ * make sure to save and restore the flags if exec fails.
+ */
+ if (epp->ep_vap->va_mode & (VSUID|VSGID))
+ p->p_flag |= P_SUGID|P_SUGIDEXEC;
+
/* check access. for root we have to see if any exec bit on */
if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p)) != 0)
goto bad1;
@@ -244,6 +253,7 @@
char **tmpfap;
int szsigcode;
extern struct emul emul_native;
+ int saved_sugid;
/*
* figure out the maximum size of an exec header, if necessary.
@@ -275,6 +285,7 @@
pack.ep_emul = &emul_native;
pack.ep_flags = 0;
+ saved_sugid = p->p_flag & (P_SUGID|P_SUGIDEXEC);
/* see if we can run it. */
if ((error = check_exec(p, &pack)) != 0) {
goto freehdr;
@@ -642,6 +653,7 @@