Skip Menu |

This queue is for tickets about the Net-Daemon CPAN distribution.

Report information
The Basics
Id: 4323
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Net-Daemon

People
Owner: MNOONING [...] cpan.org
Requestors: rgreab [...] fx.ro
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: incorrect testing of values returned by getgrnam and getpwnam
Net::Daemon dies with an error when I try to run my server as root: $ perl -Mblib -MNet::Daemon -we 'Net::Daemon->new({ user => "root", group => "root", pidfile => "none", localport => 1034 })->Bind' Using /home/test/.cpan/build/Net-Daemon-0.37/blib Cannot determine gid of root: at /home/test/.cpan/build/Net-Daemon-0.37/blib/lib/Net/Daemon.pm line 569. at /home/test/.cpan/build/Net-Daemon-0.37/blib/lib/Net/Daemon/Log.pm line 130. The test "if (my $gid = getgrnam($group))" needs to be changed to "if (defined(my $gid = getgrnam($group)))" to make it work when user or group is given by name and its ID is zero.
--- lib/Net/Daemon.pm.orig Tue Aug 20 21:44:06 2002 +++ lib/Net/Daemon.pm Fri Nov 7 17:11:34 2003 @@ -563,7 +563,7 @@ $self->Debug("Changing GID to $group"); my $gid; if ($group !~ /^\d+$/) { - if (my $gid = getgrnam($group)) { + if (defined(my $gid = getgrnam($group))) { $group = $gid; } else { $self->Fatal("Cannot determine gid of $group: $!"); @@ -575,7 +575,7 @@ $self->Debug("Changing UID to $user"); my $uid; if ($user !~ /^\d+$/) { - if (my $uid = getpwnam($user)) { + if (defined(my $uid = getpwnam($user))) { $user = $uid; } else { $self->Fatal("Cannot determine uid of $user: $!");
Thanks, patch applied in 0.38. (Although I still wonder why one should explicitly specify UID 0 ... :-)
This bug is years old. It has not been reported or commented upon since then, and the revision is now up to 0.41. I cannot help but think that the issue has been resolved. Revision 0.41 was just submitted today. If the issue has not been resolved, hopefully the CPAN testers will flag it.