summary refs log tree commit diff
path: root/gnu/services/networking.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-10-18 23:12:35 +0200
committerLudovic Courtès <ludo@gnu.org>2019-10-18 23:22:25 +0200
commite52b953434b255f53e61125c7fd3653adcebdab8 (patch)
tree1c1d8c5f2c4c7048496cfb10b8b0558cb22f0f1b /gnu/services/networking.scm
parent4e37cf35c0dc2c5be192f9a9455bfe4f23599e57 (diff)
downloadguix-e52b953434b255f53e61125c7fd3653adcebdab8.tar.gz
services: network-manager: Create account for 'network-manager-openconnect'.
Previously, on startup, we'd see:

  dbus: Unknown username nm-openconnect in message bus configuration file

This fixes it.

* gnu/services/networking.scm (network-manager-accounts): New procedure.
(network-manager-service-type): Extend 'account-service-type'.
* gnu/packages/gnome.scm (network-manager-openconnect)[properties]: Add
'user-accounts'.
Diffstat (limited to 'gnu/services/networking.scm')
-rw-r--r--gnu/services/networking.scm30
1 files changed, 30 insertions, 0 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index f3925615bf..93d9b6a15e 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -51,6 +51,7 @@
   #:use-module (guix gexp)
   #:use-module (guix records)
   #:use-module (guix modules)
+  #:use-module (guix packages)
   #:use-module (guix deprecation)
   #:use-module (rnrs enums)
   #:use-module (srfi srfi-1)
@@ -1006,6 +1007,33 @@ and @command{wicd-curses} user interfaces."
   "Return a directory containing PLUGINS, the NM VPN plugins."
   (directory-union "network-manager-vpn-plugins" plugins))
 
+(define (network-manager-accounts config)
+  "Return the list of <user-account> and <user-group> for CONFIG."
+  (define nologin
+    (file-append shadow "/sbin/nologin"))
+
+  (define accounts
+    (append-map (lambda (package)
+                  (map (lambda (name)
+                         (user-account (system? #t)
+                                       (name name)
+                                       (group "network-manager")
+                                       (comment "NetworkManager helper")
+                                       (home-directory "/var/empty")
+                                       (create-home-directory? #f)
+                                       (shell nologin)))
+                       (or (assoc-ref (package-properties package)
+                                      'user-accounts)
+                           '())))
+                (network-manager-configuration-vpn-plugins config)))
+
+  (match accounts
+    (()
+     '())
+    (_
+     (cons (user-group (name "network-manager") (system? #t))
+           accounts))))
+
 (define network-manager-environment
   (match-lambda
     (($ <network-manager-configuration> network-manager dns vpn-plugins)
@@ -1055,6 +1083,8 @@ and @command{wicd-curses} user interfaces."
                                (compose
                                 list
                                 network-manager-configuration-network-manager))
+            (service-extension account-service-type
+                               network-manager-accounts)
             (service-extension activation-service-type
                                network-manager-activation)
             (service-extension session-environment-service-type