summaryrefslogtreecommitdiff
path: root/gnu/services/xorg.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-02-28 22:44:31 +0100
committerLudovic Courtès <ludo@gnu.org>2015-03-01 00:25:30 +0100
commitec4a4c46efaf2e7373f331654640f1321c0f2e62 (patch)
tree450695f90a647658287e8df866b662e499098fbd /gnu/services/xorg.scm
parent74bbf894953c3e7b0123f96b6d2442e4ca4dff8c (diff)
downloadpatches-ec4a4c46efaf2e7373f331654640f1321c0f2e62.tar
patches-ec4a4c46efaf2e7373f331654640f1321c0f2e62.tar.gz
services: xorg: Fix file descriptor leak from SLiM/xinitrc.
Previously processes started from the window manager would have a couple of leaked file descriptors: writable /var/log/slim.log and readable /gnu/store/…-xinitrc. * gnu/services/xorg.scm (xinitrc)[builder]: Add 'close-all-fdes'. Use it in 'exec-from-login-shell'.
Diffstat (limited to 'gnu/services/xorg.scm')
-rw-r--r--gnu/services/xorg.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 69a89584e0..bc1774840b 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -155,6 +155,13 @@ which should be passed to this script as the first argument. If not, the
#~(begin
(use-modules (ice-9 match))
+ (define (close-all-fdes)
+ ;; Close all the open file descriptors.
+ (let loop ((fd 0))
+ (when (< fd 4096) ;FIXME: use sysconf + _SC_OPEN_MAX
+ (false-if-exception (close-fdes fd))
+ (loop (+ 1 fd)))))
+
(define (exec-from-login-shell command . args)
;; Run COMMAND from a login shell so that it gets to see the same
;; environment variables that one gets when logging in on a tty, for
@@ -163,6 +170,11 @@ which should be passed to this script as the first argument. If not, the
(shell (passwd:shell pw))
(st (stat command #f)))
(when (and st (not (zero? (logand (stat:mode st) #o100))))
+ ;; Close any open file descriptors. This is all the more
+ ;; important that SLiM itself exec's us directly without closing
+ ;; its own file descriptors!
+ (close-all-fdes)
+
;; The '--login' option is supported at least by Bash and zsh.
(execl shell shell "--login" "-c"
(string-join (cons command args))))))