Subject: [bug#65221] [PATCH 4/6] service: honor EXTRA-PORTS regardless of log-port and log-file.

From: ulfvonbelow <[email-masked]>
Date: Fri, 18 Aug 2023 15:22:37 -0500

EXTRA-PORTS is only honored when either LOG-PORT or LOG-FILE is passed.  I
have no idea why this is the case, it isn't documented anywhere, and it isn't
intuitive.

* modules/shepherd/service.scm (exec-command): Move preserve-ports call
  outside of condition.
---
 modules/shepherd/service.scm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 68993ac..e816cd1 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -1581,11 +1581,7 @@ false."
                                 #o640)
                      (fileno log-port))
                  1)
-           (dup2 1 2)
-
-           ;; Make EXTRA-PORTS available starting from file descriptor 3.
-           ;; This clears their FD_CLOEXEC flag.
-           (reconfigure-fds extra-ports 3))
+           (dup2 1 2))
 
          (lambda (key . args)
            (when log-file
@@ -1594,6 +1590,10 @@ false."
            (print-exception (current-error-port) #f key args)
            (primitive-exit 1))))
 
+     ;; Make EXTRA-PORTS available starting from file descriptor 3.
+     ;; This clears their FD_CLOEXEC flag.
+     (reconfigure-fds extra-ports 3)
+
      ;; setgid must be done *before* setuid, otherwise the user will
      ;; likely no longer have permissions to setgid.
      (when group
-- 
2.40.1