diff mbox series

[bug#45937] gnu: php-fpm: Ensure no duplicate group.

Message ID 20210117170000.718e6062@tachikoma.lepiller.eu
State Accepted
Headers show
Series [bug#45937] gnu: php-fpm: Ensure no duplicate group. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Julien Lepiller Jan. 17, 2021, 4 p.m. UTC
Hi Guix!

When updating my system, I noticed there was a duplicate php-fpm group.
The reason is that by default, the group is php-fpm, and the accounts
list contains php-fpm and the configured group. I'm not sure why, but
the hardcoded php-fpm group seems to be used by the user as a
supplementary group.

This patch only adds the php-fpm group when the configured group is not
already php-fpm. If you think it'd be better, we could also simply
remove the hard-coded php-fpm group and the supplementary group from
the php-fpm user.

Comments

Leo Prikler Jan. 17, 2021, 7:45 p.m. UTC | #1
Hi Julien,

I've pushed your patch with a small indentation fix.

Am Sonntag, den 17.01.2021, 17:00 +0100 schrieb Julien Lepiller:
> This patch only adds the php-fpm group when the configured group is
> not
> already php-fpm. If you think it'd be better, we could also simply
> remove the hard-coded php-fpm group and the supplementary group from
> the php-fpm user.
I'm not quite sure, but I think the use case here would be having a
www-admin group with full access to the entire directory structure and
some local users, who only have access to some directories as members
of the php-fpm group.  I might be wrong on that though, php-fpm users
please correct me if I am.

Regards,
Leo
diff mbox series

Patch

From d50e84c66d9cc9fa027035b9265e80ecab22aa00 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Sat, 16 Jan 2021 20:42:32 +0100
Subject: [PATCH] gnu: php-fpm: Ensure no duplicate group.

* gnu/services/web.scm (php-fpm-accounts): Ensure `php-fpm` group is not
duplicated.
---
 gnu/services/web.scm | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 855f4e649b..f8dc621614 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -922,19 +922,20 @@  of index files."
 (define php-fpm-accounts
   (match-lambda
     (($ <php-fpm-configuration> php socket user group socket-user socket-group _ _ _ _ _ _)
-     (list
-      (user-group (name "php-fpm") (system? #t))
-      (user-group
-       (name group)
-       (system? #t))
-      (user-account
-       (name user)
-       (group group)
-       (supplementary-groups '("php-fpm"))
-       (system? #t)
-       (comment "php-fpm daemon user")
-       (home-directory "/var/empty")
-       (shell (file-append shadow "/sbin/nologin")))))))
+     `(,@(if (equal? group "php-fpm")
+             '()
+             (list (user-group (name "php-fpm") (system? #t))))
+       ,(user-group
+         (name group)
+         (system? #t))
+       ,(user-account
+        (name user)
+        (group group)
+        (supplementary-groups '("php-fpm"))
+        (system? #t)
+        (comment "php-fpm daemon user")
+        (home-directory "/var/empty")
+        (shell (file-append shadow "/sbin/nologin")))))))
 
 (define (default-php-fpm-config socket user group socket-user socket-group
           pid-file log-file pm display-errors timezone workers-log-file)
-- 
2.30.0