From 8845865d1537d50dd26cec61f181f39ff14e6928 Mon Sep 17 00:00:00 2001 Message-Id: <8845865d1537d50dd26cec61f181f39ff14e6928.1718140838.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 6 Aug 2017 03:23:20 +0100 Subject: [PATCH 1/1] el/dot-emacs.el: Don't leak `LD_PRELOAD' into some subprocesses. Organization: Straylight/Edgeware From: Mark Wooding Currently, compile, term, shell, eshell, but there may be more. Basically, places where Emacs runs user commands rather than its own made-up stuff. --- el/dot-emacs.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 8195411..8aff2b9 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -535,6 +535,12 @@ (eval-after-load "compile" '(progn (define-key compilation-shell-minor-mode-map "\C-c\M-g" 'recompile))) +(defadvice compile (around hack-environment compile activate) + "Hack the environment inherited by inferiors in the compilation." + (let ((process-environment process-environment)) + (setenv "LD_PRELOAD" nil) + ad-do-it)) + (defun mdw-compile (command &optional directory comint) "Initiate a compilation COMMAND, maybe in a different DIRECTORY. The DIRECTORY may be nil to not change. If COMINT is t, then @@ -3507,6 +3513,11 @@ (mdw-define-face eshell-ls-directory (t :foreground "cyan" :weight bold)) (mdw-define-face eshell-ls-readonly (t nil)) (mdw-define-face eshell-ls-symlink (t :foreground "cyan")) +(defun mdw-eshell-hack () + (when mdw-preload-hacks + (setenv "LD_PRELOAD" nil))) +(add-hook 'eshell-mode-hook 'mdw-eshell-hack) + ;;;-------------------------------------------------------------------------- ;;; Messages-file mode. @@ -3861,6 +3872,18 @@ (defadvice term-exec (before program-args-list compile activate) (ad-set-arg 2 (car program)) (ad-set-arg 4 (cdr program)))))) +(defadvice term-exec-1 (around hack-environment compile activate) + "Hack the environment inherited by inferiors in the terminal." + (let ((process-environment process-environment)) + (setenv "LD_PRELOAD" nil) + ad-do-it)) + +(defadvice shell (around hack-environment compile activate) + "Hack the environment inherited by inferiors in the shell." + (let ((process-environment process-environment)) + (setenv "LD_PRELOAD" nil) + ad-do-it)) + (defun ssh (host) "Open a terminal containing an ssh session to the HOST." (interactive "sHost: ") -- [mdw]