module Ethernet::Provisioning
Setup issues such as assigning permissions for Ethernet-level transmission.
Constants
- OS
The kernel that the VM is running on (e.g. “darwin”, “linux”)
- POINTER_SIZE
Number of bytes taken by a pointer on the Machine.
Public Class Methods
usermode_sockets()
click to toggle source
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.
# 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