[PATCH] gnu: php-fpm: Ensure no duplicate group.

  • Done
  • quality assurance status badge
Details
2 participants
  • Julien Lepiller
  • Leo Prikler
Owner
unassigned
Submitted by
Julien Lepiller
Severity
normal
J
J
Julien Lepiller wrote on 17 Jan 2021 17:00
(address . guix-patches@gnu.org)
20210117170000.718e6062@tachikoma.lepiller.eu
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.
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(-)

Toggle diff (40 lines)
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
L
L
Leo Prikler wrote on 17 Jan 2021 20:45
ef383c8cc40c511d7f3f51fc72176c65d0e5b9e1.camel@student.tugraz.at
Hi Julien,

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

Am Sonntag, den 17.01.2021, 17:00 +0100 schrieb Julien Lepiller:
Toggle quote (5 lines)
> 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
Closed
?