r25598: Add missing become_root/unbecome_root around calls of add_aliases.
[samba.git] / source / python / py_winbind.c
index 130f78d7e126e424330232f0177f10f1017b4a2a..7d3a9cdf087dea9c85d7b346616810c9f386dd44 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "py_winbind.h"
@@ -30,7 +29,7 @@ PyObject *winbind_error;      /* A winbind call returned WINBINDD_ERROR */
 
 /* Prototypes from common.h */
 
-NSS_STATUS winbindd_request(int req_type, 
+NSS_STATUS winbindd_request_response(int req_type, 
                            struct winbindd_request *request,
                            struct winbindd_response *response);
 
@@ -66,7 +65,7 @@ static PyObject *py_name_to_sid(PyObject *self, PyObject *args)
                fstrcpy(request.data.name.name, name);
        }
 
-       if (winbindd_request(WINBINDD_LOOKUPNAME, &request, &response)  
+       if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response)  
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;
@@ -94,7 +93,7 @@ static PyObject *py_sid_to_name(PyObject *self, PyObject *args)
 
        fstrcpy(request.data.sid, sid);
 
-       if (winbindd_request(WINBINDD_LOOKUPSID, &request, &response)  
+       if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response)  
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;
@@ -126,7 +125,7 @@ static PyObject *py_enum_domain_users(PyObject *self, PyObject *args)
 
        ZERO_STRUCT(response);
 
-       if (winbindd_request(WINBINDD_LIST_USERS, NULL, &response) 
+       if (winbindd_request_response(WINBINDD_LIST_USERS, NULL, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -134,8 +133,8 @@ static PyObject *py_enum_domain_users(PyObject *self, PyObject *args)
 
        result = PyList_New(0);
 
-       if (response.extra_data) {
-               const char *extra_data = response.extra_data;
+       if (response.extra_data.data) {
+               const char *extra_data = response.extra_data.data;
                fstring name;
 
                while (next_token(&extra_data, name, ",", sizeof(fstring)))
@@ -157,7 +156,7 @@ static PyObject *py_enum_domain_groups(PyObject *self, PyObject *args)
 
        ZERO_STRUCT(response);
 
-       if (winbindd_request(WINBINDD_LIST_GROUPS, NULL, &response) 
+       if (winbindd_request_response(WINBINDD_LIST_GROUPS, NULL, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -165,8 +164,8 @@ static PyObject *py_enum_domain_groups(PyObject *self, PyObject *args)
 
        result = PyList_New(0);
 
-       if (response.extra_data) {
-               const char *extra_data = response.extra_data;
+       if (response.extra_data.data) {
+               const char *extra_data = response.extra_data.data;
                fstring name;
 
                while (next_token(&extra_data, name, ",", sizeof(fstring)))
@@ -192,7 +191,7 @@ static PyObject *py_enum_trust_dom(PyObject *self, PyObject *args)
 
        ZERO_STRUCT(response);
 
-       if (winbindd_request(WINBINDD_LIST_TRUSTDOM, NULL, &response) 
+       if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, NULL, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -200,8 +199,8 @@ static PyObject *py_enum_trust_dom(PyObject *self, PyObject *args)
 
        result = PyList_New(0);
 
-       if (response.extra_data) {
-               const char *extra_data = response.extra_data;
+       if (response.extra_data.data) {
+               const char *extra_data = response.extra_data.data;
                fstring name;
 
                while (next_token(&extra_data, name, ",", sizeof(fstring)))
@@ -222,7 +221,7 @@ static PyObject *py_check_secret(PyObject *self, PyObject *args)
 
        ZERO_STRUCT(response);
 
-       if (winbindd_request(WINBINDD_CHECK_MACHACC, NULL, &response) 
+       if (winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -294,7 +293,7 @@ static PyObject *py_uid_to_sid(PyObject *self, PyObject *args)
 
        request.data.uid = id;
 
-       if (winbindd_request(WINBINDD_UID_TO_SID, &request, &response) 
+       if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -319,7 +318,7 @@ static PyObject *py_gid_to_sid(PyObject *self, PyObject *args)
 
        request.data.gid = id;
 
-       if (winbindd_request(WINBINDD_GID_TO_SID, &request, &response) 
+       if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -344,7 +343,7 @@ static PyObject *py_sid_to_uid(PyObject *self, PyObject *args)
 
        fstrcpy(request.data.sid, sid);
 
-       if (winbindd_request(WINBINDD_SID_TO_UID, &request, &response) 
+       if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -369,7 +368,7 @@ static PyObject *py_sid_to_gid(PyObject *self, PyObject *args)
 
        fstrcpy(request.data.sid, sid);
 
-       if (winbindd_request(WINBINDD_SID_TO_GID, &request, &response) 
+       if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -399,7 +398,7 @@ static PyObject *py_auth_plaintext(PyObject *self, PyObject *args)
        fstrcpy(request.data.auth.user, username);
        fstrcpy(request.data.auth.pass, password);
 
-       if (winbindd_request(WINBINDD_PAM_AUTH, &request, &response) 
+       if (winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -432,7 +431,7 @@ static PyObject *py_auth_crap(PyObject *self, PyObject *args, PyObject *kw)
                return NULL;
        }
 
-       generate_random_buffer(request.data.auth_crap.chal, 8, False);
+       generate_random_buffer(request.data.auth_crap.chal, 8);
         
        if (use_lm_hash) {
                SMBencrypt((uchar *)password, request.data.auth_crap.chal, 
@@ -446,7 +445,7 @@ static PyObject *py_auth_crap(PyObject *self, PyObject *args, PyObject *kw)
                request.data.auth_crap.nt_resp_len = 24;
        }
 
-       if (winbindd_request(WINBINDD_PAM_AUTH_CRAP, &request, &response) 
+       if (winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -481,7 +480,7 @@ static PyObject *py_auth_smbd(PyObject *self, PyObject *args, PyObject *kw)
                return NULL;
        }
 
-       generate_random_buffer(request.data.smbd_auth_crap.chal, 8, False);
+       generate_random_buffer(request.data.smbd_auth_crap.chal, 8);
         
        if (use_lm_hash) {
                SMBencrypt((uchar *)password, 
@@ -506,7 +505,7 @@ static PyObject *py_auth_smbd(PyObject *self, PyObject *args, PyObject *kw)
 
 
 
-       if (winbindd_request(WINBINDD_SMBD_AUTH_CRAP, &request, &response) 
+       if (winbindd_request_response(WINBINDD_SMBD_AUTH_CRAP, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -534,7 +533,7 @@ static PyObject *py_getpwnam(PyObject *self, PyObject *args)
 
        fstrcpy(request.data.username, username);
 
-       if (winbindd_request(WINBINDD_GETPWNAM, &request, &response) 
+       if (winbindd_request_response(WINBINDD_GETPWNAM, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -565,7 +564,7 @@ static PyObject *py_getpwuid(PyObject *self, PyObject *args)
 
        request.data.uid = uid;
 
-       if (winbindd_request(WINBINDD_GETPWUID, &request, &response) 
+       if (winbindd_request_response(WINBINDD_GETPWUID, &request, &response) 
            != NSS_STATUS_SUCCESS) {
                PyErr_SetString(winbind_error, "lookup failed");
                return NULL;            
@@ -706,7 +705,7 @@ static PyMethodDef winbind_methods[] = {
 "Authenticate a username and password using plaintext authentication.\n"
 "The NT status code is returned with zero indicating success." },
 
-       { "auth_crap", (PyCFunction)py_auth_crap, METH_VARARGS,
+       { "auth_crap", (PyCFunction)py_auth_crap, METH_VARARGS | METH_KEYWORDS,
          "auth_crap(s, s) -> int\n"
 "\n"
 "Authenticate a username and password using the challenge/response\n"