summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1997-08-04 05:40:37 +0000
committerDavid Greenman <dg@FreeBSD.org>1997-08-04 05:40:37 +0000
commit40ae4344e11f3c0e8a00531ae601131504c1cf50 (patch)
tree7eb72a68c405c0a7e9005350839976fad0cb6ffc
parent7c6750ba6950290b3879740440f83bc85a833bb7 (diff)
Notes
-rw-r--r--sys/kern/kern_exec.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 1b232475c87d..2746260790ae 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: kern_exec.c,v 1.47.2.6 1997/04/04 07:30:44 davidg Exp $
+ * $Id: kern_exec.c,v 1.47.2.7 1997/04/18 02:37:08 davidg Exp $
*/
#include <sys/param.h>
@@ -254,6 +254,18 @@ interpret:
else
suword(--stack_base, imgp->argc);
+ /*
+ * For security and other reasons, the file descriptor table cannot
+ * be shared after an exec.
+ */
+ if (p->p_fd->fd_refcnt > 1) {
+ struct filedesc *tmp;
+
+ tmp = fdcopy(p);
+ fdfree(p);
+ p->p_fd = tmp;
+ }
+
/* close files on exec */
fdcloseexec(p);
@@ -276,10 +288,13 @@ interpret:
}
/*
- * Implement image setuid/setgid. Disallow if the process is
- * being traced.
+ * Implement image setuid/setgid.
+ *
+ * Don't honor setuid/setgid if the filesystem prohibits it or if
+ * the process is being traced.
*/
if ((attr.va_mode & (VSUID | VSGID)) &&
+ (imgp->vp->v_mount->mnt_flag & MNT_NOSUID) == 0 &&
(p->p_flag & P_TRACED) == 0) {
/*
* Turn off syscall tracing for set-id programs, except for
@@ -626,12 +641,5 @@ exec_check_permissions(imgp)
if (error)
return (error);
- /*
- * Disable setuid/setgid if the filesystem prohibits it or if
- * the process is being traced.
- */
- if ((vp->v_mount->mnt_flag & MNT_NOSUID) || (p->p_flag & P_TRACED))
- attr->va_mode &= ~(VSUID | VSGID);
-
return (0);
}