Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
nixos/test-driver: Specify /bin/sh shell when running a bourne shell …
Browse files Browse the repository at this point in the history
…script as the user

The test harness provides the commands it wishes to run in Bourne
syntax.  This fails if the user uses a different shell.  For example,
with fish:

  machine.wait_for_unit("graphical-session.target", "alice")

machine # fish: Unsupported use of '='. To run '-u`' with a modified environment, please use 'env XDG_RUNTIME_DIR=/run/user/`id -u`…'
machine # XDG_RUNTIME_DIR=/run/user/`id -u` systemctl --user --no-pager show "graphical-session.target"
machine # ^
machine # [   16.329957] su[1077]: pam_unix(su:session): session closed for user alice
error: retrieving systemctl info for unit "graphical-session.target" under user "alice" failed with exit code 127
  • Loading branch information
chkno committed May 9, 2020
1 parent d0c3e7b commit 751a270
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nixos/lib/test-driver/test-driver.py
Expand Up @@ -369,7 +369,7 @@ def systemctl(self, q: str, user: Optional[str] = None) -> Tuple[int, str]:
q = q.replace("'", "\\'")
return self.execute(
(
"su -l {} -c "
"su -l {} --shell /bin/sh -c "
"$'XDG_RUNTIME_DIR=/run/user/`id -u` "
"systemctl --user {}'"
).format(user, q)
Expand Down

0 comments on commit 751a270

Please sign in to comment.