From 64643b90ab490eef34226c2f01de9f782de7333f Mon Sep 17 00:00:00 2001 From: 宋文武 Date: Sun, 18 Oct 2015 14:18:52 +0800 Subject: services: dbus: Build '/etc/dbus-1/system-local.conf'. * gnu/services/dbus.scm (dbus-etc-files): New procedure. (dbus-dmd-service): Remove the use of '--config-file'. (dbus-configuration-directory): Adjust accordingly. (dbus-root-service-type): Add extension of ETC-SERVICE-TYPE. --- gnu/services/dbus.scm | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm index e4ecd961c5..1fa910af56 100644 --- a/gnu/services/dbus.scm +++ b/gnu/services/dbus.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès +;;; Copyright © 2015 Sou Bunnbu ;;; ;;; This file is part of GNU Guix. ;;; @@ -41,9 +42,9 @@ (services dbus-configuration-services ;list of (default '()))) -(define (dbus-configuration-directory dbus services) - "Return a configuration directory for @var{dbus} that includes the -@code{etc/dbus-1/system.d} directories of each package listed in +(define (dbus-configuration-directory services) + "Return a directory contains the @code{system-local.conf} file for DBUS that +includes the @code{etc/dbus-1/system.d} directories of each package listed in @var{services}." (define build #~(begin @@ -65,13 +66,6 @@ services))) (mkdir #$output) - (copy-file (string-append #$dbus "/etc/dbus-1/system.conf") - (string-append #$output "/system.conf")) - - ;; The default 'system.conf' has an clause for - ;; 'system.d', so create it. - (mkdir (string-append #$output "/system.d")) - ;; 'system-local.conf' is automatically included by the default ;; 'system.conf', so this is where we stuff our own things. (call-with-output-file (string-append #$output "/system-local.conf") @@ -81,6 +75,12 @@ (computed-file "dbus-configuration" build)) +(define (dbus-etc-files config) + "Return a list of FILES for @var{etc-service-type} to build the +@code{/etc/dbus-1} directory." + (list `("dbus-1" ,(dbus-configuration-directory + (dbus-configuration-services config))))) + (define %dbus-accounts ;; Accounts used by the system bus. (list (user-group (name "messagebus") (system? #t)) @@ -118,20 +118,15 @@ (execl prog))) (waitpid pid))))))) -(define dbus-dmd-service - (match-lambda - (($ dbus services) - (let ((conf (dbus-configuration-directory dbus services))) - (list (dmd-service - (documentation "Run the D-Bus system daemon.") - (provision '(dbus-system)) - (requirement '(user-processes)) - (start #~(make-forkexec-constructor - (list (string-append #$dbus "/bin/dbus-daemon") - "--nofork" - (string-append "--config-file=" #$conf - "/system.conf")))) - (stop #~(make-kill-destructor)))))))) +(define (dbus-dmd-service config) + (list (dmd-service + (documentation "Run the D-Bus system daemon.") + (provision '(dbus-system)) + (requirement '(user-processes)) + (start #~(make-forkexec-constructor + (list (string-append #$dbus "/bin/dbus-daemon") + "--nofork" "--system"))) + (stop #~(make-kill-destructor))))) (define dbus-root-service-type (service-type (name 'dbus) @@ -140,6 +135,8 @@ dbus-dmd-service) (service-extension activation-service-type dbus-activation) + (service-extension etc-service-type + dbus-etc-files) (service-extension account-service-type (const %dbus-accounts)))) -- cgit v1.2.3 From 4a663ca4e8b5ded9a3d92870fba8f2ebde22d75a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 21 Oct 2015 23:37:02 +0200 Subject: services: dbus: Honor the config's dbus package. * gnu/services/dbus.scm (dbus-dmd-service): Rewrite using 'match-lambda' so that the config's dbus package is used. Fixes a regression introduced in 64643b9. --- gnu/services/dbus.scm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm index 1fa910af56..1d504a8309 100644 --- a/gnu/services/dbus.scm +++ b/gnu/services/dbus.scm @@ -118,15 +118,17 @@ includes the @code{etc/dbus-1/system.d} directories of each package listed in (execl prog))) (waitpid pid))))))) -(define (dbus-dmd-service config) - (list (dmd-service - (documentation "Run the D-Bus system daemon.") - (provision '(dbus-system)) - (requirement '(user-processes)) - (start #~(make-forkexec-constructor - (list (string-append #$dbus "/bin/dbus-daemon") - "--nofork" "--system"))) - (stop #~(make-kill-destructor))))) +(define dbus-dmd-service + (match-lambda + (($ dbus) + (list (dmd-service + (documentation "Run the D-Bus system daemon.") + (provision '(dbus-system)) + (requirement '(user-processes)) + (start #~(make-forkexec-constructor + (list (string-append #$dbus "/bin/dbus-daemon") + "--nofork" "--system"))) + (stop #~(make-kill-destructor))))))) (define dbus-root-service-type (service-type (name 'dbus) -- cgit v1.2.3 From cde0402169cd93497084664c8d8d399808a1ea82 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 22 Oct 2015 00:35:10 +0200 Subject: services: dbus: Support service activation. * gnu/services/dbus.scm (system-service-directory): New procedure. (dbus-configuration-directory)[services->sxml]: Add /etc/dbus-1/system-services tag, and remove the per-service "/share/dbus-1/system-services" tag. Symlink OUTPUT/system-services. (dbus-setuid-programs): New procedure. (dbus-root-service-type): Extend SETUID-PROGRAM-SERVICE-TYPE. (dbus-service): Default to DBUS/ACTIVATION. --- gnu/services/dbus.scm | 66 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm index 1d504a8309..9b0d198683 100644 --- a/gnu/services/dbus.scm +++ b/gnu/services/dbus.scm @@ -21,7 +21,7 @@ #:use-module (gnu services) #:use-module (gnu services dmd) #:use-module (gnu system shadow) - #:use-module (gnu packages glib) + #:use-module ((gnu packages glib) #:select (dbus/activation)) #:use-module (gnu packages admin) #:use-module (guix gexp) #:use-module (guix records) @@ -38,10 +38,35 @@ dbus-configuration make-dbus-configuration dbus-configuration? (dbus dbus-configuration-dbus ; - (default dbus)) + (default dbus/activation)) (services dbus-configuration-services ;list of (default '()))) +(define (system-service-directory services) + "Return the system service directory, containing @code{.service} files for +all the services that may be activated by the daemon." + (computed-file "dbus-system-services" + #~(begin + (use-modules (guix build utils) + (srfi srfi-1)) + + (define files + (append-map (lambda (service) + (find-files (string-append + service + "/share/dbus-1/system-services") + "\\.service$")) + (list #$@services))) + + (mkdir #$output) + (for-each (lambda (file) + (symlink file + (string-append #$output "/" + (basename file)))) + files) + #t) + #:modules '((guix build utils)))) + (define (dbus-configuration-directory services) "Return a directory contains the @code{system-local.conf} file for DBUS that includes the @code{etc/dbus-1/system.d} directories of each package listed in @@ -54,18 +79,28 @@ includes the @code{etc/dbus-1/system.d} directories of each package listed in (define (services->sxml services) ;; Return the SXML 'includedir' clauses for DIRS. `(busconfig + (servicehelper "/run/setuid-programs/dbus-daemon-launch-helper") + + ;; First, the '.service' files of services subject to activation. + ;; We use a fixed location under /etc because the setuid helper + ;; looks for them in that location and nowhere else. See + ;; . + (servicedir "/etc/dbus-1/system-services") + ,@(append-map (lambda (dir) `((includedir ,(string-append dir "/etc/dbus-1/system.d")) - (servicedir ;for '.service' files - ,(string-append dir "/share/dbus-1/services")) - (servicedir ;likewise, for auto-activation - ,(string-append - dir - "/share/dbus-1/system-services")))) + (servicedir ;for '.service' files + ,(string-append dir "/share/dbus-1/services")))) services))) (mkdir #$output) + + ;; Provide /etc/dbus-1/system-services, which is where the setuid + ;; helper looks for system service files. + (symlink #$(system-service-directory services) + (string-append #$output "/system-services")) + ;; 'system-local.conf' is automatically included by the default ;; 'system.conf', so this is where we stuff our own things. (call-with-output-file (string-append #$output "/system-local.conf") @@ -92,6 +127,12 @@ includes the @code{etc/dbus-1/system.d} directories of each package listed in (home-directory "/var/run/dbus") (shell #~(string-append #$shadow "/sbin/nologin"))))) +(define dbus-setuid-programs + ;; Return the file name of the setuid program that we need. + (match-lambda + (($ dbus services) + (list #~(string-append #$dbus "/libexec/dbus-daemon-launch-helper"))))) + (define (dbus-activation config) "Return an activation gexp for D-Bus using @var{config}." #~(begin @@ -140,13 +181,12 @@ includes the @code{etc/dbus-1/system.d} directories of each package listed in (service-extension etc-service-type dbus-etc-files) (service-extension account-service-type - (const %dbus-accounts)))) + (const %dbus-accounts)) + (service-extension setuid-program-service-type + dbus-setuid-programs))) ;; Extensions consist of lists of packages (representing D-Bus ;; services) that we just concatenate. - ;; - ;; FIXME: We need 'dbus-daemon-launch-helper' to be - ;; setuid-root for auto-activation to work. (compose concatenate) ;; The service's parameters field is extended by augmenting @@ -158,7 +198,7 @@ includes the @code{etc/dbus-1/system.d} directories of each package listed in (append (dbus-configuration-services config) services))))))) -(define* (dbus-service #:key (dbus dbus) (services '())) +(define* (dbus-service #:key (dbus dbus/activation) (services '())) "Return a service that runs the \"system bus\", using @var{dbus}, with support for @var{services}. -- cgit v1.2.3 From 26909789d06b1e006ff45980aac59d3faa31436e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 22 Oct 2015 00:42:33 +0200 Subject: services: Rely on D-Bus activation for colord, geoclue, and polkit. * gnu/services/desktop.scm (colord-dmd-service): Remove. (colord-service-type): Adjust accordingly. (geoclue-dmd-service): Remove. (geoclue-service-type): Adjust accordingly. (polkit-dmd-service): Remove. (polkit-service-type): Adjust accordingly. --- gnu/services/desktop.scm | 50 +++--------------------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 69edc6d9bb..87d3eaa1b0 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -245,17 +245,6 @@ levels, with the given configuration settings. It implements the (home-directory "/var/empty") (shell #~(string-append #$shadow "/sbin/nologin"))))) -(define (colord-dmd-service colord) - "Return a dmd service for COLORD." - ;; TODO: Remove when D-Bus activation works. - (list (dmd-service - (documentation "Run the colord color management service.") - (provision '(colord-daemon)) - (requirement '(dbus-system udev)) - (start #~(make-forkexec-constructor - (list (string-append #$colord "/libexec/colord")))) - (stop #~(make-kill-destructor))))) - (define colord-service-type (service-type (name 'colord) (extensions @@ -263,8 +252,6 @@ levels, with the given configuration settings. It implements the (const %colord-accounts)) (service-extension activation-service-type (const %colord-activation)) - (service-extension dmd-root-service-type - colord-dmd-service) ;; Colord is a D-Bus service that dbus-daemon can ;; activate. @@ -343,23 +330,6 @@ users are allowed." "GEOCLUE_CONFIG_FILE" (geoclue-configuration-file config)))) -(define (geoclue-dmd-service config) - "Return a GeoClue dmd service for CONFIG." - ;; TODO: Remove when D-Bus activation works. - (let ((geoclue (geoclue-configuration-geoclue config)) - (config (geoclue-configuration-file config))) - (list (dmd-service - (documentation "Run the GeoClue location service.") - (provision '(geoclue-daemon)) - (requirement '(dbus-system)) - - (start #~(make-forkexec-constructor - (list (string-append #$geoclue "/libexec/geoclue")) - #:user "geoclue" - #:environment-variables - (list (string-append "GEOCLUE_CONFIG_FILE=" #$config)))) - (stop #~(make-kill-destructor)))))) - (define %geoclue-accounts (list (user-group (name "geoclue") (system? #t)) (user-account @@ -375,8 +345,6 @@ users are allowed." (extensions (list (service-extension dbus-root-service-type geoclue-dbus-service) - (service-extension dmd-root-service-type - geoclue-dmd-service) (service-extension account-service-type (const %geoclue-accounts)))))) @@ -426,18 +394,6 @@ site} for more information." (define %polkit-pam-services (list (unix-pam-service "polkitd"))) -(define (polkit-dmd-service polkit) - "Return the for POLKIT." - ;; TODO: Remove when D-Bus activation works. - (list (dmd-service - (documentation "Run the polkit privilege management service.") - (provision '(polkit-daemon)) - (requirement '(dbus-system)) - - (start #~(make-forkexec-constructor - (list (string-append #$polkit "/lib/polkit-1/polkitd")))) - (stop #~(make-kill-destructor))))) - (define polkit-service-type ;; TODO: Make it extensible so it can collect policy files from other ;; services. @@ -448,9 +404,7 @@ site} for more information." (service-extension pam-root-service-type (const %polkit-pam-services)) (service-extension dbus-root-service-type - list) - (service-extension dmd-root-service-type - polkit-dmd-service))))) + list))))) (define* (polkit-service #:key (polkit polkit)) "Return a service that runs the @command{polkit} privilege management @@ -601,6 +555,8 @@ the system if the user is logged in locally." (define (elogind-dmd-service config) "Return a dmd service for elogind, using @var{config}." + ;; TODO: We could probably rely on service activation but the '.service' + ;; file currently contains an erroneous 'Exec' line. (let ((config-file (elogind-configuration-file config)) (elogind (elogind-package config))) (list (dmd-service -- cgit v1.2.3