+int execute_command(const char *command, const char *subsystem)
+{
+ int retval;
+ pid_t pid;
+ char arg[PATH_SIZE];
+ char *argv[(PATH_SIZE / 2) + 1];
+ char *pos;
+ int devnull;
+ int i;
+
+ strlcpy(arg, command, sizeof(arg));
+ i = 0;
+ if (strchr(arg, ' ')) {
+ pos = arg;
+ while (pos != NULL) {
+ if (pos[0] == '\'') {
+ /* don't separate if in apostrophes */
+ pos++;
+ argv[i] = strsep(&pos, "\'");
+ while (pos && pos[0] == ' ')
+ pos++;
+ } else {
+ argv[i] = strsep(&pos, " ");
+ }
+ dbg("arg[%i] '%s'", i, argv[i]);
+ i++;
+ }
+ argv[i] = NULL;
+ dbg("execute '%s' with parsed arguments", arg);
+ } else {
+ argv[0] = arg;
+ argv[1] = (char *) subsystem;
+ argv[2] = NULL;
+ dbg("execute '%s' with subsystem '%s' argument", arg, argv[1]);
+ }