guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 23/24: shepherd: Do not change to the client directory when e


From: Ludovic Courtès
Subject: [shepherd] 23/24: shepherd: Do not change to the client directory when executing a command.
Date: Mon, 28 Mar 2022 17:24:48 -0400 (EDT)

civodul pushed a commit to branch wip-fibers
in repository shepherd.

commit 7b1832557bc67cf77701bc2e2b5ff83bf7bbd336
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 28 22:08:20 2022 +0200

    shepherd: Do not change to the client directory when executing a command.
    
    This mechanism was mostly useless and potentially unsafe.
    
    * modules/shepherd.scm (process-command): Remove
    'with-directory-excursion' use.
    * tests/basic.sh: Adjust test to pass an absolute file name to 'herd
    load root'.
---
 modules/shepherd.scm | 20 ++++++++++----------
 tests/basic.sh       |  5 ++---
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 16c242e..63a0a2c 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -445,7 +445,8 @@ already ~a threads running, disabling 'signalfd' support")
   "Interpret COMMAND, a command sent by the user, represented as a
 <shepherd-command> object.  Send the reply to PORT."
   (match command
-    (($ <shepherd-command> the-action service-symbol (args ...) dir)
+    (($ <shepherd-command> the-action service-symbol (args ...)
+                           directory)             ;ignored
 
      ;; We have to catch `quit' so that we can send the terminator
      ;; line to herd before we actually quit.
@@ -478,15 +479,14 @@ already ~a threads running, disabling 'signalfd' support")
                                    port)))
 
              (define result
-               (with-directory-excursion dir
-                 (case the-action
-                   ((start) (apply start service-symbol args))
-                   ((stop) (apply stop service-symbol args))
-                   ((enforce) (apply enforce service-symbol args))
-
-                   ;; Actions which have the semantics of `action' are
-                   ;; handled there.
-                   (else (apply action service-symbol the-action args)))))
+               (case the-action
+                 ((start) (apply start service-symbol args))
+                 ((stop) (apply stop service-symbol args))
+                 ((enforce) (apply enforce service-symbol args))
+
+                 ;; Actions which have the semantics of `action' are
+                 ;; handled there.
+                 (else (apply action service-symbol the-action args))))
 
              (write-reply (command-reply command result #f (get-messages))
                           port))))
diff --git a/tests/basic.sh b/tests/basic.sh
index 5ef1fb0..10bace8 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test basic communication capabilities.
-# Copyright © 2013, 2014, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2013-2014, 2016-2019, 2022 Ludovic Courtès <ludo@gnu.org>
 # Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 # Copyright © 2014 Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
 #
@@ -183,8 +183,7 @@ EOF
 if $herd status test-loaded
 then false; else true; fi
 
-# Pass a relative file name and makes sure it's properly resolved.
-(cd "$confdir" && herd -s "../$socket" load root "some-conf.scm")
+$herd load root "$confdir/some-conf.scm"
 rm "$confdir/some-conf.scm"
 
 # The new service should be loaded now.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]