]> git.k1024.org Git - pylibacl.git/blob - acl.c
Renamed type & object names from ACLType to ACL_Type and so on. Also ACLEntry is...
[pylibacl.git] / acl.c
1 #include <sys/types.h>
2 #include <sys/acl.h>
3
4 #include <Python.h>
5
6 staticforward PyTypeObject ACL_Type;
7 static PyObject* ACL_applyto(PyObject* obj, PyObject* args);
8 static PyObject* ACL_valid(PyObject* obj, PyObject* args);
9 #ifdef HAVE_LEVEL2
10 static PyObject* ACL_get_state(PyObject *obj, PyObject* args);
11 static PyObject* ACL_set_state(PyObject *obj, PyObject* args);
12
13 staticforward PyTypeObject Entry_Type;
14 staticforward PyTypeObject Permset_Type;
15 #endif
16
17 typedef struct {
18     PyObject_HEAD
19     acl_t acl;
20     int entry_id;
21 } ACL_Object;
22
23 #ifdef HAVE_LEVEL2
24
25 typedef struct {
26     PyObject_HEAD
27     PyObject *parent; /* The parent acl, so it won't run out on us */
28     acl_entry_t entry;
29 } Entry_Object;
30
31 typedef struct {
32     PyObject_HEAD
33     PyObject *parent; /* The parent entry, so it won't run out on us */
34     acl_permset_t permset;
35 } PermsetObject;
36
37 #endif
38
39 /* Creation of a new ACL instance */
40 static PyObject* ACL_new(PyTypeObject* type, PyObject* args, PyObject *keywds) {
41     PyObject* newacl;
42
43     newacl = type->tp_alloc(type, 0);
44
45     if(newacl != NULL) {
46         ((ACL_Object*)newacl)->acl = NULL;
47         ((ACL_Object*)newacl)->entry_id = ACL_FIRST_ENTRY;
48     }
49
50     return newacl;
51 }
52
53 /* Initialization of a new ACL instance */
54 static int ACL_init(PyObject* obj, PyObject* args, PyObject *keywds) {
55     ACL_Object* self = (ACL_Object*) obj;
56     static char *kwlist[] = { "file", "fd", "text", "acl", NULL };
57     char *file = NULL;
58     char *text = NULL;
59     int fd = -1;
60     ACL_Object* thesrc = NULL;
61     int tmp;
62
63     if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sisO!", kwlist,
64                                      &file, &fd, &text, &ACL_Type, &thesrc))
65         return -1;
66     tmp = 0;
67     if(file != NULL)
68         tmp++;
69     if(text != NULL)
70         tmp++;
71     if(fd != -1)
72         tmp++;
73     if(thesrc != NULL)
74         tmp++;
75     if(tmp > 1) {
76         PyErr_SetString(PyExc_ValueError, "a maximum of one argument must be passed");
77         return -1;
78     }
79
80     /* Free the old acl_t without checking for error, we don't
81      * care right now */
82     if(self->acl != NULL)
83         acl_free(self->acl);
84
85     if(file != NULL)
86         self->acl = acl_get_file(file, ACL_TYPE_ACCESS);
87     else if(text != NULL)
88         self->acl = acl_from_text(text);
89     else if(fd != -1)
90         self->acl = acl_get_fd(fd);
91     else if(thesrc != NULL)
92         self->acl = acl_dup(thesrc->acl);
93     else
94         self->acl = acl_init(0);
95
96     if(self->acl == NULL) {
97         PyErr_SetFromErrno(PyExc_IOError);
98         return -1;
99     }
100
101     return 0;
102 }
103
104 /* Standard type functions */
105 static void ACL_dealloc(PyObject* obj) {
106     ACL_Object *self = (ACL_Object*) obj;
107     PyObject *err_type, *err_value, *err_traceback;
108     int have_error = PyErr_Occurred() ? 1 : 0;
109
110     if (have_error)
111         PyErr_Fetch(&err_type, &err_value, &err_traceback);
112     if(acl_free(self->acl) != 0)
113         PyErr_WriteUnraisable(obj);
114     if (have_error)
115         PyErr_Restore(err_type, err_value, err_traceback);
116     PyObject_DEL(self);
117 }
118
119 /* Converts the acl to a text format */
120 static PyObject* ACL_repr(PyObject *obj) {
121     char *text;
122     ACL_Object *self = (ACL_Object*) obj;
123     PyObject *ret;
124
125     text = acl_to_text(self->acl, NULL);
126     if(text == NULL) {
127         return PyErr_SetFromErrno(PyExc_IOError);
128     }
129     ret = PyString_FromString(text);
130     if(acl_free(text) != 0) {
131         Py_DECREF(ret);
132         return PyErr_SetFromErrno(PyExc_IOError);
133     }
134     return ret;
135 }
136
137 /* Custom methods */
138 static char __applyto_doc__[] = \
139 "Apply the ACL to a file or filehandle.\n" \
140 "\n" \
141 "Parameters:\n" \
142 "  - either a filename or a file-like object or an integer; this\n" \
143 "    represents the filesystem object on which to act\n" \
144 ;
145
146 /* Applyes the ACL to a file */
147 static PyObject* ACL_applyto(PyObject* obj, PyObject* args) {
148     ACL_Object *self = (ACL_Object*) obj;
149     PyObject *myarg;
150     int type_default = 0;
151     acl_type_t type = ACL_TYPE_ACCESS;
152     int nret;
153     int fd;
154
155     if (!PyArg_ParseTuple(args, "O|i", &myarg, &type_default))
156         return NULL;
157     if(type_default)
158         type = ACL_TYPE_DEFAULT;
159
160     if(PyString_Check(myarg)) {
161         char *filename = PyString_AS_STRING(myarg);
162         nret = acl_set_file(filename, type, self->acl);
163     } else if((fd = PyObject_AsFileDescriptor(myarg)) != -1) {
164         nret = acl_set_fd(fd, self->acl);
165     } else {
166         PyErr_SetString(PyExc_TypeError, "argument 1 must be string, int, or file-like object");
167         return 0;
168     }
169     if(nret == -1) {
170         return PyErr_SetFromErrno(PyExc_IOError);
171     }
172
173     /* Return the result */
174     Py_INCREF(Py_None);
175     return Py_None;
176 }
177
178 static char __valid_doc__[] = \
179 "Test the ACL for validity.\n" \
180 "\n" \
181 "This method tests the ACL to see if it is a valid ACL\n" \
182 "in terms of the filesystem. More precisely, it checks:\n" \
183 "A valid ACL contains exactly one entry with each of the ACL_USER_OBJ,\n" \
184 "ACL_GROUP_OBJ, and ACL_OTHER tag types. Entries with ACL_USER and\n" \
185 "ACL_GROUP tag types may appear zero or more times in an ACL. An ACL that\n" \
186 "contains entries of ACL_USER or ACL_GROUP tag types must contain exactly\n" \
187 "one entry of the ACL_MASK tag type. If an ACL contains no entries of\n" \
188 "ACL_USER or ACL_GROUP tag types, the ACL_MASK entry is optional.\n" \
189 "\n" \
190 "All user ID qualifiers must be unique among all entries of ACL_USER tag\n" \
191 "type, and all group IDs must be unique among all entries of ACL_GROUP tag\n" \
192 "type." \
193 ;
194
195 /* Checks the ACL for validity */
196 static PyObject* ACL_valid(PyObject* obj, PyObject* args) {
197     ACL_Object *self = (ACL_Object*) obj;
198
199     if(acl_valid(self->acl) == -1) {
200         return PyErr_SetFromErrno(PyExc_IOError);
201     }
202
203     /* Return the result */
204     Py_INCREF(Py_None);
205     return Py_None;
206 }
207
208 #ifdef HAVE_LEVEL2
209
210 static PyObject* ACL_get_state(PyObject *obj, PyObject* args) {
211     ACL_Object *self = (ACL_Object*) obj;
212     PyObject *ret;
213     ssize_t size, nsize;
214     char *buf;
215
216     size = acl_size(self->acl);
217     if(size == -1)
218         return PyErr_SetFromErrno(PyExc_IOError);
219
220     if((ret = PyString_FromStringAndSize(NULL, size)) == NULL)
221         return NULL;
222     buf = PyString_AsString(ret);
223     
224     if((nsize = acl_copy_ext(buf, self->acl, size)) == -1) {
225         Py_DECREF(ret);
226         return PyErr_SetFromErrno(PyExc_IOError);
227     }
228     
229     return ret;
230 }
231
232 static PyObject* ACL_set_state(PyObject *obj, PyObject* args) {
233     ACL_Object *self = (ACL_Object*) obj;
234     const void *buf;
235     int bufsize;
236     acl_t ptr;
237
238     /* Parse the argument */
239     if (!PyArg_ParseTuple(args, "s#", &buf, &bufsize))
240         return NULL;
241
242     /* Try to import the external representation */
243     if((ptr = acl_copy_int(buf)) == NULL)
244         return PyErr_SetFromErrno(PyExc_IOError);
245         
246     /* Free the old acl. Should we ignore errors here? */
247     if(self->acl != NULL) {
248         if(acl_free(self->acl) == -1)
249             return PyErr_SetFromErrno(PyExc_IOError);
250     }
251
252     self->acl = ptr;
253
254     /* Return the result */
255     Py_INCREF(Py_None);
256     return Py_None;
257 }
258
259 static PyObject* ACL_iter(PyObject *obj) {
260     ACL_Object *self = (ACL_Object*)obj;
261     self->entry_id = ACL_FIRST_ENTRY;
262     Py_INCREF(obj);
263     return obj;
264 }
265
266 static PyObject* ACL_iternext(PyObject *obj) {
267     ACL_Object *self = (ACL_Object*)obj;
268     acl_entry_t the_entry_t;
269     Entry_Object *the_entry_obj;
270     int nerr;
271     
272     if((nerr = acl_get_entry(self->acl, self->entry_id, &the_entry_t)) == -1)
273         return PyErr_SetFromErrno(PyExc_IOError);
274     self->entry_id = ACL_NEXT_ENTRY;
275     if(nerr == 0) {
276         PyErr_SetObject(PyExc_StopIteration, Py_None);
277         return NULL;
278     }
279
280     the_entry_obj = (Entry_Object*) PyType_GenericNew(&Entry_Type, NULL, NULL);
281     if(the_entry_obj == NULL)
282         return NULL;
283     
284     the_entry_obj->entry = the_entry_t;
285
286     the_entry_obj->parent = obj;
287     Py_INCREF(obj); /* For the reference we have in entry->parent */
288
289     return (PyObject*)the_entry_obj;
290 }
291
292 /* Creation of a new Entry instance */
293 static PyObject* Entry_new(PyTypeObject* type, PyObject* args, PyObject *keywds) {
294     PyObject* newentry;
295
296     newentry = PyType_GenericNew(type, args, keywds);
297
298     if(newentry != NULL) {
299         ((Entry_Object*)newentry)->entry = NULL;
300         ((Entry_Object*)newentry)->parent = NULL;
301     }
302
303     return newentry;
304 }
305
306 /* Initialization of a new Entry instance */
307 static int Entry_init(PyObject* obj, PyObject* args, PyObject *keywds) {
308     Entry_Object* self = (Entry_Object*) obj;
309     ACL_Object* parent = NULL;
310
311     if (!PyArg_ParseTuple(args, "O!", &ACL_Type, &parent))
312         return -1;
313
314     if(acl_create_entry(&parent->acl, &self->entry) == -1) {
315         PyErr_SetFromErrno(PyExc_IOError);
316         return -1;
317     }
318
319     self->parent = (PyObject*)parent;
320     Py_INCREF(parent);
321
322     return 0;
323 }
324
325 /* Free the Entry instance */
326 static void Entry_dealloc(PyObject* obj) {
327     Entry_Object *self = (Entry_Object*) obj;
328     PyObject *err_type, *err_value, *err_traceback;
329     int have_error = PyErr_Occurred() ? 1 : 0;
330
331     if (have_error)
332         PyErr_Fetch(&err_type, &err_value, &err_traceback);
333     if(self->parent != NULL) {
334         Py_DECREF(self->parent);
335         self->parent = NULL;
336     }
337     if (have_error)
338         PyErr_Restore(err_type, err_value, err_traceback);
339     PyObject_DEL(self);
340 }
341
342 static int Entry_set_tag_type(PyObject* obj, PyObject* value, void* arg) {
343     Entry_Object *self = (Entry_Object*) obj;
344
345     if(value == NULL) {
346         PyErr_SetString(PyExc_TypeError,
347                         "tag type deletion is not supported");
348         return -1;
349     }
350
351     if(!PyInt_Check(value)) {
352         PyErr_SetString(PyExc_TypeError,
353                         "tag type must be integer");
354         return -1;
355     }
356     if(acl_set_tag_type(self->entry, (acl_tag_t)PyInt_AsLong(value)) == -1) {
357         PyErr_SetFromErrno(PyExc_IOError);
358         return -1;
359     }
360
361     return 0;
362 }
363
364 static PyObject* Entry_get_tag_type(PyObject *obj, void* arg) {
365     Entry_Object *self = (Entry_Object*) obj;
366     acl_tag_t value;
367
368     if (self->entry == NULL) {
369         PyErr_SetString(PyExc_AttributeError, "entry attribute");
370         return NULL;
371     }
372     if(acl_get_tag_type(self->entry, &value) == -1) {
373         PyErr_SetFromErrno(PyExc_IOError);
374         return NULL;
375     }
376
377     return PyInt_FromLong(value);
378 }
379
380 static int Entry_set_qualifier(PyObject* obj, PyObject* value, void* arg) {
381     Entry_Object *self = (Entry_Object*) obj;
382     int uidgid;
383
384     if(value == NULL) {
385         PyErr_SetString(PyExc_TypeError,
386                         "qualifier deletion is not supported");
387         return -1;
388     }
389
390     if(!PyInt_Check(value)) {
391         PyErr_SetString(PyExc_TypeError,
392                         "tag type must be integer");
393         return -1;
394     }
395     uidgid = PyInt_AsLong(value);
396     if(acl_set_qualifier(self->entry, (void*)&uidgid) == -1) {
397         PyErr_SetFromErrno(PyExc_IOError);
398         return -1;
399     }
400
401     return 0;
402 }
403
404 static PyObject* Entry_get_qualifier(PyObject *obj, void* arg) {
405     Entry_Object *self = (Entry_Object*) obj;
406     void *p;
407     int value;
408
409     if (self->entry == NULL) {
410         PyErr_SetString(PyExc_AttributeError, "entry attribute");
411         return NULL;
412     }
413     if((p = acl_get_qualifier(self->entry)) == NULL) {
414         PyErr_SetFromErrno(PyExc_IOError);
415         return NULL;
416     }
417     value = *(uid_t*)p;
418     
419     return PyInt_FromLong(value);
420 }
421
422 static PyObject* Entry_get_parent(PyObject *obj, void* arg) {
423     Entry_Object *self = (Entry_Object*) obj;
424     
425     Py_INCREF(self->parent);
426     return self->parent;
427 }
428
429 #endif
430
431 static char __acltype_doc__[] = \
432 "Type which represents a POSIX ACL\n" \
433 "\n" \
434 "Parameters:\n" \
435 "  Only one keword parameter should be provided:\n"
436 "  - file=\"...\", meaning create ACL representing\n"
437 "    the ACL of that file\n" \
438 "  - fd=<int>, meaning create ACL representing\n" \
439 "    the ACL of that file descriptor\n" \
440 "  - text=\"...\", meaning create ACL from a \n" \
441 "    textual description\n" \
442 "  - acl=<ACL instance>, meaning create a copy\n" \
443 "    of an existing ACL instance\n" \
444 ;
445
446 /* ACL type methods */
447 static PyMethodDef ACL_methods[] = {
448     {"applyto", ACL_applyto, METH_VARARGS, __applyto_doc__},
449     {"valid", ACL_valid, METH_NOARGS, __valid_doc__},
450 #ifdef HAVE_LEVEL2
451     {"__getstate__", ACL_get_state, METH_NOARGS, "Dumps the ACL to an external format."},
452     {"__setstate__", ACL_set_state, METH_VARARGS, "Loads the ACL from an external format."},
453 #endif
454     {NULL, NULL, 0, NULL}
455 };
456
457
458 /* The definition of the ACL Type */
459 static PyTypeObject ACL_Type = {
460     PyObject_HEAD_INIT(NULL)
461     0,
462     "posix1e.ACL",
463     sizeof(ACL_Object),
464     0,
465     ACL_dealloc,        /* tp_dealloc */
466     0,                  /* tp_print */
467     0,                  /* tp_getattr */
468     0,                  /* tp_setattr */
469     0,                  /* tp_compare */
470     ACL_repr,           /* tp_repr */
471     0,                  /* tp_as_number */
472     0,                  /* tp_as_sequence */
473     0,                  /* tp_as_mapping */
474     0,                  /* tp_hash */
475     0,                  /* tp_call */
476     0,                  /* tp_str */
477     0,                  /* tp_getattro */
478     0,                  /* tp_setattro */
479     0,                  /* tp_as_buffer */
480     Py_TPFLAGS_DEFAULT, /* tp_flags */
481     __acltype_doc__,    /* tp_doc */
482     0,                  /* tp_traverse */
483     0,                  /* tp_clear */
484     0,                  /* tp_richcompare */
485     0,                  /* tp_weaklistoffset */
486 #ifdef HAVE_LEVEL2
487     ACL_iter,
488     ACL_iternext,
489 #else
490     0,                  /* tp_iter */
491     0,                  /* tp_iternext */
492 #endif
493     ACL_methods,        /* tp_methods */
494     0,                  /* tp_members */
495     0,                  /* tp_getset */
496     0,                  /* tp_base */
497     0,                  /* tp_dict */
498     0,                  /* tp_descr_get */
499     0,                  /* tp_descr_set */
500     0,                  /* tp_dictoffset */
501     ACL_init,           /* tp_init */
502     0,                  /* tp_alloc */
503     ACL_new,            /* tp_new */
504 };
505
506 #ifdef HAVE_LEVEL2
507
508 /* Entry type methods */
509 static PyMethodDef Entry_methods[] = {
510     {NULL, NULL, 0, NULL}
511 };
512
513 static char __Entry_tagtype_doc__[] = \
514 "The tag type of the current entry\n" \
515 "\n" \
516 "This is one of:\n" \
517 " - ACL_UNDEFINED_TAG\n" \
518 " - ACL_USER_OBJ\n" \
519 " - ACL_USER\n" \
520 " - ACL_GROUP_OBJ\n" \
521 " - ACL_GROUP\n" \
522 " - ACL_MASK\n" \
523 " - ACL_OTHER\n" \
524 ;
525
526 static char __Entry_qualifier_doc__[] = \
527 "The qualifier of the current entry\n" \
528 "\n" \
529 "If the tag type is ACL_USER, this should be a user id.\n" \
530 "If the tag type if ACL_GROUP, this should be a group id.\n" \
531 "Else, it doesn't matter.\n" \
532 ;
533
534 static char __Entry_parent_doc__[] = \
535 "The parent ACL of this entry\n" \
536 ;
537
538 /* Entry getset */
539 static PyGetSetDef Entry_getsets[] = {
540     {"tag_type", Entry_get_tag_type, Entry_set_tag_type, __Entry_tagtype_doc__},
541     {"qualifier", Entry_get_qualifier, Entry_set_qualifier, __Entry_qualifier_doc__},
542     {"parent", Entry_get_parent, NULL, __Entry_parent_doc__},
543     {NULL}
544 };
545
546 /* The definition of the ACL Entry Type */
547 static PyTypeObject Entry_Type = {
548     PyObject_HEAD_INIT(NULL)
549     0,
550     "posix1e.Entry",
551     sizeof(Entry_Object),
552     0,
553     Entry_dealloc,   /* tp_dealloc */
554     0,                  /* tp_print */
555     0,                  /* tp_getattr */
556     0,                  /* tp_setattr */
557     0,                  /* tp_compare */
558     0, //Entry_repr,      /* tp_repr */
559     0,                  /* tp_as_number */
560     0,                  /* tp_as_sequence */
561     0,                  /* tp_as_mapping */
562     0,                  /* tp_hash */
563     0,                  /* tp_call */
564     0,                  /* tp_str */
565     0,                  /* tp_getattro */
566     0,                  /* tp_setattro */
567     0,                  /* tp_as_buffer */
568     Py_TPFLAGS_DEFAULT, /* tp_flags */
569     __acltype_doc__,    /* tp_doc */
570     0,                  /* tp_traverse */
571     0,                  /* tp_clear */
572     0,                  /* tp_richcompare */
573     0,                  /* tp_weaklistoffset */
574     0,                  /* tp_iter */
575     0,                  /* tp_iternext */
576     Entry_methods,   /* tp_methods */
577     0,                  /* tp_members */
578     Entry_getsets,   /* tp_getset */
579     0,                  /* tp_base */
580     0,                  /* tp_dict */
581     0,                  /* tp_descr_get */
582     0,                  /* tp_descr_set */
583     0,                  /* tp_dictoffset */
584     Entry_init,      /* tp_init */
585     0,                  /* tp_alloc */
586     Entry_new,       /* tp_new */
587 };
588
589 #endif
590
591 /* Module methods */
592
593 static char __deletedef_doc__[] = \
594 "Delete the default ACL from a directory.\n" \
595 "\n" \
596 "This function deletes the default ACL associated with \n" \
597 "a directory (the ACL which will be ANDed with the mode\n" \
598 "parameter to the open, creat functions).\n" \
599 "Parameters:\n" \
600 "  - a string representing the directory whose default ACL\n" \
601 "    should be deleted\n" \
602 ;
603
604 /* Deletes the default ACL from a directory */
605 static PyObject* aclmodule_delete_default(PyObject* obj, PyObject* args) {
606     char *filename;
607
608     /* Parse the arguments */
609     if (!PyArg_ParseTuple(args, "s", &filename))
610         return NULL;
611
612     if(acl_delete_def_file(filename) == -1) {
613         return PyErr_SetFromErrno(PyExc_IOError);
614     }
615
616     /* Return the result */
617     Py_INCREF(Py_None);
618     return Py_None;
619 }
620
621 /* The module methods */
622 static PyMethodDef aclmodule_methods[] = {
623     {"delete_default", aclmodule_delete_default, METH_VARARGS, __deletedef_doc__},
624     {NULL, NULL, 0, NULL}
625 };
626
627 static char __posix1e_doc__[] = \
628 "POSIX.1e ACLs manipulation\n" \
629 "\n" \
630 "This module provides support for manipulating POSIX.1e ACLS\n" \
631 "\n" \
632 "Depending on the operating system support for POSIX.1e, \n" \
633 "the ACL type will have more or less capabilities:\n" \
634 "  - level 1, only basic support, you can create\n" \
635 "    ACLs from files and text descriptions;\n" \
636 "    once created, the type is immutable\n" \
637 "  - level 2, complete support, you can alter\n"\
638 "    the ACL once it is created\n" \
639 "\n" \
640 "Also, in level 2, more types will be available, corresponding\n" \
641 "to acl_entry_t, acl_permset_t, etc.\n" \
642 "\n" \
643 "Example:\n" \
644 ">>> import posix1e\n" \
645 ">>> acl1 = posix1e.ACL(file=\"file.txt\") \n" \
646 ">>> print acl1\n" \
647 "user::rw-\n" \
648 "group::rw-\n" \
649 "other::r--\n" \
650 "\n" \
651 ">>> b = posix1e.ACL(text=\"u::rx,g::-,o::-\")\n" \
652 ">>> print b\n" \
653 "user::r-x\n" \
654 "group::---\n" \
655 "other::---\n" \
656 "\n" \
657 ">>> b.applyto(\"file.txt\")\n" \
658 ">>> print posix1e.ACL(file=\"file.txt\")\n" \
659 "user::r-x\n" \
660 "group::---\n" \
661 "other::---\n" \
662 "\n" \
663 ">>>\n" \
664 ;
665
666 DL_EXPORT(void) initposix1e(void) {
667     PyObject *m, *d;
668
669     ACL_Type.ob_type = &PyType_Type;
670
671     if(PyType_Ready(&ACL_Type) < 0)
672         return;
673
674 #ifdef HAVE_LEVEL2
675     Entry_Type.ob_type = &PyType_Type;
676
677     if(PyType_Ready(&Entry_Type) < 0)
678         return;
679 #endif
680
681     m = Py_InitModule3("posix1e", aclmodule_methods, __posix1e_doc__);
682
683     d = PyModule_GetDict(m);
684     if (d == NULL)
685         return;
686
687     Py_INCREF(&ACL_Type);
688     if (PyDict_SetItemString(d, "ACL",
689                              (PyObject *) &ACL_Type) < 0)
690         return;
691 #ifdef HAVE_LEVEL2
692     Py_INCREF(&Entry_Type);
693     if (PyDict_SetItemString(d, "Entry",
694                              (PyObject *) &Entry_Type) < 0)
695         return;
696
697     /* 23.2.2 acl_perm_t values */
698     PyModule_AddIntConstant(m, "ACL_READ", ACL_READ);
699     PyModule_AddIntConstant(m, "ACL_WRITE", ACL_WRITE);
700     PyModule_AddIntConstant(m, "ACL_EXECUTE", ACL_EXECUTE);
701
702     /* 23.2.5 acl_tag_t values */
703     PyModule_AddIntConstant(m, "ACL_UNDEFINED_TAG", ACL_UNDEFINED_TAG);
704     PyModule_AddIntConstant(m, "ACL_USER_OBJ", ACL_USER_OBJ);
705     PyModule_AddIntConstant(m, "ACL_USER", ACL_USER);
706     PyModule_AddIntConstant(m, "ACL_GROUP_OBJ", ACL_GROUP_OBJ);
707     PyModule_AddIntConstant(m, "ACL_GROUP", ACL_GROUP);
708     PyModule_AddIntConstant(m, "ACL_MASK", ACL_MASK);
709     PyModule_AddIntConstant(m, "ACL_OTHER", ACL_OTHER);
710
711     /* 23.3.6 acl_type_t values */    
712     PyModule_AddIntConstant(m, "ACL_TYPE_ACCESS", ACL_TYPE_ACCESS);
713     PyModule_AddIntConstant(m, "ACL_TYPE_DEFAULT", ACL_TYPE_DEFAULT);
714
715 #endif
716 }