[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 01/06: Canonicalize the running value to valid read syntax.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 01/06: Canonicalize the running value to valid read syntax. |
Date: |
Wed, 27 Jan 2016 10:24:11 +0000 |
civodul pushed a commit to branch master
in repository shepherd.
commit e1eb5e23399f305118e24578c69683a7103dad77
Author: Ludovic Courtès <address@hidden>
Date: Wed Jan 27 09:55:12 2016 +0100
Canonicalize the running value to valid read syntax.
* modules/shepherd/service.scm (service->sexp): Pass the 'running' value
through 'result->sexp'.
* tests/basic.sh: Add test.
---
modules/shepherd/service.scm | 6 ++++--
tests/basic.sh | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 1b37d96..31f6684 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -486,9 +486,11 @@ clients."
(respawn? ,(respawn? service))
(docstring ,(slot-ref service 'docstring))
- ;; Status.
+ ;; Status. Use 'result->sexp' for the running value to make sure
+ ;; that whole thing is valid read syntax; we do not want things
+ ;; like #<undefined> to be sent to the client.
(enabled? ,(enabled? service))
- (running ,(slot-ref service 'running))
+ (running ,(result->sexp (slot-ref service 'running)))
(last-respawns ,(slot-ref service 'last-respawns))))
(define-method (result->sexp (service <service>))
diff --git a/tests/basic.sh b/tests/basic.sh
index 8e611d1..ca49109 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -145,6 +145,22 @@ $herd status test-loaded | grep stopped
$herd start test-loaded
$herd status test-loaded | grep -i 'running.*42'
$herd stop test-loaded
+$herd unload root test-loaded
+
+# Load a service whose running value does not have a valid read syntax, and
+# make sure that the running value is clamped before being sent over the wire.
+cat > "$confdir/some-conf.scm" <<EOF
+(register-services
+ (make <service>
+ #:provides '(test-loaded)
+ #:start (const (if #f #f)) ;#<undefined>
+ #:stop (const #f)))
+EOF
+
+$herd load root "$confdir/some-conf.scm"
+$herd start test-loaded
+$herd status test-loaded | grep -i "running.*#<unspecified>"
+$herd stop test-loaded
# Unload everything and make sure only 'root' is left.
$herd unload root all
- [shepherd] branch master updated (88c6a20 -> 83567c4), Ludovic Courtès, 2016/01/27
- [shepherd] 06/06: Default system-wide config file is now /etc/shepherd.scm., Ludovic Courtès, 2016/01/27
- [shepherd] 01/06: Canonicalize the running value to valid read syntax.,
Ludovic Courtès <=
- [shepherd] 03/06: Move commands to (shepherd scripts xyz)., Ludovic Courtès, 2016/01/27
- [shepherd] 04/06: build: Install Guile modules to the usual place., Ludovic Courtès, 2016/01/27
- [shepherd] 02/06: Add the list of conflicting services to the status sexp., Ludovic Courtès, 2016/01/27
- [shepherd] 05/06: build: Build man pages., Ludovic Courtès, 2016/01/27