diff mbox series

[bug#42918,1/1] services: fcgiwrap: Create parent directory for unix socket.

Message ID 20200818182032.19689-1-arunisaac@systemreboot.net
State Accepted
Headers show
Series services: fcgiwrap: Create parent directory for unix socket. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job

Commit Message

Arun Isaac Aug. 18, 2020, 6:20 p.m. UTC
* gnu/services/web.scm (fcgiwrap-activation): New function.
(fcgiwrap-service-type): Extend activation-service-type with
fcgiwrap-activation.
---
 gnu/services/web.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Mathieu Othacehe Aug. 24, 2020, 9:25 a.m. UTC | #1
Hey Arun,

> * gnu/services/web.scm (fcgiwrap-activation): New function.
> (fcgiwrap-service-type): Extend activation-service-type with
> fcgiwrap-activation.

This looks fine, feel free to proceed!

Thanks,

Mathieu
Arun Isaac Aug. 26, 2020, 5:57 p.m. UTC | #2
Thanks for the review, pushed to master!
diff mbox series

Patch

diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 3b9f9e40be..d11a1c0545 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -12,6 +12,7 @@ 
 ;;; Copyright © 2019, 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -794,13 +795,29 @@  of index files."
 		      #:user #$user #:group #$group))
             (stop #~(make-kill-destructor)))))))
 
+(define fcgiwrap-activation
+  (match-lambda
+    (($ <fcgiwrap-configuration> package socket user group)
+     #~(begin
+         ;; When listening on a unix socket, create a parent directory for the
+         ;; socket with the correct permissions.
+         (when (string-prefix? "unix:" #$socket)
+           (let ((run-directory
+                  (dirname (substring #$socket (string-length "unix:")))))
+             (mkdir-p run-directory)
+             (chown run-directory
+                    (passwd:uid (getpw #$user))
+                    (group:gid (getgr #$group)))))))))
+
 (define fcgiwrap-service-type
   (service-type (name 'fcgiwrap)
                 (extensions
                  (list (service-extension shepherd-root-service-type
                                           fcgiwrap-shepherd-service)
 		       (service-extension account-service-type
-                                          fcgiwrap-accounts)))
+                                          fcgiwrap-accounts)
+                       (service-extension activation-service-type
+                                          fcgiwrap-activation)))
                 (default-value (fcgiwrap-configuration))))
 
 (define-record-type* <php-fpm-configuration> php-fpm-configuration