summaryrefslogtreecommitdiffstats
path: root/lib/libutil/uucplock.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-08-28 21:10:37 +0000
committerjilles <jilles@FreeBSD.org>2013-08-28 21:10:37 +0000
commitbaaacfdc28bae3ef25b6e173c058f66a64c7f18d (patch)
tree8dda6bdc0191b6bd5008300355e35de43cca06e6 /lib/libutil/uucplock.c
parent609f43ab7f3c398c0c3a4d8f093fe380c9e04b82 (diff)
downloadFreeBSD-src-baaacfdc28bae3ef25b6e173c058f66a64c7f18d.zip
FreeBSD-src-baaacfdc28bae3ef25b6e173c058f66a64c7f18d.tar.gz
libutil: Use O_CLOEXEC for internal file descriptors from open().
Diffstat (limited to 'lib/libutil/uucplock.c')
-rw-r--r--lib/libutil/uucplock.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c
index afbfaa4..424ac26 100644
--- a/lib/libutil/uucplock.c
+++ b/lib/libutil/uucplock.c
@@ -76,7 +76,8 @@ uu_lock(const char *tty_name)
pid);
(void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,
tty_name);
- if ((tmpfd = creat(lcktmpname, 0664)) < 0)
+ if ((tmpfd = open(lcktmpname, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
+ 0664)) < 0)
GORET(0, UU_LOCK_CREAT_ERR);
for (i = 0; i < MAXTRIES; i++) {
@@ -88,7 +89,7 @@ uu_lock(const char *tty_name)
* check to see if the process holding the lock
* still exists
*/
- if ((fd = open(lckname, O_RDONLY)) < 0)
+ if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) < 0)
GORET(1, UU_LOCK_OPEN_ERR);
if ((pid_old = get_pid (fd, &err)) == -1)
@@ -132,7 +133,7 @@ uu_lock_txfr(const char *tty_name, pid_t pid)
snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, tty_name);
- if ((fd = open(lckname, O_RDWR)) < 0)
+ if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) < 0)
return UU_LOCK_OWNER_ERR;
if (get_pid(fd, &err) != getpid())
err = UU_LOCK_OWNER_ERR;
OpenPOWER on IntegriCloud