This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Net-Ping: creating an icmp socket requires admin access on recent cygwin
authorTony Cook <tony@develop-help.com>
Fri, 27 Jul 2012 13:47:05 +0000 (23:47 +1000)
committerTony Cook <tony@develop-help.com>
Thu, 2 Aug 2012 00:24:57 +0000 (10:24 +1000)
on recent Windows.

cygwin on XP can create an icmp socket as a normal user but can't do
anything with it.  On Vista or Win7 the process must be running as
an admin to create the socket.

If someone sees value in running the test on cygwin on XP, they can
provide a patch.

dist/Net-Ping/t/110_icmp_inst.t

index 7840657..b36d32f 100644 (file)
@@ -16,7 +16,7 @@ BEGIN {use_ok('Net::Ping')};
 SKIP: {
   skip "icmp ping requires root privileges.", 1
     if ($> and $^O ne 'VMS' and $^O ne 'cygwin')
-      or ($^O eq 'MSWin32'
+      or (($^O eq 'MSWin32' or $^O eq 'cygwin')
          and !IsAdminUser())
        or ($^O eq 'VMS'
            and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/));
@@ -25,7 +25,7 @@ SKIP: {
 }
 
 sub IsAdminUser {
-  return unless $^O eq 'MSWin32';
+  return unless $^O eq 'MSWin32' or $^O eq 'cygwin';
   return unless eval { require Win32 };
   return unless defined &Win32::IsAdminUser;
   return Win32::IsAdminUser();