flatpak-xdg-utils icon indicating copy to clipboard operation
flatpak-xdg-utils copied to clipboard

flatpak-spawn: Option to copy current env vars

Open gasinvein opened this issue 6 years ago • 5 comments

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.

gasinvein avatar Dec 20 '19 12:12 gasinvein

Steam's pressure-vessel-launch (which is loosely based on flatpak-spawn) has:

  • --unset-env=FOO: equivalent to env -u FOO
  • --pass-env=FOO: equivalent to --env=FOO=foo if FOO is set to foo, or --unset-env=FOO if FOO is unset
  • --pass-env-matching='*FO*': equivalent to --pass-env for 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 avatar Dec 09 '20 14:12 smcv

@smcv This sounds good enough to me.

gasinvein avatar Dec 09 '20 15:12 gasinvein