I was looking around for an interface to POSIX capabilities from Python under Linux. I couldn't find anything that did the job, so I wrote the attached PosixCapabilities module. It has a number of shortcomings: * it is written using ctypes to interface directly to libcap; * it assumes the sizes/types of various POSIX defined types; * it only gets/sets process capabilities; * it can test/set/clear capability flags. Despite the downsides, I think it would be good to get the package out there. If anyone wishes to adopt it, update it, rewrite it and/or put it into the distribution, then feel free. Regards, Matt -- Matt Kern http://www.undue.org/
On Fri, Nov 17, 2006, Matt Kern wrote:
I was looking around for an interface to POSIX capabilities from Python under Linux. I couldn't find anything that did the job, so I wrote the attached PosixCapabilities module. It has a number of shortcomings:
Please upload it to the Cheeseshop; optional is making an announcement on c.l.py.announce. python-dev really is not the right place. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "In many ways, it's a dull language, borrowing solid old concepts from many other languages & styles: boring syntax, unsurprising semantics, few automatic coercions, etc etc. But that's one of the things I like about it." --Tim Peters on Python, 16 Sep 1993
Matt Kern schrieb:
I was looking around for an interface to POSIX capabilities from Python under Linux. I couldn't find anything that did the job, so I wrote the attached PosixCapabilities module. It has a number of shortcomings:
* it is written using ctypes to interface directly to libcap; * it assumes the sizes/types of various POSIX defined types; * it only gets/sets process capabilities; * it can test/set/clear capability flags.
Despite the downsides, I think it would be good to get the package out there. If anyone wishes to adopt it, update it, rewrite it and/or put it into the distribution, then feel free.
As Aahz says: make a distutils package out of it, and upload it to the Cheeseshop. For inclusion into Python, I would rather prefer to see the traditional route: make an autoconf test for presence of these functions, then edit Modules/posixmodule.c to conditionally expose these APIs from posix/os (they are POSIX functions, after all). The standard library should expose them as-is, without providing a convenience wrapper. I believe your implementation has limited portability, due to its usage of hard-coded symbolic values for the capabilites (I guess this is the Linux numbering, right?). Unfortunately, a ctypes-based implementation can't really do much better. Regards, Martin
participants (3)
-
"Martin v. Löwis"
-
Aahz
-
Matt Kern