Bug 41458: Pass a valid GID to Net::Server for SIP

When starting SIP, Koha passes an incorrect value to the
Net::Server "group" parameter, which can generate an
error in the logs":
  Couldn't become gid "<uid>": Operation not permitted

This change ensures that a valid numeric GID is passed instead.

Test plan:
1. Enter KTD shell.
2. To reproduce the error: sudo groupmod -g 8001 kohadev-koha
3. Restart SIP: sudo koha-sip --restart kohadev
4. Check SIP logs:
     /var/log/koha/kohadev/sip-output.log
5. Observe the error:
     Couldn't become gid "<uid>": Operation not permitted
6. Apply this patch.
7. Repeat steps 2 to 4.
8. Verify that the "Couldn't become gid" error is no longer logged.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Slava Shishkin 2025-12-16 19:27:38 +02:00 committed by Lucas Gass
parent 52d538312e
commit b16ff5a8a0
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 5 additions and 1 deletions

View File

@ -87,7 +87,11 @@ if ( defined( $config->{'server-params'} ) ) {
# Add user and group to prevent warn from Net::Server.
push @params, 'user=' . $>;
push @params, 'group=' . $>;
# $) can contain supplementary groups like "1010 1010" -> Net::Server tries setgroups() and fails.
my ($egid) = split /\s+/, $);
$egid ||= $(; # fallback to real gid just in case
push @params, 'group=' . $egid;
#
# This is the main event.