From: greg@kroah.com Date: Fri, 27 Feb 2004 05:29:49 +0000 (-0800) Subject: [PATCH] remove limit of the number of args passed to PROGRAM X-Git-Tag: 019~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=dde05ccb8d423fbc5c29f54b0c1b545938c8f151 [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. --- diff --git a/namedev.c b/namedev.c index 21f52d1f3..7c07e3b10 100644 --- a/namedev.c +++ b/namedev.c @@ -421,7 +421,13 @@ static int execute_program(char *path, char *value, int len) case 0: /* child */ 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, ' ')) { /* exec with arguments */ pos = path; @@ -431,14 +437,16 @@ static int execute_program(char *path, char *value, int len) break; } if (args[i]) { - dbg("too many args - %d", i); - args[i] = NULL; + dbg("too many args - %d, using subshell instead '%s'", i, buffer); + 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 { retval = execv(path, main_argv); } - dbg("child execve failed"); + info(FIELD_PROGRAM " execution of '%s' failed", path); exit(1); case -1: dbg("fork failed"); diff --git a/test/udev-test.pl b/test/udev-test.pl index f2f77dd0e..a3bf768fe 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -241,6 +241,15 @@ EOF expected => "escape-3" , conf => < "program with lots of arguments", + subsys => "block", + devpath => "block/sda/sda3", + expected => "foo9" , + conf => <