Skip Menu |

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

Report information
The Basics
Id: 118451
Status: resolved
Priority: 0/
Queue: Net-Ping

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
SREZIC [...] cpan.org
Cc: PLICEASE [...] cpan.org
AdminCc:

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



Subject: Test hangs waiting for root password
I installed perl 5.25.6 under perlbrew today, and Net::Ping was upgraded from 2.51 to 2.53. The tests hung with a "Password:" prompt until I came to the console and ^C'd out of it. This looks to be the culprit: https://metacpan.org/source/RURBAN/Net-Ping-2.53//t/500_ping_icmp.t#L18
I think the problem is here in 500_ping_icmp.t: if (!Net::Ping::_isroot()) { my $file = __FILE__; diag 'This optional test may prompt for your sudo password.'; if (system("sudo \"$^X\" -Mblib $file") == 0) { exit; } else { plan skip_all => 'no sudo/failed'; } } I don't like random code trying to sudo. Perhaps this should be an "author only" test?
On Wed Oct 26 08:59:06 2016, NHORNE wrote: Show quoted text
> I think the problem is here in 500_ping_icmp.t: > > if (!Net::Ping::_isroot()) { > my $file = __FILE__; > diag 'This optional test may prompt for your sudo password.'; > if (system("sudo \"$^X\" -Mblib $file") == 0) { > exit; > } else { > plan skip_all => 'no sudo/failed'; > } > } > > I don't like random code trying to sudo. Perhaps this should be an > "author only" test?
Yes, I don't like it neither. But it caught a longstanding bug, because nobody so far ever executed that function, because nobody apparently tested that as root. So either add a timeout or change it to AUTHOR_TESTING only. Catch is, I never run AUTHOR_TESTING in perl core, so I would never catch that. -- Reini Urban
On 2016-10-27 06:53:25, RURBAN wrote: Show quoted text
> On Wed Oct 26 08:59:06 2016, NHORNE wrote:
> > I think the problem is here in 500_ping_icmp.t: > > > > if (!Net::Ping::_isroot()) { > > my $file = __FILE__; > > diag 'This optional test may prompt for your sudo password.'; > > if (system("sudo \"$^X\" -Mblib $file") == 0) { > > exit; > > } else { > > plan skip_all => 'no sudo/failed'; > > } > > } > > > > I don't like random code trying to sudo. Perhaps this should be an > > "author only" test?
> > Yes, I don't like it neither. But it caught a longstanding bug, > because nobody so far ever executed that function, because nobody > apparently tested that as root. > So either add a timeout or change it to AUTHOR_TESTING only. > Catch is, I never run AUTHOR_TESTING in perl core, so I would never > catch that.
So check $ENV{PERL_CORE} || $ENV{AUTHOR_TESTING} then? But hanging on a password prompt while building perl core would be just as bad. You can change the sudo command to never prompt -- e.g. use the -S option to pass a dummy password from stdin.
Subject: Re: [rt.cpan.org #118451] Test hangs waiting for root password
Date: Thu, 27 Oct 2016 19:51:18 +0200
To: bug-Net-Ping [...] rt.cpan.org
From: Reini Urban <reini.urban [...] gmail.com>
Show quoted text
> On Oct 27, 2016, at 7:49 PM, Karen Etheridge via RT <bug-Net-Ping@rt.cpan.org> wrote: > > Queue: Net-Ping > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=118451 > > > On 2016-10-27 06:53:25, RURBAN wrote:
>> On Wed Oct 26 08:59:06 2016, NHORNE wrote:
>>> I think the problem is here in 500_ping_icmp.t: >>> >>> if (!Net::Ping::_isroot()) { >>> my $file = __FILE__; >>> diag 'This optional test may prompt for your sudo password.'; >>> if (system("sudo \"$^X\" -Mblib $file") == 0) { >>> exit; >>> } else { >>> plan skip_all => 'no sudo/failed'; >>> } >>> } >>> >>> I don't like random code trying to sudo. Perhaps this should be an >>> "author only" test?
>> >> Yes, I don't like it neither. But it caught a longstanding bug, >> because nobody so far ever executed that function, because nobody >> apparently tested that as root. >> So either add a timeout or change it to AUTHOR_TESTING only. >> Catch is, I never run AUTHOR_TESTING in perl core, so I would never >> catch that.
> > So check $ENV{PERL_CORE} || $ENV{AUTHOR_TESTING} then? > > But hanging on a password prompt while building perl core would be just as bad. > > You can change the sudo command to never prompt -- e.g. use the -S option to pass a dummy password from stdin.
-S is an excellent idea. I’ll add that. plus the if $ENV{PERL_CORE} part, so cpan users will not be bothered. thanks
Subject: Re: [rt.cpan.org #118451] Test hangs waiting for root password
Date: Thu, 27 Oct 2016 13:03:08 -0600
To: bug-Net-Ping [...] rt.cpan.org
From: Rob Brown <bbb [...] cpan.org>
Yes I agree and I also recommend that solution: if (system("sudo -S \"\" \"$^X\" -Mblib $file") == 0) { On Thu, Oct 27, 2016 at 11:51 AM, reini.urban@gmail.com via RT < bug-Net-Ping@rt.cpan.org> wrote: Show quoted text
> Queue: Net-Ping > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=118451 > > >
> > On Oct 27, 2016, at 7:49 PM, Karen Etheridge via RT <
> bug-Net-Ping@rt.cpan.org> wrote:
> > > > Queue: Net-Ping > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=118451 > > > > > On 2016-10-27 06:53:25, RURBAN wrote:
> >> On Wed Oct 26 08:59:06 2016, NHORNE wrote:
> >>> I think the problem is here in 500_ping_icmp.t: > >>> > >>> if (!Net::Ping::_isroot()) { > >>> my $file = __FILE__; > >>> diag 'This optional test may prompt for your sudo password.'; > >>> if (system("sudo \"$^X\" -Mblib $file") == 0) { > >>> exit; > >>> } else { > >>> plan skip_all => 'no sudo/failed'; > >>> } > >>> } > >>> > >>> I don't like random code trying to sudo. Perhaps this should be an > >>> "author only" test?
> >> > >> Yes, I don't like it neither. But it caught a longstanding bug, > >> because nobody so far ever executed that function, because nobody > >> apparently tested that as root. > >> So either add a timeout or change it to AUTHOR_TESTING only. > >> Catch is, I never run AUTHOR_TESTING in perl core, so I would never > >> catch that.
> > > > So check $ENV{PERL_CORE} || $ENV{AUTHOR_TESTING} then? > > > > But hanging on a password prompt while building perl core would be just
> as bad.
> > > > You can change the sudo command to never prompt -- e.g. use the -S
> option to pass a dummy password from stdin. > > -S is an excellent idea. I’ll add that. > plus the if $ENV{PERL_CORE} part, so cpan users will not be bothered. > > thanks > > >
On Thu Oct 27 15:03:25 2016, BBB wrote: Show quoted text
> Yes I agree and I also recommend that solution: > > if (system("sudo -S \"\" \"$^X\" -Mblib $file") == 0) {
I'll rather go with -n for non-interactive, which will fail when a password is required or sudo is missing, and skip the tests then. t/500_ping_icmp.t ..... sudo: a password is required t/500_ping_icmp.t ..... skipped: no sudo/failed Show quoted text
> On Thu, Oct 27, 2016 at 11:51 AM, reini.urban@gmail.com via RT < > bug-Net-Ping@rt.cpan.org> wrote:
> > Queue: Net-Ping > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=118451 > > > > >
> > > On Oct 27, 2016, at 7:49 PM, Karen Etheridge via RT <
> > bug-Net-Ping@rt.cpan.org> wrote:
> > > > > > Queue: Net-Ping > > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=118451 > > > > > > > On 2016-10-27 06:53:25, RURBAN wrote:
> > >> On Wed Oct 26 08:59:06 2016, NHORNE wrote:
> > >>> I think the problem is here in 500_ping_icmp.t: > > >>> > > >>> if (!Net::Ping::_isroot()) { > > >>> my $file = __FILE__; > > >>> diag 'This optional test may prompt for your sudo password.'; > > >>> if (system("sudo \"$^X\" -Mblib $file") == 0) { > > >>> exit; > > >>> } else { > > >>> plan skip_all => 'no sudo/failed'; > > >>> } > > >>> } > > >>> > > >>> I don't like random code trying to sudo. Perhaps this should be an > > >>> "author only" test?
> > >> > > >> Yes, I don't like it neither. But it caught a longstanding bug, > > >> because nobody so far ever executed that function, because nobody > > >> apparently tested that as root. > > >> So either add a timeout or change it to AUTHOR_TESTING only. > > >> Catch is, I never run AUTHOR_TESTING in perl core, so I would never > > >> catch that.
> > > > > > So check $ENV{PERL_CORE} || $ENV{AUTHOR_TESTING} then? > > > > > > But hanging on a password prompt while building perl core would be just
> > as bad.
> > > > > > You can change the sudo command to never prompt -- e.g. use the -S
> > option to pass a dummy password from stdin. > > > > -S is an excellent idea. I’ll add that. > > plus the if $ENV{PERL_CORE} part, so cpan users will not be bothered. > > > > thanks > > > > > >
-- Reini Urban
Fixed with 2.55 -- Reini Urban
Subject: Re: [rt.cpan.org #118451] Test hangs waiting for root password
Date: Thu, 27 Oct 2016 15:40:18 -0600
To: bug-Net-Ping [...] rt.cpan.org
From: Rob Brown <bbb [...] cpan.org>
Oh right. And in case the sudo password is cached (and isn't the empty string) the "-n" option can still allow it to work as intended. Even better! Thank you Reini! On Thu, Oct 27, 2016 at 3:11 PM, Reini Urban via RT < bug-Net-Ping@rt.cpan.org> wrote: Show quoted text
> Queue: Net-Ping > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=118451 > > > On Thu Oct 27 15:03:25 2016, BBB wrote:
> > Yes I agree and I also recommend that solution: > > > > if (system("sudo -S \"\" \"$^X\" -Mblib $file") == 0) {
> > I'll rather go with -n for non-interactive, which will fail when a > password is required or sudo is missing, and skip the tests then. > > t/500_ping_icmp.t ..... sudo: a password is required > t/500_ping_icmp.t ..... skipped: no sudo/failed > >