[Top][All Lists]

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

[shepherd] 02/02: Use XDG_RUNTIME_DIR for the shepherd socket.

From: Ludovic Courtès
Subject: [shepherd] 02/02: Use XDG_RUNTIME_DIR for the shepherd socket.
Date: Fri, 16 Jun 2017 04:19:09 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit 11f1ae22854b9a165db5926ec92b98a8ce540654
Author: Danny Milosavljevic <address@hidden>
Date:   Wed Jun 14 09:49:01 2017 +0200

    Use XDG_RUNTIME_DIR for the shepherd socket.
    * modules/shepherd/support.scm (%user-runtime-dir): New variable.
    (default-socket-dir): Use it.
    * doc/shepherd.texi (Invoking shepherd): Document it.
    Co-authored-by: Ludovic Courtès <address@hidden>
 doc/shepherd.texi            | 11 ++++++++---
 modules/shepherd/support.scm |  7 ++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index e90c3b2..810336c 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -419,9 +419,14 @@ to the standard output if @var{file} is omitted.
 @item -s @var{file}
 @itemx address@hidden
 @cindex socket special file
-Receive further commands on the socket special file @var{file}.  If
-this option is not specified, @address@hidden/run/shepherd/socket} is
address@hidden XDG_RUNTIME_DIR
+Receive further commands on the socket special file @var{file}.  If this
+option is not specified, @address@hidden/run/shepherd/socket} is
+taken when running as @code{root}; when running as an unprivileged
+user, @command{shepherd} listens to @file{/run/user/@var{uid}/shepherd},
+where @var{uid} is the user's numerical ID, or to
address@hidden/shepherd} when the @code{XDG_RUNTIME_DIR}
+environment variable is defined.
 If @code{-} is specified as file name, commands will be read from
 standard input, one per line, as would be passed on a @command{herd}
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index e50de74..ea98b5f 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -251,6 +251,11 @@ There is NO WARRANTY, to the extent permitted by law.")))
                      (string-append user-homedir "/.config"))
+(define %user-runtime-dir
+  ;; Default runtime directory if shepherd is run as a normal user.
+  (string-append (or (getenv "XDG_RUNTIME_DIR")
+                     (format #f "/run/user/~s" (getuid)))))
 (define (make-bare-init-file target)
   "Return #t if a bare init file was created at TARGET; #f otherwise.
@@ -301,7 +306,7 @@ create a template configuration file if non exists."
 (define default-socket-dir
   (if (zero? (getuid))
-      (string-append %user-config-dir "/run")))
+      (string-append %user-runtime-dir "/shepherd")))
 ;; Unix domain socket for receiving commands in shepherd.
 (define default-socket-file

reply via email to

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