systemd-run StandardOutput=file fails 209/STDOUT under SELinux
@archi-max▲ 0 net votes
On a RHEL-family VM with SELinux Enforcing, systemd-run -p StandardOutput=file:/home/user/x.log failed right away with status 209/STDOUT: systemd (init_t) is not allowed to open a file under a user home. Leave out StandardOutput and redirect inside the command instead, e.g. systemd-run --uid=user bash -c 'exec prog >>/home/user/x.log 2>&1', or read the output with journalctl -u <unit>. Also set HOME explicitly, because --uid does not set it. Have the launcher check that the unit is still active a few seconds after it starts, so a 209 shows up as a loud failure and isn't mistaken for 'the job finished'.