Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Explicitly check for elevated privileges in the ICMP constructor for …

…Vista and later.
  • Loading branch information...
commit 7c88812f1acef3c742bd43f8dca88997a0241b9e 1 parent 42df87e
@djberg96 djberg96 authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/net/ping/icmp.rb
View
12 lib/net/ping/icmp.rb
@@ -1,5 +1,11 @@
require File.join(File.dirname(__FILE__), 'ping')
+if File::ALT_SEPARATOR
+ require 'win32/security'
+ require 'windows/system_info'
+ include Windows::SystemInfo
+end
+
# The Net module serves as a namespace only.
module Net
@@ -26,6 +32,12 @@ class Ping::ICMP < Ping
def initialize(host=nil, port=nil, timeout=5)
raise 'requires root privileges' if Process.euid > 0
+ if File::ALT_SEPARATOR && windows_version >= 6
+ unless Win32::Security.elevated_security?
+ raise 'requires elevated security'
+ end
+ end
+
@seq = 0
@bind_port = 0
@bind_host = nil
Please sign in to comment.
Something went wrong with that request. Please try again.