[PATCH] remove limit of the number of args passed to PROGRAM
If we go over our internal limit of 7, then we call out to /bin/sh otherwise we handle it ourself without relying on a shell.
This commit is contained in:
parent
3fe0734266
commit
dde05ccb8d
18
namedev.c
18
namedev.c
|
@ -421,7 +421,13 @@ static int execute_program(char *path, char *value, int len)
|
||||||
case 0:
|
case 0:
|
||||||
/* child */
|
/* child */
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
dup(fds[1]); /* dup write side of pipe to STDOUT */
|
|
||||||
|
/* dup write side of pipe to STDOUT */
|
||||||
|
dup(fds[1]);
|
||||||
|
|
||||||
|
/* copy off our path to use incase we have too many args */
|
||||||
|
strnfieldcpy(buffer, path, sizeof(buffer));
|
||||||
|
|
||||||
if (strchr(path, ' ')) {
|
if (strchr(path, ' ')) {
|
||||||
/* exec with arguments */
|
/* exec with arguments */
|
||||||
pos = path;
|
pos = path;
|
||||||
|
@ -431,14 +437,16 @@ static int execute_program(char *path, char *value, int len)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (args[i]) {
|
if (args[i]) {
|
||||||
dbg("too many args - %d", i);
|
dbg("too many args - %d, using subshell instead '%s'", i, buffer);
|
||||||
args[i] = NULL;
|
retval = execl("/bin/sh", "sh", "-c", buffer, NULL);
|
||||||
}
|
} else {
|
||||||
|
dbg("execute program '%s'", path);
|
||||||
retval = execv(args[0], args);
|
retval = execv(args[0], args);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
retval = execv(path, main_argv);
|
retval = execv(path, main_argv);
|
||||||
}
|
}
|
||||||
dbg("child execve failed");
|
info(FIELD_PROGRAM " execution of '%s' failed", path);
|
||||||
exit(1);
|
exit(1);
|
||||||
case -1:
|
case -1:
|
||||||
dbg("fork failed");
|
dbg("fork failed");
|
||||||
|
|
|
@ -241,6 +241,15 @@ EOF
|
||||||
expected => "escape-3" ,
|
expected => "escape-3" ,
|
||||||
conf => <<EOF
|
conf => <<EOF
|
||||||
BUS="scsi", PROGRAM="/bin/echo -n escape-%%n", KERNEL="sda3", NAME="%c"
|
BUS="scsi", PROGRAM="/bin/echo -n escape-%%n", KERNEL="sda3", NAME="%c"
|
||||||
|
EOF
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc => "program with lots of arguments",
|
||||||
|
subsys => "block",
|
||||||
|
devpath => "block/sda/sda3",
|
||||||
|
expected => "foo9" ,
|
||||||
|
conf => <<EOF
|
||||||
|
BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="%c{7}"
|
||||||
EOF
|
EOF
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
3
udev.8
3
udev.8
|
@ -182,8 +182,7 @@ all of the values being required in order to match the rule.
|
||||||
.TP
|
.TP
|
||||||
.B PROGRAM
|
.B PROGRAM
|
||||||
Call external program. This key is valid if the program returns successful.
|
Call external program. This key is valid if the program returns successful.
|
||||||
A few command line options may specified, but shell characters like pipe,
|
The environment variables of
|
||||||
diversion or similiar options are not available. The environment variables of
|
|
||||||
.B udev
|
.B udev
|
||||||
are also available for the program.
|
are also available for the program.
|
||||||
.br
|
.br
|
||||||
|
|
Loading…
Reference in a new issue