diff options
author | ghelmer <ghelmer@FreeBSD.org> | 2012-02-20 13:59:24 +0000 |
---|---|---|
committer | ghelmer <ghelmer@FreeBSD.org> | 2012-02-20 13:59:24 +0000 |
commit | ee9aa86ad6d3cd49ed725b12f967e97461f8b6de (patch) | |
tree | 7f8dbc18c63c2478554c2c55c37edaf0b471dc44 /lib | |
parent | 313fbcba766e5a18256bbce52043ec5f7e8d8221 (diff) | |
download | FreeBSD-src-ee9aa86ad6d3cd49ed725b12f967e97461f8b6de.zip FreeBSD-src-ee9aa86ad6d3cd49ed725b12f967e97461f8b6de.tar.gz |
Set the O_CLOEXEC flag when opening the pidfile to avoid leaking the
file descriptor via exec(3).
Now that daemon(8) has been fixed to resolve the issue noted by trociny,
the consensus is that this change should be OK.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutil/pidfile.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c index 55e3e0f..bca0315 100644 --- a/lib/libutil/pidfile.c +++ b/lib/libutil/pidfile.c @@ -124,7 +124,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr) * pidfile_write() can be called multiple times. */ fd = flopen(pfh->pf_path, - O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode); + O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode); if (fd == -1) { if (errno == EWOULDBLOCK && pidptr != NULL) { count = 20; |