mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00
ssh: Fix environment variable parsing (#177503)
From systemctl(1)'s `show-environment`: [...] If no special characters or whitespace is present in the variable values, no escaping is performed, and the assignments have the form "VARIABLE=value". If whitespace or characters which have special meaning to the shell are present, dollar-single-quote escaping is used, and assignments have the form "VARIABLE=$'value'". [...] `DISPLAY` is unlikely to require such escaping, but is still broken and overly complicated. Just rely on the fact that systemctl outputs line that are safe to be interpreted by the shell. Filter for `DISPLAY` and `eval` the output instead of trying to parse just the value part and reassign it again.
This commit is contained in:
parent
d361bb4bb4
commit
afffa89ec5
1 changed files with 1 additions and 3 deletions
|
@ -13,9 +13,7 @@ let
|
|||
|
||||
askPasswordWrapper = pkgs.writeScript "ssh-askpass-wrapper" ''
|
||||
#! ${pkgs.runtimeShell} -e
|
||||
export DISPLAY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^DISPLAY=\(.*\)/\1/; t; d')"
|
||||
export XAUTHORITY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^XAUTHORITY=\(.*\)/\1/; t; d')"
|
||||
export WAYLAND_DISPLAY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^WAYLAND_DISPLAY=\(.*\)/\1/; t; d')"
|
||||
eval export $(systemctl --user show-environment | ${pkgs.coreutils}/bin/grep -E '^(DISPLAY|WAYLAND_DISPLAY|XAUTHORITY)=')
|
||||
exec ${cfg.askPassword} "$@"
|
||||
'';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue