Ticket #43 (closed defect: fixed)
Hard coded directories in win32 port
| Reported by: | jUrner(at)arcor.de | Owned by: | pbi |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | Scapy | Version: | |
| Keywords: | Cc: |
Description
Just happend to read over scapy and stumbled over some hard coded directories wich should lead into troubles on windows. "TMP" and "system" might be located anywhere and named anyhow. So I would like to suggest some changes.
Near line 176 it should read probably:
if not PCAP: #Note testing still if WINDOWS: #Windows needs TMP and not Temp here on my system f = os.popen("!WinDump -V 2> %s" % os.environ!["TMP"])
Near line 407 the system directory is hard coded to get on the available protocols. There is no easy way to get the system directory on windows, so best is to digg into kernel32 library. Below a version that uses win32all or ctypes (builtin since python 2.5):
def get_windows_system_directory(): """Returns the windows system directory""" # win32all version def gwsd_win32all(): import win32api return win32api.GetSystemDirectory() # ctypes ansi version def gwsd_ctypes_a(): from ctypes import windll, sizeof, create_string_buffer, WinError kernel32 = windll.kernel32 nBuffer = kernel32.GetSystemDirectoryA(None, 0) if nBuffer: p = create_string_buffer(nBuffer) if kernel32.GetSystemDirectoryA(p, sizeof(p)): return p.value raise WinError() # ctypes unicode version (not used, just in case) def gwsd_ctypes_w(): from ctypes import windll, sizeof, create_unicode_buffer, WinError kernel32 = windll.kernel32 nBuffer = kernel32.GetSystemDirectoryW(None, 0) if nBuffer: p = create_unicode_buffer(nBuffer) if kernel32.GetSystemDirectoryW(p, sizeof(p)): return p.value raise WinError() ## try: return gwsd_win32all() except ImportError: try: return gwsd_ctypes_a() except ImportError: raise SystemExit('Win32all or ctypes required')
Didn't fiddle along with a ctypes version of WaitForMultipleObjects(), but it should be fairly easy to implement.
regards, Jürgen
Attachments
Change History
Note: See
TracTickets for help on using
tickets.