Module: Ethernet::Provisioning
- Defined in:
- lib/ethernet/provisioning.rb
Overview
Setup issues such as assigning permissions for Ethernet-level transmission.
Constant Summary collapse
- OS =
The kernel that the VM is running on (e.g. “darwin”, “linux”)
Config::CONFIG['target_os']
- POINTER_SIZE =
Number of bytes taken by a pointer on the Machine.
1.size
Class Method Summary collapse
-
.usermode_sockets ⇒ Object
Allow non-root users to create low-level Ethernet sockets.
Class Method Details
.usermode_sockets ⇒ Object
Allow non-root users to create low-level Ethernet sockets.
This is a security risk, because Ethernet sockets can be used to spy on all traffic on the machine’s network. This should not be called on production machines.
Returns true for success, false otherwise. If the call fails, it is most likely because it is not run by root / Administrator.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ethernet/provisioning.rb', line 22 def self.usermode_sockets case OS when /darwin/ return false unless Kernel.system("sudo chmod o+rw /dev/bpf*") when /linux/ ruby = File.join Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'] unless Kernel.system("sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' #{ruby}") return false end # Try to enable Wireshark packet capture for debugging. # No big deal if this fails. dumpcap = '/usr/bin/dumpcap' if File.exist? dumpcap Kernel.system("sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' #{dumpcap}") end when /win/ # NOTE: this might not work return false unless Kernel.system("sc config npf start= auto") else raise "Unsupported os #{Ethernet::Provisioning.platform}" end true end |