test: add testcase for environment file variables with backslashes
systemd silently strips out backslashes in variables from environment files. Add a testcase that explicitly tests for this behaviour.
This commit is contained in:
committed by
Yu Watanabe
parent
a9a2f9b0b1
commit
b6887d7ae4
@@ -455,7 +455,8 @@ static void test_exec_environmentfile(Manager *m) {
|
||||
" ; # comment3\n"
|
||||
"line without an equal\n"
|
||||
"VAR3='$word 5 6'\n"
|
||||
"VAR4='new\nline'\n";
|
||||
"VAR4='new\nline'\n"
|
||||
"VAR5=password\\with\\backslashes";
|
||||
int r;
|
||||
|
||||
r = write_string_file("/tmp/test-exec_environmentfile.conf", e, WRITE_STRING_FILE_CREATE);
|
||||
@@ -482,6 +483,7 @@ static void test_exec_passenvironment(Manager *m) {
|
||||
assert_se(setenv("VAR2", "word3", 1) == 0);
|
||||
assert_se(setenv("VAR3", "$word 5 6", 1) == 0);
|
||||
assert_se(setenv("VAR4", "new\nline", 1) == 0);
|
||||
assert_se(setenv("VAR5", "passwordwithbackslashes", 1) == 0);
|
||||
test(m, "exec-passenvironment.service", 0, CLD_EXITED);
|
||||
test(m, "exec-passenvironment-repeated.service", 0, CLD_EXITED);
|
||||
test(m, "exec-passenvironment-empty.service", 0, CLD_EXITED);
|
||||
@@ -489,6 +491,7 @@ static void test_exec_passenvironment(Manager *m) {
|
||||
assert_se(unsetenv("VAR2") == 0);
|
||||
assert_se(unsetenv("VAR3") == 0);
|
||||
assert_se(unsetenv("VAR4") == 0);
|
||||
assert_se(unsetenv("VAR5") == 0);
|
||||
test(m, "exec-passenvironment-absent.service", 0, CLD_EXITED);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user