chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] PATCH udev close on exec
[elogind.git]
/
dev_d.c
diff --git
a/dev_d.c
b/dev_d.c
index 97c552647b27fdda1756880f8b1ed7f2a0be3852..c091f11c28726cc02d5a165bdecd38d7befad1da 100644
(file)
--- a/
dev_d.c
+++ b/
dev_d.c
@@
-23,9
+23,13
@@
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
+#include <fcntl.h>
+
#include "udev.h"
#include "udev_lib.h"
#include "udev.h"
#include "udev_lib.h"
+#include "udevdb.h"
#include "logging.h"
#define DEVD_DIR "/etc/dev.d/"
#include "logging.h"
#define DEVD_DIR "/etc/dev.d/"
@@
-34,6
+38,7
@@
static int run_program(char *name)
{
pid_t pid;
static int run_program(char *name)
{
pid_t pid;
+ int fd;
dbg("running %s", name);
dbg("running %s", name);
@@
-41,6
+46,14
@@
static int run_program(char *name)
switch (pid) {
case 0:
/* child */
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);
execv(name, main_argv);
dbg("exec of child failed");
exit(1);
@@
-61,7
+74,7
@@
static int run_program(char *name)
* subsystem/
* default/
*/
* subsystem/
* default/
*/
-void dev_d_send(struct udevice *dev, c
har *subsystem,
char *devpath)
+void dev_d_send(struct udevice *dev, c
onst char *subsystem, const
char *devpath)
{
char dirname[256];
char env_devname[NAME_SIZE];
{
char dirname[256];
char env_devname[NAME_SIZE];
@@
-71,6
+84,7
@@
void dev_d_send(struct udevice *dev, char *subsystem, char *devpath)
if (udev_dev_d == 0)
return;
if (udev_dev_d == 0)
return;
+ memset(env_devname, 0x00, sizeof(env_devname));
if (dev->type == 'b' || dev->type == 'c') {
strfieldcpy(env_devname, udev_root);
strfieldcat(env_devname, dev->name);
if (dev->type == 'b' || dev->type == 'c') {
strfieldcpy(env_devname, udev_root);
strfieldcat(env_devname, dev->name);