summaryrefslogtreecommitdiff
path: root/dev_d.c
diff options
context:
space:
mode:
authorharald@redhat.com <harald@redhat.com>2004-10-06 00:54:08 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:37:03 -0700
commit6e3e3c3416864eca74cb885f64c453eb531eed63 (patch)
treeb467f72775c46db6b8a208a61236027fce422e6a /dev_d.c
parentc8fa2d8b413f7cf1ab42d1c35865952649bfccad (diff)
[PATCH] PATCH udev close on exec
selinux wants a clean fd set, so better close all open fds
Diffstat (limited to 'dev_d.c')
-rw-r--r--dev_d.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/dev_d.c b/dev_d.c
index e6081b3993..c091f11c28 100644
--- a/dev_d.c
+++ b/dev_d.c
@@ -23,9 +23,13 @@
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <unistd.h>
+#include <fcntl.h>
+
#include "udev.h"
#include "udev_lib.h"
+#include "udevdb.h"
#include "logging.h"
#define DEVD_DIR "/etc/dev.d/"
@@ -34,6 +38,7 @@
static int run_program(char *name)
{
pid_t pid;
+ int fd;
dbg("running %s", name);
@@ -41,6 +46,14 @@ static int run_program(char *name)
switch (pid) {
case 0:
/* child */
+ udevdb_exit(); /* close udevdb */
+ fd = open("/dev/null", O_RDWR);
+ if ( fd >= 0) {
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDIN_FILENO);
+ dup2(fd, STDERR_FILENO);
+ }
+ close(fd);
execv(name, main_argv);
dbg("exec of child failed");
exit(1);