]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-systemd-tmpfiles: respect $HOME in test for %h expansion 7419/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 4 Dec 2017 08:05:05 +0000 (09:05 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Dec 2017 09:30:49 +0000 (10:30 +0100)
%h is a special specifier because we look at $HOME (unless running suid, but
let's say that this case does not apply to tmpfiles, since the code is
completely unready to be run suid). For all other specifiers we query the user
db and use those values directly. I'm not sure if this exception is good, but
let's just "document" status quo for now. If this is changes, it should be in
a separate PR.

src/test/test-systemd-tmpfiles.py

index 00362c695209c592e61918f6bd6f8124df274839..309cee23e64aa9278be2e080dc8e8c27156382a3 100755 (executable)
@@ -100,7 +100,11 @@ def test_valid_specifiers(*, user):
 
     user = pwd.getpwuid(os.getuid())
     test_content('f {} - - - - %u', '{}'.format(user.pw_name), user=user)
-    test_content('f {} - - - - %h', '{}'.format(user.pw_dir), user=user)
+
+    # Note that %h is the only specifier in which we look the environment,
+    # because we check $HOME. Should we even be doing that?
+    home = os.path.expanduser("~")
+    test_content('f {} - - - - %h', '{}'.format(home), user=user)
 
     xdg_runtime_dir = os.getenv('XDG_RUNTIME_DIR')
     if xdg_runtime_dir is not None or not user: