Iustin Pop [Tue, 3 Dec 2019 23:35:33 +0000 (00:35 +0100)]
Change entry qualifier set/get behaviour
This was intended to address #13, but investigation found out more
breakage than just that. It's hard to make overflow/underflow tests
without assuming the signedness of the uid_t/gid_t types, so
assume/require that they're unsigned (it is true with glibc, MacOS and
FreeBSD) and use this to improve the behaviour:
- Fix setting very large qualifiers, both in the sense of correctly
reporting overflow when too large, and not longer falsely reporting
overflow for larger than signed max but smaller than unsigned max;
- Fix returning very large (larger than signed max value) qualifiers;
Iustin Pop [Fri, 29 Nov 2019 18:55:09 +0000 (19:55 +0100)]
Add stub type hints - even if not working
Apparently PEP561 only addresses packages, not modules, and somewhat
dismissively says: "code should be refactored into a package-based
distribution and indicate that the package supports typing as
described above".
Well, locally I can use it, so let's add the stub. Will see later if
it can be used somehow.
Iustin Pop [Fri, 29 Nov 2019 14:42:42 +0000 (15:42 +0100)]
Switch ACL to be always-initialised
This is the last object to change, but the semantics here are more
complex. Since the ACL doesn't have a parent, and the init signature
is complex, we can't detect "same-reinit", we allow arbitrary-reinit,
but this makes existing live entries be undefined; they might point to
a different entry in the new ACL, or not be valid, etc.
It could be possible to prevent re-init, but doing so requires
trickery which might be broken by serialisation, so let's just leave
it there and document it as such.
Iustin Pop [Fri, 29 Nov 2019 13:54:23 +0000 (14:54 +0100)]
Stop duplicating permset initialisation
A permset can be initalised either via `__init__ ` or by getting
`parent.permset` getter. The latter duplicates the logic in the
former, which is not good as hacks into the internals of the permset.
Remove the duplication by just calling explicitly permset(self) and
returning the value of it.
Iustin Pop [Fri, 29 Nov 2019 13:28:06 +0000 (14:28 +0100)]
Change Entry initialisation protocol
This fixes very large and significant bugs - segfaults and memory
leaks - that were present for uninitialised object, more precisely
created but not init'ed ones.
I spent quite a bit of time thinking back on forth how to fix this,
and from the two options of:
- check initialised status on all code paths, or
- don't ever allow invalid/un-initialised objects
The latter one seems the correct one, even though the Python C API
docs imply that doing actual stuff in `__new__` should be "rare".
Tests for reference leaks and wrong re-init added as well; these would
have caught at least memory leaks before.
Iustin Pop [Sun, 3 Mar 2019 12:45:45 +0000 (13:45 +0100)]
ACL creation: change how mode arguments are used
Currently, initialising from a mode is done by looking at the keywords
arguments that were passed and seeing if mode was part of them. For
some reason, this causes a segfault under PyPy (my fault, probably),
so let's switch to check based on whether the mode argument was
initialised. To do so, switch the type of mode to int and the Python
format char, since the 'H' is defined as "without overflow checking"
anyway, so we don't get any real checks. Document that invalid values
will cause errors.
Iustin Pop [Sun, 3 Mar 2019 12:42:10 +0000 (13:42 +0100)]
Remove use of PyString/PyUnicode *AndDel() function
These are not documented in Python 3, so let's switch to plain
Concat() for it with explicit delete of original strings. This makes
the code buildable with pypy3.
Iustin Pop [Sun, 3 Mar 2019 11:47:36 +0000 (12:47 +0100)]
Drop Python 2.6 and earlier support
While the C extension doesn't need anything to support it, simply
running the tests becomes more and more difficult with such old
versions. Given upcoming Python 2 deprecation, let's drop support for
older versions and simplify the test suite.
Iustin Pop [Sun, 3 Mar 2019 01:40:04 +0000 (02:40 +0100)]
Increase test coverage
These are old changes from October 2016 which I forgot to commit. I
think they're related to test coverage, although a few changes (object
structure) seems a bit different.
Iustin Pop [Sat, 2 Mar 2019 20:09:30 +0000 (21:09 +0100)]
Travis: remove "sudo:false"
Per the deprecation of container-based
builds (https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration),
remove the sudo:false setting.
Iustin Pop [Thu, 30 Apr 2015 17:43:53 +0000 (19:43 +0200)]
tests: don't call acl_to_text on an invalid ACL
While Linux is happy to convert it to text, it seems that under
FreeBSD this doesn't (always? sometimes?) work, so let's use a proper
ACL in the str() test.
Iustin Pop [Sat, 28 Jun 2014 12:13:32 +0000 (14:13 +0200)]
Try to fix uid_t/gid_t usage in entry qualifiers
The current code is very broken with regards to the casting between
Python's integer type (either int in Py2 or the magic int/long in Py3)
and the uid_t/gid_t POSIX types. This means that the code is broken
outside "small" integer values.
By using uid_t/gid_t as appropriate, we can fix most of the problem
(at least as far as the new unittests are concerned). There's still no
automatic printf format modifier for them, so the code hardcodes
unsigned (which is what Linux/glibc defines them to), and also there's
a unittest that expects negative values to fail when set.