Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICMP tests fail in a rootless podman container because ($> == 0) != isRoot #32

Open
djerius opened this issue Feb 27, 2023 · 3 comments
Assignees
Labels

Comments

@djerius
Copy link

djerius commented Feb 27, 2023

On Linux Net::Ping uses $> == 0 to determine if the user is root, and therefore is able to use icmp. However, while in a podman rootless container (and also possibly a docker rootless container, but $work doesn't give me access to that), $> == 0, but as it's not really running as root, icmp doesn't work, and the various tests which require icmp fail.

Normally I'd just force install Net::Ping, but Perl bundles it and this behavior breaks the Perl build.

The logic to figure out if the test is running in a rootless container seems to be very ad hoc and unstable, so I can't suggest a proper fix. One workaround would be to introduce an environment variable to be used during testing to avoid the ICMP checks regardless of the value of $>

@rurban
Copy link
Owner

rurban commented Feb 27, 2023

NO_NETWORK_TESTING=1 should cover that

@djerius
Copy link
Author

djerius commented Feb 27, 2023

Aha. Thanks, I was looking only at the code bundled in Perl 5.36.0; my apologies.

I ran the tests for Net::Ping 2.75 in a rootless podman container (Debian 11, but it shouldn't matter), with the following results; there seem to be a couple of corner cases left in the NO_NETWORK_TESTING support:

% NO_NETWORK_TESTING=1 make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
# Testing Net::Ping 2.75, Perl 5.032001 on linux, /usr/bin/perl
t/000_load.t ........... ok
icmp socket error - Operation not permitted at t/001_new.t line 66.
# Looks like your test exited with 1 just after 9.
t/001_new.t ............ 
Dubious, test returned 1 (wstat 256, 0x100)
All 9 subtests passed 
t/010_pingecho.t ....... ok
t/020_external.t ....... ok
icmp socket error - Operation not permitted at t/110_icmp_inst.t line 24.
# Looks like your test exited with 1 just after 1.
t/110_icmp_inst.t ...... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests 
t/120_udp_inst.t ....... ok
t/130_tcp_inst.t ....... ok
t/140_stream_inst.t .... ok
t/150_syn_inst.t ....... ok
t/190_alarm.t .......... skipped: network dependent test
t/200_ping_tcp.t ....... skipped: network dependent test
t/250_ping_hires.t ..... skipped: network dependent test
t/300_ping_stream.t .... skipped: network dependent test
t/400_ping_syn.t ....... skipped: network dependent test
t/410_syn_host.t ....... skipped: network dependent test
t/420_ping_syn_port.t .. skipped: network dependent test
t/450_service.t ........ ok
icmp socket error - Operation not permitted at t/500_ping_icmp.t line 59.
t/500_ping_icmp.t ...... 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
t/501_ping_icmpv6.t .... skipped: no icmpv6 on this machine icmp socket error - Operation not permitted at t/501_ping_icmpv6.t line 51.
t/510_ping_udp.t ....... ok
icmp socket error - Operation not permitted at t/520_icmp_ttl.t line 23.
# Looks like your test exited with 1 just after 1.
t/520_icmp_ttl.t ....... 
Dubious, test returned 1 (wstat 256, 0x100)
All 1 subtests passed 
t/600_pod.t ............ skipped: Test::Pod 1.22 required for testing POD
t/601_pod-coverage.t ... skipped: This test is only run for the module author
t/602_kwalitee.t ....... skipped: This test is only run for the module author
t/603_meta.t ........... skipped: This test is only run for the module author
sh: 1: git: not found
t/604_manifest.t ....... ok

Test Summary Report
-------------------
t/001_new.t          (Wstat: 256 Tests: 9 Failed: 0)
  Non-zero exit status: 1
t/110_icmp_inst.t    (Wstat: 256 Tests: 1 Failed: 0)
  Non-zero exit status: 1
  Parse errors: Bad plan.  You planned 2 tests but ran 1.
t/500_ping_icmp.t    (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
t/520_icmp_ttl.t     (Wstat: 256 Tests: 1 Failed: 0)
  Non-zero exit status: 1
Files=26, Tests=57,  1 wallclock secs ( 0.10 usr  0.04 sys +  1.27 cusr  0.21 csys =  1.62 CPU)
Result: FAIL
Failed 4/26 test programs. 0/57 subtests failed.
make: *** [Makefile:866: test_dynamic] Error 255

@rurban rurban self-assigned this Feb 28, 2023
@rurban rurban added the bug label Feb 28, 2023
@rurban
Copy link
Owner

rurban commented Dec 5, 2024

The fix for GH #33 (v2.76) will probably fix that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants