Message9362
Logged In: YES
user_id=323435
From the current man pages of OpenBSD and FreeBSD. It stats
that the second argument of ioctl is an unsigned int.
http://www.openbsd.org/cgi-bin/man.cgi?query=ioctl
http://www.freebsd.org/cgi-bin/man.cgi?query=ioctl
Pythons fcntl.ioctl() does not allow the second argumnet to
be anything other then a C int, this does not allow required
operations to be preformed with ioctl on the two BSD systems.
For a practical example. On the openbsd system the /dev/pf
is the direct inteface to the firewall, the only things I am
able to preform on this file in python are to turn the
firewall on and off. This is allowed because the ioctl
un_signed ints (536888321 in base 10) that prefrom this
action happen to be small enough to fit in to an int. While
the ioctl unsigned int (3229893651 in base 10) for reporting
the status of connections is larger then a C int and python
raises an exception before calling the system ioctl call.
The following is the code in question.
import fcntl
import struct
import os
fd = os.open("/dev/pf",os.O_RDWR)
null = '\0'*(struct.calcsize("LLLLIIII"))
x = 3229893651
null = fcntl.ioctl(fd,x,null)
print struct.unpack("LLLLIIII",null)
---output---
$ sudo python ./py-pfctl.py
Traceback (most recent call last):
File "./py-pfctl.py", line 8, in ?
null = fcntl.ioctl(fd,x,null)
OverflowError: long int too large to convert to int
|
|
Date |
User |
Action |
Args |
2007-08-23 13:59:21 | admin | link | issue521723 messages |
2007-08-23 13:59:21 | admin | create | |
|