Subject: | Running a daemon with multiple group permissions in Starman using Net::Server.pm |
Date: | Fri, 04 May 2018 19:30:37 +1200 |
To: | bug-Net-Server [...] rt.cpan.org |
From: | Andrew Maguire <andrew.maguire [...] catalyst.net.nz> |
Hi,
We are trying to start a starman service on Debian Jessie & Stretch.
This uses --user and --group arguments but we want to start the service
with multiple groups and the variable user interface levels just fail to
handle this situation. The problem appears to be in the command line
processing in Net::Server.
TLDR;
The simple solution is a one line change in Net::Server::post_bind()
- } elsif ($prop->{'group'} =~ /^([\w-]+(?: [\w-]+)*)$/) {
$prop->{'group'} = eval { get_gid($1) };
+ } elsif ($prop->{'group'} =~ /^([\w-,]+(?: [\w-,]+)*)$/) {
$prop->{'group'} = eval { get_gid($1) };
Long version
------------
The Net::Server::Daemonize::get_gid() interface allows for parsing of a
string of gids that are both space and comma delimited.
The Net::Server command parsing explicitly prevents setting of arguments
with values that contain spaces, see process_args() line:
if ($args->[$i] =~ /^(?:--)?(\w+)(?:[=\ ](\S+))?$/
so trying to use
--group 'mygroup othergroup'
does not work. Although I have not tried it, the same parsing is used if
the configuration is read for a file instead of from command line
arguments.
In theory it should be valid to pecify the groups as a comma separated
list
--group 'mygroup,othergroup'
This would work except that commas are not treated as a delimiter in
Net::Server::post_bind() as described above.
Thanks
Andrew
Ps. Also Net::Server::Daemonize::daemonize() appears to have a bug with
starting a daemon with multiple groups but that interface is not used
here.
Name: Andrew Maguire
Email: andrew.maguire@catalyst.net.nz