Module Name:    src
Committed By:   christos
Date:           Thu Jan 24 17:46:00 UTC 2013

Modified Files:
        src/usr.bin/usbhidaction: usbhidaction.c

Log Message:
use O_CLOEXEC


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/usbhidaction/usbhidaction.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/usbhidaction/usbhidaction.c
diff -u src/usr.bin/usbhidaction/usbhidaction.c:1.24 src/usr.bin/usbhidaction/usbhidaction.c:1.25
--- src/usr.bin/usbhidaction/usbhidaction.c:1.24	Sun Jan 18 02:14:03 2009
+++ src/usr.bin/usbhidaction/usbhidaction.c	Thu Jan 24 12:46:00 2013
@@ -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 @@ main(int argc, char **argv)
 	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);

Reply via email to