From e75a160f48cbce19a53fdc0de8af4e834df6a741 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sat, 28 Jun 2008 00:08:00 +0200 Subject: [PATCH] Try to enhance the FreeBSD support FreeBSD 7.0 supports more functions, so we split some Linux-only functions out from the HAVE_LEVEL2 defs and into a HAVE_ACL_COPY_EXT so FreeBSD can define HAVE_LEVEL2 too. --- Makefile | 17 ++++++++++++----- acl.c | 19 ++++++++++++++----- os_linux.c | 6 ------ setup.py | 3 +++ 4 files changed, 29 insertions(+), 16 deletions(-) delete mode 100644 os_linux.c diff --git a/Makefile b/Makefile index 9c1aa46..e1a34e5 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,19 @@ -.PHONY: doc log +.PHONY: doc log test doc: posix1e.txt posix1e.html build/lib.linux-x86_64-2.4/posix1e.so: acl.c ./setup.py build -posix1e.txt: build/lib.linux-x86_64-2.4/posix1e.so - PYTHONPATH=build/lib.linux-x86_64-2.4 pydoc posix1e > posix1e.txt +posix1e.so: acl.c + ./setup.py build_ext --inplace -posix1e.html: build/lib.linux-x86_64-2.4/posix1e.so - PYTHONPATH=build/lib.linux-x86_64-2.4 pydoc -w posix1e +posix1e.txt: posix1e.so + pydoc posix1e > posix1e.txt + +posix1e.html: posix1e.so + pydoc -w posix1e + +test: + python2.4 ./setup.py test + python2.5 ./setup.py test diff --git a/acl.c b/acl.c index 753a20e..7f09712 100644 --- a/acl.c +++ b/acl.c @@ -4,17 +4,22 @@ #include #ifdef HAVE_LINUX -#include "os_linux.c" +#include +#define get_perm acl_get_perm +#elif HAVE_FREEBSD +#define get_perm acl_get_perm_np #endif staticforward PyTypeObject ACL_Type; static PyObject* ACL_applyto(PyObject* obj, PyObject* args); static PyObject* ACL_valid(PyObject* obj, PyObject* args); -#ifdef HAVE_LEVEL2 +#ifdef HAVE_ACL_COPY_EXT static PyObject* ACL_get_state(PyObject *obj, PyObject* args); static PyObject* ACL_set_state(PyObject *obj, PyObject* args); +#endif +#ifdef HAVE_LEVEL2 staticforward PyTypeObject Entry_Type; staticforward PyTypeObject Permset_Type; static PyObject* Permset_new(PyTypeObject* type, PyObject* args, @@ -372,8 +377,7 @@ static PyObject* ACL_valid(PyObject* obj, PyObject* args) { } } -#ifdef HAVE_LEVEL2 - +#ifdef HAVE_ACL_COPY_EXT static PyObject* ACL_get_state(PyObject *obj, PyObject* args) { ACL_Object *self = (ACL_Object*) obj; PyObject *ret; @@ -422,6 +426,9 @@ static PyObject* ACL_set_state(PyObject *obj, PyObject* args) { Py_INCREF(Py_None); return Py_None; } +#endif + +#ifdef HAVE_LEVEL2 /* tp_iter for the ACL type; since it can be iterated only * destructively, the type is its iterator @@ -1064,11 +1071,13 @@ static PyMethodDef ACL_methods[] = { __to_any_text_doc__}, {"check", ACL_check, METH_NOARGS, __check_doc__}, #endif -#ifdef HAVE_LEVEL2 +#ifdef HAVE_ACL_COPYEXT {"__getstate__", ACL_get_state, METH_NOARGS, "Dumps the ACL to an external format."}, {"__setstate__", ACL_set_state, METH_VARARGS, "Loads the ACL from an external format."}, +#endif +#ifdef HAVE_LEVEL2 {"delete_entry", ACL_delete_entry, METH_VARARGS, __ACL_delete_entry_doc__}, {"calc_mask", ACL_calc_mask, METH_NOARGS, __ACL_calc_mask_doc__}, {"append", ACL_append, METH_VARARGS, __ACL_append_doc__}, diff --git a/os_linux.c b/os_linux.c deleted file mode 100644 index 1fb7203..0000000 --- a/os_linux.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int get_perm(acl_permset_t permset, acl_perm_t perm) -{ - return acl_get_perm(permset, perm); -} diff --git a/setup.py b/setup.py index 9fbef40..e75e1a0 100755 --- a/setup.py +++ b/setup.py @@ -14,9 +14,12 @@ if u_sysname == "Linux": elif u_sysname == "GNU/kFreeBSD": macros.append(("HAVE_LINUX", None)) macros.append(("HAVE_LEVEL2", None)) + macros.append(("HAVE_ACL_COPY_EXT", None)) libs.append("acl") elif u_sysname == "FreeBSD": macros.append(("HAVE_FREEBSD", None)) + if u_release.startswith("7."): + macros.append(("HAVE_LEVEL2", None)) elif u_sysname == "Darwin": libs.append("pthread") else: -- 2.39.5