summary refs log tree commit diff
path: root/gnu/services/shepherd.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-11-18 10:58:58 +0100
committerLudovic Courtès <ludo@gnu.org>2020-11-18 11:13:49 +0100
commit37b98e8cca3244067071bc6e382b06861457a459 (patch)
treec85c955f098254a2770372f0471b4f2a1c88f3cf /gnu/services/shepherd.scm
parent5bc19300ee82093f9e20760dc5e305e12df12dd0 (diff)
downloadguix-37b98e8cca3244067071bc6e382b06861457a459.tar.gz
services: shepherd: Map all the invalid store characters to dash.
Fixes a regression introduced in
977eb5d023cfdf8e336f1896480eea9cef5c04e9 whereby file system services
would now have a different name.

* gnu/services/base.scm (file-system->shepherd-service-name): Revert
changes introduced in 977eb5d023cfdf8e336f1896480eea9cef5c04e9.
* gnu/services/shepherd.scm (%store-characters): New variable
(shepherd-service-file-name): Map all the characters outside
%STORE-CHARACTERS to #\-.
Diffstat (limited to 'gnu/services/shepherd.scm')
-rw-r--r--gnu/services/shepherd.scm13
1 files changed, 9 insertions, 4 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index e14ceca231..1faeb350df 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -224,16 +224,21 @@ which is not provided by any service")
 
   (for-each assert-satisfied-requirements services))
 
+(define %store-characters
+  ;; Valid store characters; see 'checkStoreName' in the daemon.
+  (string->char-set
+   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-._?="))
+
 (define (shepherd-service-file-name service)
   "Return the file name where the initialization code for SERVICE is to be
 stored."
   (let ((provisions (string-join (map symbol->string
                                       (shepherd-service-provision service)))))
     (string-append "shepherd-"
-                   (string-map (match-lambda
-                                 (#\/ #\-)
-                                 (#\  #\-)
-                                 (chr chr))
+                   (string-map (lambda (chr)
+                                 (if (char-set-contains? %store-characters chr)
+                                     chr
+                                     #\-))
                                provisions)
                    ".scm")))