s3-passdb: Make arguments for python wrapper enum_group_mapping() optional
authorAmitay Isaacs <amitay@gmail.com>
Thu, 18 Aug 2011 05:05:18 +0000 (15:05 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 19 Aug 2011 06:35:00 +0000 (16:35 +1000)
Set the defaults, if no arguments are provided.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source3/passdb/py_passdb.c

index 5b10c465feac80ecd93733390b2468a7c9806fc9..81eb59d40da972d6fedf30314b6a600e1226dfce 100644 (file)
@@ -1791,16 +1791,19 @@ static PyObject *py_pdb_enum_group_mapping(pytalloc_Object *self, PyObject *args
        struct pdb_methods *methods;
        TALLOC_CTX *tframe;
        enum lsa_SidType sid_name_use;
        struct pdb_methods *methods;
        TALLOC_CTX *tframe;
        enum lsa_SidType sid_name_use;
-       int lsa_sidtype_value;
-       int unix_only;
+       int lsa_sidtype_value = SID_NAME_UNKNOWN;
+       int unix_only = 0;
        PyObject *py_domain_sid;
        PyObject *py_domain_sid;
-       struct dom_sid *domain_sid;
+       struct dom_sid *domain_sid = NULL;
        GROUP_MAP *gmap, *group_map;
        size_t num_entries;
        PyObject *py_gmap_list, *py_group_map;
        int i;
 
        GROUP_MAP *gmap, *group_map;
        size_t num_entries;
        PyObject *py_gmap_list, *py_group_map;
        int i;
 
-       if (!PyArg_ParseTuple(args, "O!ii:enum_group_mapping", dom_sid_Type, &py_domain_sid,
+       py_domain_sid = Py_None;
+       Py_INCREF(Py_None);
+
+       if (!PyArg_ParseTuple(args, "|O!ii:enum_group_mapping", dom_sid_Type, &py_domain_sid,
                                        &lsa_sidtype_value, &unix_only)) {
                return NULL;
        }
                                        &lsa_sidtype_value, &unix_only)) {
                return NULL;
        }
@@ -1814,7 +1817,9 @@ static PyObject *py_pdb_enum_group_mapping(pytalloc_Object *self, PyObject *args
 
        sid_name_use = lsa_sidtype_value;
 
 
        sid_name_use = lsa_sidtype_value;
 
-       domain_sid = pytalloc_get_ptr(py_domain_sid);
+       if (py_domain_sid != Py_None) {
+               domain_sid = pytalloc_get_ptr(py_domain_sid);
+       }
 
        status = methods->enum_group_mapping(methods, domain_sid, sid_name_use,
                                                &gmap, &num_entries, unix_only);
 
        status = methods->enum_group_mapping(methods, domain_sid, sid_name_use,
                                                &gmap, &num_entries, unix_only);