diff options
author | David Edmundson <kde@davidedmundson.co.uk> | 2022-09-14 20:21:00 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-15 20:43:17 +0200 |
commit | 8c0a6a96fe04f97966b86ec91ee4502f5d4fa8d8 (patch) | |
tree | d65d81dcaabaaa6862054f6ce72c8de3cb72b66c /src/xdg-autostart-generator/test-xdg-autostart.c | |
parent | unit: drop ProtectClock=yes from systemd-udevd.service (diff) | |
download | systemd-8c0a6a96fe04f97966b86ec91ee4502f5d4fa8d8.tar.xz systemd-8c0a6a96fe04f97966b86ec91ee4502f5d4fa8d8.zip |
xdg-autostart-service: expand tilde in Exec lines
In typical desktop file parsing it is expected that "~" expands to a
home directory.
Users may write an autostart file with "Exec=myCoolService
~/.someSpecialConfig" which worked before the systemd migration.
Diffstat (limited to 'src/xdg-autostart-generator/test-xdg-autostart.c')
-rw-r--r-- | src/xdg-autostart-generator/test-xdg-autostart.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/xdg-autostart-generator/test-xdg-autostart.c b/src/xdg-autostart-generator/test-xdg-autostart.c index 7866d3a7b4..e11f3d9385 100644 --- a/src/xdg-autostart-generator/test-xdg-autostart.c +++ b/src/xdg-autostart-generator/test-xdg-autostart.c @@ -25,6 +25,11 @@ static void test_xdg_format_exec_start_one(const char *exec, const char *expecte } TEST(xdg_format_exec_start) { + _cleanup_free_ char *home = NULL; + _cleanup_free_ char *expected1, *expected2 = NULL; + + assert_se(get_home_dir(&home) >= 0); + test_xdg_format_exec_start_one("/bin/sleep 100", "/bin/sleep 100"); /* All standardised % identifiers are stripped. */ @@ -34,6 +39,14 @@ TEST(xdg_format_exec_start) { test_xdg_format_exec_start_one("/bin/sleep %X \"%Y\"", "/bin/sleep %%X %%Y"); test_xdg_format_exec_start_one("/bin/sleep \";\\\"\"", "/bin/sleep \";\\\"\""); + + /* tilde is expanded only if standalone or at the start of a path */ + expected1 = strjoin("/bin/ls ", home); + test_xdg_format_exec_start_one("/bin/ls ~", expected1); + expected2 = strjoin("/bin/ls ", home, "/foo"); + test_xdg_format_exec_start_one("/bin/ls \"~/foo\"", expected2); + test_xdg_format_exec_start_one("/bin/ls ~foo", "/bin/ls ~foo"); + test_xdg_format_exec_start_one("/bin/ls foo~", "/bin/ls foo~"); } static const char* const xdg_desktop_file[] = { |