GNU bug report logs -
#27323
[PATCH shepherd] Make sure that shepherd does not serve already-served sockets.
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27323 in the body.
You can then email your comments to 27323 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#27323
; Package
guix-patches
.
(Sun, 11 Jun 2017 02:38:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Danny Milosavljevic <dannym <at> scratchpost.org>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Sun, 11 Jun 2017 02:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* modules/shepherd.scm (server-present?): New variable.
(main): Adapt.
---
modules/shepherd.scm | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index dd8a076..4998e09 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -32,10 +32,21 @@
#:use-module (shepherd runlevel)
#:use-module (shepherd args)
#:use-module (shepherd comm)
+ #:use-module (rnrs io ports)
#:export (main))
+(define (server-present? file-name)
+ "Open a socket at FILE-NAME, and connect to the server, if any.
+Return #t if that worked."
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (let ((sock (socket PF_UNIX SOCK_STREAM 0)))
+ (call-with-port sock
+ (lambda (sock)
+ (let ((address (make-socket-address AF_UNIX file-name)))
+ (false-if-exception (connect sock address))))))))
+
(define (open-server-socket file-name)
"Open a socket at FILE-NAME, and listen for connections there."
(with-fluids ((%default-port-encoding "UTF-8"))
@@ -132,8 +143,12 @@
;; we use no socket.
#f)))))))
;; We do this early so that we can abort early if necessary.
- (and socket-file
- (verify-dir (dirname socket-file) #:secure? secure))
+ (if socket-file
+ (begin
+ (verify-dir (dirname socket-file) #:secure? secure)
+ (if (server-present? socket-file)
+ (exit 0)))) ; There's already a shepherd instance running.
+
;; Enable logging as first action.
(start-logging logfile)
Information forwarded
to
guix-patches <at> gnu.org
:
bug#27323
; Package
guix-patches
.
(Wed, 14 Jun 2017 07:50:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 27323 <at> debbugs.gnu.org (full text, mbox):
Danny Milosavljevic (2):
Use XDG_RUNTIME_DIR for the shepherd socket.
Make sure that shepherd does not serve already-served sockets.
modules/shepherd.scm | 1 -
modules/shepherd/support.scm | 7 ++++++-
2 files changed, 6 insertions(+), 2 deletions(-)
Information forwarded
to
guix-patches <at> gnu.org
:
bug#27323
; Package
guix-patches
.
(Wed, 14 Jun 2017 07:50:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 27323 <at> debbugs.gnu.org (full text, mbox):
---
modules/shepherd/support.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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"))
"/shepherd"))
+(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))
%system-socket-dir
- (string-append %user-config-dir "/run")))
+ (string-append %user-runtime-dir "/shepherd")))
;; Unix domain socket for receiving commands in shepherd.
(define default-socket-file
Information forwarded
to
guix-patches <at> gnu.org
:
bug#27323
; Package
guix-patches
.
(Wed, 14 Jun 2017 07:50:03 GMT)
Full text and
rfc822 format available.
Message #14 received at 27323 <at> debbugs.gnu.org (full text, mbox):
---
modules/shepherd.scm | 1 -
1 file changed, 1 deletion(-)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index dd8a076..f7c169d 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -41,7 +41,6 @@
(with-fluids ((%default-port-encoding "UTF-8"))
(let ((sock (socket PF_UNIX SOCK_STREAM 0))
(address (make-socket-address AF_UNIX file-name)))
- (false-if-exception (delete-file file-name))
(bind sock address)
(listen sock 10)
sock)))
Reply sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
You have taken responsibility.
(Fri, 16 Jun 2017 08:20:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Danny Milosavljevic <dannym <at> scratchpost.org>
:
bug acknowledged by developer.
(Fri, 16 Jun 2017 08:20:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 27323-done <at> debbugs.gnu.org (full text, mbox):
Hi,
Danny Milosavljevic <dannym <at> scratchpost.org> skribis:
> Danny Milosavljevic (2):
> Use XDG_RUNTIME_DIR for the shepherd socket.
> Make sure that shepherd does not serve already-served sockets.
>
> modules/shepherd.scm | 1 -
> modules/shepherd/support.scm | 7 ++++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
Cool, applied both with a commit log and doc/test adjustments.
Thanks!
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 14 Jul 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 340 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.