summaryrefslogtreecommitdiff
path: root/gnu/services/authentication.scm
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2021-02-14 12:57:32 +0100
committerLudovic Courtès <ludo@gnu.org>2021-03-10 18:01:47 +0100
commit520bac7ed00a949a0391ad680de65a1498105c2b (patch)
tree15d2267b31ca62c0ef8b201aa700726aa310fa34 /gnu/services/authentication.scm
parent1a1d0fe505da18c1f43996fb7eb3652e42250d0a (diff)
services: Prevent following symlinks during activation.
This addresses a potential security issue, where a compromised service could trick the activation code in changing the permissions, owner and group of arbitrary files. However, this patch is currently only a partial fix, due to a TOCTTOU (time-of-check to time-of-use) race, which can be fixed once guile has bindings to openat and friends. Fixes: <https://lists.gnu.org/archive/html/guix-devel/2021-01/msg00388.html> * gnu/build/activation.scm: new procedure 'mkdir-p/perms'. * gnu/services/authentication.scm (%nslcd-activation, nslcd-service-type): use new procedure. * gnu/services/cups.scm (%cups-activation): likewise. * gnu/services/dbus.scm (dbus-activation): likewise. * gnu/services/dns.scm (knot-activation): likewise. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/services/authentication.scm')
-rw-r--r--gnu/services/authentication.scm22
1 files changed, 13 insertions, 9 deletions
diff --git a/gnu/services/authentication.scm b/gnu/services/authentication.scm
index 73969a5a6df..d7efc48cd04 100644
--- a/gnu/services/authentication.scm
+++ b/gnu/services/authentication.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org> 2;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
3;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net> 3;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
4;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -31,6 +32,7 @@
31 #:use-module (guix gexp) 32 #:use-module (guix gexp)
32 #:use-module (guix records) 33 #:use-module (guix records)
33 #:use-module (guix packages) 34 #:use-module (guix packages)
35 #:use-module (guix modules)
34 #:use-module (ice-9 match) 36 #:use-module (ice-9 match)
35 #:use-module (srfi srfi-1) 37 #:use-module (srfi srfi-1)
36 #:use-module (srfi srfi-26) 38 #:use-module (srfi srfi-26)
@@ -521,6 +523,16 @@ password.")
521(define (pam-ldap-pam-services config) 523(define (pam-ldap-pam-services config)
522 (list (pam-ldap-pam-service config))) 524 (list (pam-ldap-pam-service config)))
523 525
526(define %nslcd-activation
527 (with-imported-modules (source-module-closure '((gnu build activation)))
528 #~(begin
529 (use-modules (gnu build activation))
530 (let ((rundir "/var/run/nslcd")
531 (user (getpwnam "nslcd")))
532 (mkdir-p/perms rundir user #o755)
533 (when (file-exists? "/etc/nslcd.conf")
534 (chmod "/etc/nslcd.conf" #o400))))))
535
524(define nslcd-service-type 536(define nslcd-service-type
525 (service-type 537 (service-type
526 (name 'nslcd) 538 (name 'nslcd)
@@ -531,15 +543,7 @@ password.")
531 (service-extension etc-service-type 543 (service-extension etc-service-type
532 nslcd-etc-service) 544 nslcd-etc-service)
533 (service-extension activation-service-type 545 (service-extension activation-service-type
534 (const #~(begin 546 (const %nslcd-activation))
535 (use-modules (guix build utils))
536 (let ((rundir "/var/run/nslcd")
537 (user (getpwnam "nslcd")))
538 (mkdir-p rundir)
539 (chown rundir (passwd:uid user) (passwd:gid user))
540 (chmod rundir #o755)
541 (when (file-exists? "/etc/nslcd.conf")
542 (chmod "/etc/nslcd.conf" #o400))))))
543 (service-extension pam-root-service-type 547 (service-extension pam-root-service-type
544 pam-ldap-pam-services) 548 pam-ldap-pam-services)
545 (service-extension nscd-service-type 549 (service-extension nscd-service-type