Delete environment variables in Tramp when needed
* lisp/net/tramp-sh.el (tramp-get-env-with-u-option): New defun. (tramp-sh-handle-start-file-process) (tramp-sh-handle-process-file, ): Use it. (Bug#23952)
This commit is contained in:
parent
f6246717d1
commit
0a0144a2e1
1 changed files with 34 additions and 14 deletions
|
@ -3027,18 +3027,23 @@ the result will be a local, non-Tramp, file name."
|
||||||
tramp-initial-end-of-output))
|
tramp-initial-end-of-output))
|
||||||
;; We use as environment the difference to toplevel
|
;; We use as environment the difference to toplevel
|
||||||
;; `process-environment'.
|
;; `process-environment'.
|
||||||
env
|
env uenv
|
||||||
(env
|
(env (dolist (elt (cons prompt process-environment) env)
|
||||||
(dolist
|
(or (member elt (default-toplevel-value 'process-environment))
|
||||||
(elt
|
(if (string-match "=" elt)
|
||||||
(cons prompt (nreverse (copy-sequence process-environment)))
|
(setq env (append env `(,elt)))
|
||||||
env)
|
(if (tramp-get-env-with-u-option v)
|
||||||
(or (member elt (default-toplevel-value 'process-environment))
|
(setq env (append `("-u" ,elt) env))
|
||||||
(setq env (cons elt env)))))
|
(setq uenv (cons elt uenv)))))))
|
||||||
(command
|
(command
|
||||||
(when (stringp program)
|
(when (stringp program)
|
||||||
(format "cd %s && exec %s env %s %s"
|
(format "cd %s && %s exec %s env %s %s"
|
||||||
(tramp-shell-quote-argument localname)
|
(tramp-shell-quote-argument localname)
|
||||||
|
(if uenv
|
||||||
|
(format
|
||||||
|
"unset %s &&"
|
||||||
|
(mapconcat 'tramp-shell-quote-argument uenv " "))
|
||||||
|
"")
|
||||||
(if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
|
(if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
|
||||||
(mapconcat 'tramp-shell-quote-argument env " ")
|
(mapconcat 'tramp-shell-quote-argument env " ")
|
||||||
(if heredoc
|
(if heredoc
|
||||||
|
@ -3127,20 +3132,28 @@ the result will be a local, non-Tramp, file name."
|
||||||
(error "Implementation does not handle immediate return"))
|
(error "Implementation does not handle immediate return"))
|
||||||
|
|
||||||
(with-parsed-tramp-file-name default-directory nil
|
(with-parsed-tramp-file-name default-directory nil
|
||||||
(let (command env input tmpinput stderr tmpstderr outbuf ret)
|
(let (command env uenv input tmpinput stderr tmpstderr outbuf ret)
|
||||||
;; Compute command.
|
;; Compute command.
|
||||||
(setq command (mapconcat 'tramp-shell-quote-argument
|
(setq command (mapconcat 'tramp-shell-quote-argument
|
||||||
(cons program args) " "))
|
(cons program args) " "))
|
||||||
;; We use as environment the difference to toplevel `process-environment'.
|
;; We use as environment the difference to toplevel `process-environment'.
|
||||||
(setq env
|
(dolist (elt process-environment)
|
||||||
(dolist (elt (nreverse (copy-sequence process-environment)) env)
|
(or (member elt (default-toplevel-value 'process-environment))
|
||||||
(or (member elt (default-toplevel-value 'process-environment))
|
(if (string-match "=" elt)
|
||||||
(setq env (cons elt env)))))
|
(setq env (append env `(,elt)))
|
||||||
|
(if (tramp-get-env-with-u-option v)
|
||||||
|
(setq env (append `("-u" ,elt) env))
|
||||||
|
(setq uenv (cons elt uenv))))))
|
||||||
(when env
|
(when env
|
||||||
(setq command
|
(setq command
|
||||||
(format
|
(format
|
||||||
"env %s %s"
|
"env %s %s"
|
||||||
(mapconcat 'tramp-shell-quote-argument env " ") command)))
|
(mapconcat 'tramp-shell-quote-argument env " ") command)))
|
||||||
|
(when uenv
|
||||||
|
(setq command
|
||||||
|
(format
|
||||||
|
"unset %s && %s"
|
||||||
|
(mapconcat 'tramp-shell-quote-argument uenv " ") command)))
|
||||||
;; Determine input.
|
;; Determine input.
|
||||||
(if (null infile)
|
(if (null infile)
|
||||||
(setq input "/dev/null")
|
(setq input "/dev/null")
|
||||||
|
@ -5695,6 +5708,13 @@ Return ATTR."
|
||||||
((and (equal id-format 'string) (not (stringp res))) "UNKNOWN")
|
((and (equal id-format 'string) (not (stringp res))) "UNKNOWN")
|
||||||
(t res)))))
|
(t res)))))
|
||||||
|
|
||||||
|
(defun tramp-get-env-with-u-option (vec)
|
||||||
|
(with-tramp-connection-property vec "env-u-option"
|
||||||
|
(tramp-message vec 5 "Checking, whether `env -u' works")
|
||||||
|
;; Option "-u" is a GNU extension.
|
||||||
|
(tramp-send-command-and-check
|
||||||
|
vec "env FOO=foo env -u FOO 2>/dev/null | grep -qv FOO" t)))
|
||||||
|
|
||||||
;; Some predefined connection properties.
|
;; Some predefined connection properties.
|
||||||
(defun tramp-get-inline-compress (vec prop size)
|
(defun tramp-get-inline-compress (vec prop size)
|
||||||
"Return the compress command related to PROP.
|
"Return the compress command related to PROP.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue