flatpak-spawn: Option to copy current env vars
It would be nice to have some option like --copy-env to automatically set all current environment variables for spawned process. This way it would behave more like a child process, that inherits current environment.
App-launching apps like Steam or Lutris would benefit from it a lot, since it would allow to easily restrict permissions for child app or game.
Steam's pressure-vessel-launch (which is loosely based on flatpak-spawn) has:
-
--unset-env=FOO: equivalent toenv -u FOO -
--pass-env=FOO: equivalent to--env=FOO=fooifFOOis set tofoo, or--unset-env=FOOifFOOis unset -
--pass-env-matching='*FO*': equivalent to--pass-envfor every variable that is set in the caller's environment whose name matches the glob*FO*
I could do a MR to add these to flatpak-spawn if there's interest?
Then @gasinvein could use --clear-env --pass-env-matching='*' to get an exact copy of the caller's environment.
--unset-env is nicer to implement with help from the server sides in Flatpak (the portal and the session helper), but it's possible to emulate it against the existing Flatpak servers by literally using env -u FOO -u BAR myprogram as the command to execute.
@smcv This sounds good enough to me.