aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/setuid.2
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2015-09-13 14:00:49 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2015-09-13 14:00:49 +0000
commit6b46581ed9ee98e582a9d0329d423d92d2d59f46 (patch)
treecdeaf677f153ccff5ffd2e7f0b231464dbb4d4ef /lib/libc/sys/setuid.2
parent844c2a3a9438df1cdf0b0a058497fb59f757e1b4 (diff)
setuid(2): Suggest O_CLOEXEC instead of fcntl(F_SETFD).
Notes
Notes: svn path=/head/; revision=287753
Diffstat (limited to 'lib/libc/sys/setuid.2')
-rw-r--r--lib/libc/sys/setuid.29
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/libc/sys/setuid.2 b/lib/libc/sys/setuid.2
index 4c7d5ad0c67a..54d89bcc7464 100644
--- a/lib/libc/sys/setuid.2
+++ b/lib/libc/sys/setuid.2
@@ -28,7 +28,7 @@
.\" @(#)setuid.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd September 13, 2015
.Dt SETUID 2
.Os
.Sh NAME
@@ -178,15 +178,10 @@ pseudocode(void)
int fd;
/* ... */
- fd = open("/path/to/sensitive/data", O_RDWR);
+ fd = open("/path/to/sensitive/data", O_RDWR | O_CLOEXEC);
if (fd == -1)
err(1, "open");
- /*
- * Set close-on-exec flag; see fcntl(2) for more information.
- */
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
- err(1, "fcntl(F_SETFD)");
/* ... */
execve(path, argv, environ);
}