Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/usbhidaction use O_CLOEXEC



details:   https://anonhg.NetBSD.org/src/rev/d7c7bf601cd8
branches:  trunk
changeset: 784307:d7c7bf601cd8
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 24 17:46:00 2013 +0000

description:
use O_CLOEXEC

diffstat:

 usr.bin/usbhidaction/usbhidaction.c |  10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diffs (34 lines):

diff -r ba92ad2a9e41 -r d7c7bf601cd8 usr.bin/usbhidaction/usbhidaction.c
--- a/usr.bin/usbhidaction/usbhidaction.c       Thu Jan 24 17:44:59 2013 +0000
+++ b/usr.bin/usbhidaction/usbhidaction.c       Thu Jan 24 17:46:00 2013 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: usbhidaction.c,v 1.24 2009/01/18 07:14:03 lukem Exp $ */
+/*      $NetBSD: usbhidaction.c,v 1.25 2013/01/24 17:46:00 christos Exp $ */
 
 /*
  * Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: usbhidaction.c,v 1.24 2009/01/18 07:14:03 lukem Exp $");
+__RCSID("$NetBSD: usbhidaction.c,v 1.25 2013/01/24 17:46:00 christos Exp $");
 #endif
 
 #include <stdio.h>
@@ -143,14 +143,10 @@
        if (demon && conf[0] != '/')
                errx(1, "config file must have an absolute path, %s", conf);
 
-       fd = open(dev, O_RDWR);
+       fd = open(dev, O_RDWR | O_CLOEXEC);
        if (fd < 0)
                err(1, "%s", dev);
 
-       /* Avoid passing the device file descriptor to executed commands */
-       if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
-               err(1, "fcntl(F_SETFD, FD_CLOEXEC)");
-
        if (ioctl(fd, USB_GET_REPORT_ID, &reportid) < 0)
                reportid = -1;
        repd = hid_get_report_desc(fd);



Home | Main Index | Thread Index | Old Index