Merge authors:
Stéphane Graber (stgraber)
Related merge proposals:
https://code.launchpad.net/~stgraber/upstart/upstart-fix-respawn/+merge/172420
proposed by: Stéphane Graber (stgraber)
review: Needs Fixing - Steve Langasek (vorlon)
------------------------------------------------------------
revno: 1498 [merge]
fixes bug: https://launchpad.net/bugs/1181789
committer: Steve Langasek <[email protected]>
branch nick: upstream
timestamp: Mon 2013-07-01 17:11:32 -0700
message:
Merge lp:~stgraber/upstart/upstart-fix-respawn
modified:
init/job_process.c
init/tests/test_job_process.c
--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk
Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'init/job_process.c'
--- init/job_process.c 2013-05-31 15:34:00 +0000
+++ init/job_process.c 2013-07-01 21:05:15 +0000
@@ -261,12 +261,6 @@
NIH_MUST (nih_str_array_addp (&argv, NULL,
&argc, cmd));
}
-
- /* At the end, always set proc->script to TRUE, even if the user didn't
- * explicitly set it (when using shell variables). That way tests
- * can reliably check for shell-specific behaviour.
- */
- proc->script = TRUE;
} else {
/* Split the command on whitespace to produce a list of
* arguments that we can exec directly.
=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c 2013-06-25 09:19:05 +0000
+++ init/tests/test_job_process.c 2013-07-01 23:15:19 +0000
@@ -83,6 +83,14 @@
#define MAX_ITERATIONS 5
/**
+ * SHELL_CHARS:
+ *
+ * This is the list of characters that, if encountered in a process, cause
+ * it to always be run with a shell.
+ **/
+#define SHELL_CHARS "~`!$^&*()=|\\{}[];\"'<>?"
+
+/**
* CHECK_FILE_EQ:
*
* @_file: FILE to read from,
@@ -501,6 +509,7 @@
waitpid (job->pid[PROCESS_MAIN], NULL, 0);
TEST_EQ (stat (filename, &statbuf), 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
/* Filename should contain the pid */
output = fopen (filename, "r");
@@ -677,7 +686,7 @@
output = fopen (filename, "r");
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "FOO=BAR\n");
- if (job->class->process[PROCESS_MAIN]->script)
+ if (job->class->process[PROCESS_MAIN]->script || strpbrk (job->class->process[PROCESS_MAIN]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -733,7 +742,7 @@
output = fopen (filename, "r");
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "FOO=BAR\n");
- if (job->class->process[PROCESS_MAIN]->script)
+ if (job->class->process[PROCESS_MAIN]->script || strpbrk (job->class->process[PROCESS_MAIN]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=foo\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -791,7 +800,7 @@
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "CRACKLE=FIZZ\n");
TEST_FILE_EQ (output, "FOO=SMACK\n");
- if (job->class->process[PROCESS_PRE_STOP]->script)
+ if (job->class->process[PROCESS_PRE_STOP]->script || strpbrk (job->class->process[PROCESS_PRE_STOP]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -849,7 +858,7 @@
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "CRACKLE=FIZZ\n");
TEST_FILE_EQ (output, "FOO=SMACK\n");
- if (job->class->process[PROCESS_POST_STOP]->script)
+ if (job->class->process[PROCESS_POST_STOP]->script || strpbrk (job->class->process[PROCESS_POST_STOP]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -6069,6 +6078,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
TEST_FILE_EQ (output, ("test: test main process (1) "
"terminated with status 1\n"));
@@ -6156,6 +6166,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
TEST_FILE_EQ (output, ("test: test main process (1) "
"terminated with status 1\n"));
@@ -6240,6 +6251,7 @@
TEST_EQ (job->failed, TRUE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
TEST_FILE_EQ (output, ("test: test respawning too fast, "
"stopped\n"));
@@ -6313,6 +6325,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
nih_free (job);
}
@@ -6390,6 +6403,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
TEST_FILE_EQ (output, ("test: test main process ended, "
"respawning\n"));
@@ -6462,6 +6476,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
nih_free (job);
}
@@ -7423,6 +7438,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
TEST_FILE_EQ (output, ("test: test main process ended, "
"respawning\n"));
@@ -7739,6 +7755,7 @@
TEST_EQ (job->failed, FALSE);
TEST_EQ (job->failed_process, PROCESS_INVALID);
TEST_EQ (job->exit_status, 0);
+ TEST_EQ (job->class->process[PROCESS_MAIN]->script, FALSE);
TEST_FILE_EQ (output, ("test: test main process ended, "
"respawning\n"));
--
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/upstart-devel