Trying to run a systemd service with systemctl --user start foo.service which contains ExecStart=touch /bar/baz where /bar has permissions drwxrwxr-x 1 root storage. The user running the command belongs to the group storage and can run the touch command from the shell without issue, creating the file. The service, however, fails with a permission error.
I thought that the service's permissions would match the user running it - and indeed having the service use the ${USER} environment variable in its command does produce my user, and the service appears in my ps or pstree ${USER} lists.
foo.service does not contain ProtectSystem or any entry other than: Description, EnvironmentFile, Environment, ExecStart, KillSignal, Restart, RestartSec. The environment entries are to load non-permission-related configuration.
Does the service not actually use the calling user for permissions? And if not what would be the best approach to solve the issue? /bar is on a mounted drive, so I can just dmask 0000 in my fstab, but I'd rather avoid this approach.
ExecStart=to point to an executablebashscript that does(echo "=== id ===";id;echo "=== set ===";set;echo "=== env ===";env | sort;echo "=== alias ===";alias)>/tmp/foo.logidfrom the service shows thestoragegroup. My guess is that the group status wasn't propagated correctly somehow. Not sure how exactly - I logged out and it did work when ran manually. Maybe some lingering systemd state?