From 9d59fdf77480f56db168824cdad47161e940cb90 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 2 Jul 1998 09:08:54 +0000 Subject: document fd 0-2 scheme for setuid/setgid --- lib/libc/sys/execve.2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/libc/sys/execve.2 b/lib/libc/sys/execve.2 index de7a0dc8ee2..023d232d499 100644 --- a/lib/libc/sys/execve.2 +++ b/lib/libc/sys/execve.2 @@ -115,6 +115,13 @@ and .Xr fcntl 2 ) . Descriptors that remain open are unaffected by .Fn execve . +In the case of a new setuid or setgid executable being executed, if +file descriptors 0, 1, or 2 (representing stdin, stdout, and stderr) +are currently unallocated, these descriptors will be opened to point to +some system file like +.Pa /dev/null . +The intent is to ensure these descriptors are not unallocated, since +many libraries make assumptions about the use of these 3 file descriptors. .Pp Signals set to be ignored in the calling process are set to be ignored in the -- cgit v1.2.3