From: "Jan Dubois" <jand@ActiveState.com>
Date: Mon, 18 Apr 2005 20:16:24 -0700
Message-Id: <
200504190311.j3J3BM4p001792@smtp3.ActiveState.com>
Subject: RE: [PATCH] Run ICMP ping tests on Windows as long as we have admin privs
From: "Jan Dubois" <jand@ActiveState.com>
Date: Tue, 19 Apr 2005 01:49:51 -0700
Message-Id: <
200504190844.j3J8inkW032630@smtp3.ActiveState.com>
(There was no reply from Rob Brown in over a month, so commit to blead
for now. I'll email him again...)
p4raw-id: //depot/perl@24688
@ISA = qw(Exporter);
@EXPORT = qw(pingecho);
-$VERSION = "2.31";
+$VERSION = "2.31_01";
sub SOL_IP { 0; };
sub IP_TOS { 1; };
if (($> and $^O ne 'VMS' and $^O ne 'cygwin')
or ($^O eq 'MSWin32'
- and Win32::IsWinNT())
+ and !IsAdminUser())
or ($^O eq 'VMS'
and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/))) {
skip "icmp ping requires root privileges.", 1;
my $p = new Net::Ping "icmp";
ok !!$p;
}
+
+sub IsAdminUser {
+ return unless $^O eq 'MSWin32';
+ return unless eval { require Win32 };
+ return unless defined &Win32::IsAdminUser;
+ return Win32::IsAdminUser();
+}
if (($> and $^O ne 'VMS' and $^O ne 'cygwin')
or ($^O eq 'MSWin32'
- and Win32::IsWinNT())
+ and !IsAdminUser())
or ($^O eq 'VMS'
and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/))) {
skip "icmp ping requires root privileges.", 1;
my $p = new Net::Ping "icmp";
ok $p->ping("127.0.0.1");
}
+
+sub IsAdminUser {
+ return unless $^O eq 'MSWin32';
+ return unless eval { require Win32 };
+ return unless defined &Win32::IsAdminUser;
+ return Win32::IsAdminUser();
+}