[Python-Dev] POSIX Capabilities
"Martin v. Löwis"
martin at v.loewis.de
Tue Nov 21 07:07:58 CET 2006
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
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.
More information about the Python-Dev