chiark / gitweb /
el/dot-emacs.el: Remove `noip' from `LD_PRELOAD' list while running `man'.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 13 Apr 2020 14:16:56 +0000 (15:16 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 13 Apr 2020 14:16:56 +0000 (15:16 +0100)
Later versions of `man-db' install a `seccomp' filter to prevent stray
manpages from (among other stuff) doing network things.  This interacts
badly with `noip', which wants to fetch the list of network interfaces
at startup.  Since the `man-db' filter is strictly better than what
`noip' is doing, just turn off `noip' while running `man'.

el/dot-emacs.el

index d2b9dccef345a06cf94beef78b9e5aaf8ddf61bd..5bba5d7aee7c4c1014e3f35f57e5ae56264de4b7 100644 (file)
@@ -4440,6 +4440,41 @@ (defadvice gdb-set-window-buffer
   "Don't make windows dedicated.  Seriously."
   (set-window-dedicated-p (or window (selected-window)) nil))
 
+;;;--------------------------------------------------------------------------
+;;; Man pages.
+
+;; Turn off `noip' when running `man': it interferes with `man-db''s own
+;; seccomp(2)-based sandboxing, which is (in this case, at least) strictly
+;; better.
+(defadvice Man-getpage-in-background
+    (around mdw-inhibit-noip (topic) compile activate)
+  "Inhibit the `noip' preload hack when invoking `man'."
+  (let* ((old-preload (getenv "LD_PRELOAD"))
+        (preloads (save-match-data (split-string old-preload ":")))
+        (any nil)
+        (filtered nil))
+    (while preloads
+      (let ((item (pop preloads)))
+       (if (save-match-data
+             (string-match  "\\(/\\|^\\)noip\.so\\(:\\|$\\)" item))
+           (setq any t)
+         (push item filtered))))
+    (if any
+       (unwind-protect
+           (progn
+             (setenv "LD_PRELOAD"
+                     (and filtered
+                          (with-output-to-string
+                            (setq filtered (nreverse filtered))
+                            (let ((first t))
+                              (while filtered
+                                (if first (setq first nil)
+                                  (write-char ?:))
+                                (write-string (pop filtered)))))))
+             ad-do-it)
+         (setenv "LD_PRELOAD" old-preload))
+      ad-do-it)))
+
 ;;;--------------------------------------------------------------------------
 ;;; MPC configuration.