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