python/py_winbind.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003 
00004    Python wrapper for winbind client functions.
00005 
00006    Copyright (C) Tim Potter      2002-2003
00007    
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 
00023 #include "py_winbind.h"
00024 
00025 /* 
00026  * Exceptions raised by this module 
00027  */
00028 
00029 PyObject *winbind_error;        /* A winbind call returned WINBINDD_ERROR */
00030 
00031 /* Prototypes from common.h */
00032 
00033 NSS_STATUS winbindd_request_response(int req_type, 
00034                             struct winbindd_request *request,
00035                             struct winbindd_response *response);
00036 
00037 /*
00038  * Name <-> SID conversion
00039  */
00040 
00041 /* Convert a name to a sid */
00042 
00043 static PyObject *py_name_to_sid(PyObject *self, PyObject *args)
00044 
00045 {
00046         struct winbindd_request request;
00047         struct winbindd_response response;
00048         PyObject *result;
00049         char *name, *p;
00050         const char *sep;
00051 
00052         if (!PyArg_ParseTuple(args, "s", &name))
00053                 return NULL;
00054 
00055         ZERO_STRUCT(request);
00056         ZERO_STRUCT(response);
00057 
00058         sep = lp_winbind_separator();
00059 
00060         if ((p = strchr(name, sep[0]))) {
00061                 *p = 0;
00062                 fstrcpy(request.data.name.dom_name, name);
00063                 fstrcpy(request.data.name.name, p + 1);
00064         } else {
00065                 fstrcpy(request.data.name.dom_name, lp_workgroup());
00066                 fstrcpy(request.data.name.name, name);
00067         }
00068 
00069         if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response)  
00070             != NSS_STATUS_SUCCESS) {
00071                 PyErr_SetString(winbind_error, "lookup failed");
00072                 return NULL;
00073         }
00074 
00075         result = PyString_FromString(response.data.sid.sid);
00076 
00077         return result;
00078 }
00079 
00080 /* Convert a sid to a name */
00081 
00082 static PyObject *py_sid_to_name(PyObject *self, PyObject *args)
00083 {
00084         struct winbindd_request request;
00085         struct winbindd_response response;
00086         PyObject *result;
00087         char *sid, *name;
00088 
00089         if (!PyArg_ParseTuple(args, "s", &sid))
00090                 return NULL;
00091 
00092         ZERO_STRUCT(request);
00093         ZERO_STRUCT(response);
00094 
00095         fstrcpy(request.data.sid, sid);
00096 
00097         if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response)  
00098             != NSS_STATUS_SUCCESS) {
00099                 PyErr_SetString(winbind_error, "lookup failed");
00100                 return NULL;
00101         }
00102 
00103         asprintf(&name, "%s%s%s", response.data.name.dom_name,
00104                  lp_winbind_separator(), response.data.name.name);
00105 
00106         result = PyString_FromString(name);
00107 
00108         free(name);
00109 
00110         return result;
00111 }
00112 
00113 /*
00114  * Enumerate users/groups
00115  */
00116 
00117 /* Enumerate domain users */
00118 
00119 static PyObject *py_enum_domain_users(PyObject *self, PyObject *args)
00120 {
00121         struct winbindd_response response;
00122         PyObject *result;
00123 
00124         if (!PyArg_ParseTuple(args, ""))
00125                 return NULL;
00126 
00127         ZERO_STRUCT(response);
00128 
00129         if (winbindd_request_response(WINBINDD_LIST_USERS, NULL, &response) 
00130             != NSS_STATUS_SUCCESS) {
00131                 PyErr_SetString(winbind_error, "lookup failed");
00132                 return NULL;            
00133         }
00134 
00135         result = PyList_New(0);
00136 
00137         if (response.extra_data.data) {
00138                 const char *extra_data = response.extra_data.data;
00139                 fstring name;
00140 
00141                 while (next_token(&extra_data, name, ",", sizeof(fstring)))
00142                         PyList_Append(result, PyString_FromString(name));
00143         }
00144 
00145         return result;
00146 }
00147 
00148 /* Enumerate domain groups */
00149 
00150 static PyObject *py_enum_domain_groups(PyObject *self, PyObject *args)
00151 {
00152         struct winbindd_response response;
00153         PyObject *result = NULL;
00154 
00155         if (!PyArg_ParseTuple(args, ""))
00156                 return NULL;
00157 
00158         ZERO_STRUCT(response);
00159 
00160         if (winbindd_request_response(WINBINDD_LIST_GROUPS, NULL, &response) 
00161             != NSS_STATUS_SUCCESS) {
00162                 PyErr_SetString(winbind_error, "lookup failed");
00163                 return NULL;            
00164         }
00165 
00166         result = PyList_New(0);
00167 
00168         if (response.extra_data.data) {
00169                 const char *extra_data = response.extra_data.data;
00170                 fstring name;
00171 
00172                 while (next_token(&extra_data, name, ",", sizeof(fstring)))
00173                         PyList_Append(result, PyString_FromString(name));
00174         }
00175 
00176         return result;
00177 }
00178 
00179 /*
00180  * Miscellaneous domain related
00181  */
00182 
00183 /* Enumerate domain groups */
00184 
00185 static PyObject *py_enum_trust_dom(PyObject *self, PyObject *args)
00186 {
00187         struct winbindd_response response;
00188         PyObject *result = NULL;
00189 
00190         if (!PyArg_ParseTuple(args, ""))
00191                 return NULL;
00192 
00193         ZERO_STRUCT(response);
00194 
00195         if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, NULL, &response) 
00196             != NSS_STATUS_SUCCESS) {
00197                 PyErr_SetString(winbind_error, "lookup failed");
00198                 return NULL;            
00199         }
00200 
00201         result = PyList_New(0);
00202 
00203         if (response.extra_data.data) {
00204                 const char *extra_data = response.extra_data.data;
00205                 fstring name;
00206 
00207                 while (next_token(&extra_data, name, ",", sizeof(fstring)))
00208                         PyList_Append(result, PyString_FromString(name));
00209         }
00210 
00211         return result;
00212 }
00213 
00214 /* Check machine account password */
00215 
00216 static PyObject *py_check_secret(PyObject *self, PyObject *args)
00217 {
00218         struct winbindd_response response;
00219 
00220         if (!PyArg_ParseTuple(args, ""))
00221                 return NULL;
00222 
00223         ZERO_STRUCT(response);
00224 
00225         if (winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response) 
00226             != NSS_STATUS_SUCCESS) {
00227                 PyErr_SetString(winbind_error, "lookup failed");
00228                 return NULL;            
00229         }
00230 
00231         return PyInt_FromLong(response.data.num_entries);
00232 }
00233 
00234 /*
00235  * Return a dictionary consisting of all the winbind related smb.conf
00236  * parameters.  This is stored in the module object.
00237  */
00238 
00239 static PyObject *py_config_dict(void)
00240 {
00241         PyObject *result;
00242         uid_t ulow, uhi;
00243         gid_t glow, ghi;
00244         
00245         if (!(result = PyDict_New()))
00246                 return NULL;
00247 
00248         /* Various string parameters */
00249 
00250         PyDict_SetItemString(result, "workgroup", 
00251                              PyString_FromString(lp_workgroup()));
00252 
00253         PyDict_SetItemString(result, "separator", 
00254                              PyString_FromString(lp_winbind_separator()));
00255 
00256         PyDict_SetItemString(result, "template_homedir", 
00257                              PyString_FromString(lp_template_homedir()));
00258 
00259         PyDict_SetItemString(result, "template_shell", 
00260                              PyString_FromString(lp_template_shell()));
00261 
00262         /* idmap uid/gid range */
00263 
00264         if (lp_idmap_uid(&ulow, &uhi)) {
00265                 PyDict_SetItemString(result, "uid_low", PyInt_FromLong(ulow));
00266                 PyDict_SetItemString(result, "uid_high", PyInt_FromLong(uhi));
00267         }
00268 
00269         if (lp_idmap_gid(&glow, &ghi)) {
00270                 PyDict_SetItemString(result, "gid_low", PyInt_FromLong(glow));
00271                 PyDict_SetItemString(result, "gid_high", PyInt_FromLong(ghi));
00272         }
00273 
00274         return result;
00275 }
00276 
00277 /*
00278  * ID mapping
00279  */
00280 
00281 /* Convert a uid to a SID */
00282 
00283 static PyObject *py_uid_to_sid(PyObject *self, PyObject *args)
00284 {
00285         struct winbindd_request request;
00286         struct winbindd_response response;
00287         int id;
00288 
00289         if (!PyArg_ParseTuple(args, "i", &id))
00290                 return NULL;
00291 
00292         ZERO_STRUCT(request);
00293         ZERO_STRUCT(response);
00294 
00295         request.data.uid = id;
00296 
00297         if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) 
00298             != NSS_STATUS_SUCCESS) {
00299                 PyErr_SetString(winbind_error, "lookup failed");
00300                 return NULL;            
00301         }
00302 
00303         return PyString_FromString(response.data.sid.sid);
00304 }
00305 
00306 /* Convert a gid to a SID */
00307 
00308 static PyObject *py_gid_to_sid(PyObject *self, PyObject *args)
00309 {
00310         struct winbindd_request request;
00311         struct winbindd_response response;
00312         int id;
00313 
00314         if (!PyArg_ParseTuple(args, "i", &id))
00315                 return NULL;
00316 
00317         ZERO_STRUCT(request);
00318         ZERO_STRUCT(response);
00319 
00320         request.data.gid = id;
00321 
00322         if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) 
00323             != NSS_STATUS_SUCCESS) {
00324                 PyErr_SetString(winbind_error, "lookup failed");
00325                 return NULL;            
00326         }
00327 
00328         return PyString_FromString(response.data.sid.sid);
00329 }
00330 
00331 /* Convert a sid to a uid */
00332 
00333 static PyObject *py_sid_to_uid(PyObject *self, PyObject *args)
00334 {
00335         struct winbindd_request request;
00336         struct winbindd_response response;
00337         char *sid;
00338 
00339         if (!PyArg_ParseTuple(args, "s", &sid))
00340                 return NULL;
00341 
00342         ZERO_STRUCT(request);
00343         ZERO_STRUCT(response);
00344 
00345         fstrcpy(request.data.sid, sid);
00346 
00347         if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) 
00348             != NSS_STATUS_SUCCESS) {
00349                 PyErr_SetString(winbind_error, "lookup failed");
00350                 return NULL;            
00351         }
00352 
00353         return PyInt_FromLong(response.data.uid);
00354 }
00355 
00356 /* Convert a sid to a gid */
00357 
00358 static PyObject *py_sid_to_gid(PyObject *self, PyObject *args)
00359 {
00360         struct winbindd_request request;
00361         struct winbindd_response response;
00362         char *sid;
00363 
00364         if (!PyArg_ParseTuple(args, "s", &sid))
00365                 return NULL;
00366 
00367         ZERO_STRUCT(request);
00368         ZERO_STRUCT(response);
00369 
00370         fstrcpy(request.data.sid, sid);
00371 
00372         if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) 
00373             != NSS_STATUS_SUCCESS) {
00374                 PyErr_SetString(winbind_error, "lookup failed");
00375                 return NULL;            
00376         }
00377         
00378         return PyInt_FromLong(response.data.gid);
00379 }
00380 
00381 /*
00382  * PAM authentication functions
00383  */
00384 
00385 /* Plaintext authentication */
00386 
00387 static PyObject *py_auth_plaintext(PyObject *self, PyObject *args)
00388 {
00389         struct winbindd_request request;
00390         struct winbindd_response response;
00391         char *username, *password;
00392 
00393         if (!PyArg_ParseTuple(args, "ss", &username, &password))
00394                 return NULL;
00395 
00396         ZERO_STRUCT(request);
00397         ZERO_STRUCT(response);
00398 
00399         fstrcpy(request.data.auth.user, username);
00400         fstrcpy(request.data.auth.pass, password);
00401 
00402         if (winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response) 
00403             != NSS_STATUS_SUCCESS) {
00404                 PyErr_SetString(winbind_error, "lookup failed");
00405                 return NULL;            
00406         }
00407         
00408         return PyInt_FromLong(response.data.auth.nt_status);
00409 }
00410 
00411 /* Challenge/response authentication */
00412 
00413 static PyObject *py_auth_crap(PyObject *self, PyObject *args, PyObject *kw)
00414 {
00415         static char *kwlist[] = 
00416                 {"username", "password", "use_lm_hash", "use_nt_hash", NULL };
00417         struct winbindd_request request;
00418         struct winbindd_response response;
00419         char *username, *password;
00420         int use_lm_hash = 1, use_nt_hash = 1;
00421 
00422         if (!PyArg_ParseTupleAndKeywords(
00423                     args, kw, "ss|ii", kwlist, &username, &password, 
00424                     &use_lm_hash, &use_nt_hash))
00425                 return NULL;
00426 
00427         ZERO_STRUCT(request);
00428         ZERO_STRUCT(response);
00429 
00430         if (push_utf8_fstring(request.data.auth_crap.user, username) == -1) {
00431                 PyErr_SetString(winbind_error, "unable to create utf8 string");
00432                 return NULL;
00433         }
00434 
00435         generate_random_buffer(request.data.auth_crap.chal, 8);
00436         
00437         if (use_lm_hash) {
00438                 SMBencrypt((uchar *)password, request.data.auth_crap.chal, 
00439                            (uchar *)request.data.auth_crap.lm_resp);
00440                 request.data.auth_crap.lm_resp_len = 24;
00441         }
00442 
00443         if (use_nt_hash) {
00444                 SMBNTencrypt((uchar *)password, request.data.auth_crap.chal,
00445                              (uchar *)request.data.auth_crap.nt_resp);
00446                 request.data.auth_crap.nt_resp_len = 24;
00447         }
00448 
00449         if (winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response) 
00450             != NSS_STATUS_SUCCESS) {
00451                 PyErr_SetString(winbind_error, "lookup failed");
00452                 return NULL;            
00453         }
00454         
00455         return PyInt_FromLong(response.data.auth.nt_status);
00456 }
00457 
00458 #if 0                           /* Include when auth_smbd merged to HEAD */
00459 
00460 /* Challenge/response authentication, with secret */
00461 
00462 static PyObject *py_auth_smbd(PyObject *self, PyObject *args, PyObject *kw)
00463 {
00464         static char *kwlist[] = 
00465                 {"username", "password", "use_lm_hash", "use_nt_hash", NULL };
00466         struct winbindd_request request;
00467         struct winbindd_response response;
00468         char *username, *password;
00469         int use_lm_hash = 1, use_nt_hash = 1;
00470 
00471         if (!PyArg_ParseTupleAndKeywords(
00472                     args, kw, "ss|ii", kwlist, &username, &password, 
00473                     &use_lm_hash, &use_nt_hash))
00474                 return NULL;
00475 
00476         ZERO_STRUCT(request);
00477         ZERO_STRUCT(response);
00478 
00479         if (push_utf8_fstring(request.data.auth_crap.user, username) == -1) {
00480                 PyErr_SetString("unable to create utf8 string");
00481                 return NULL;
00482         }
00483 
00484         generate_random_buffer(request.data.smbd_auth_crap.chal, 8);
00485         
00486         if (use_lm_hash) {
00487                 SMBencrypt((uchar *)password, 
00488                            request.data.smbd_auth_crap.chal, 
00489                            (uchar *)request.data.smbd_auth_crap.lm_resp);
00490                 request.data.smbd_auth_crap.lm_resp_len = 24;
00491         }
00492 
00493         if (use_nt_hash) {
00494                 SMBNTencrypt((uchar *)password, 
00495                              request.data.smbd_auth_crap.chal,
00496                              (uchar *)request.data.smbd_auth_crap.nt_resp);
00497                 request.data.smbd_auth_crap.nt_resp_len = 24;
00498         }
00499 
00500         if (!secrets_fetch_trust_account_password(
00501                     lp_workgroup(), request.data.smbd_auth_crap.proof, NULL)) {
00502                 PyErr_SetString(
00503                         winbind_error, "unable to fetch domain secret");
00504                 return NULL;
00505         }
00506 
00507 
00508 
00509         if (winbindd_request_response(WINBINDD_SMBD_AUTH_CRAP, &request, &response) 
00510             != NSS_STATUS_SUCCESS) {
00511                 PyErr_SetString(winbind_error, "lookup failed");
00512                 return NULL;            
00513         }
00514         
00515         return PyInt_FromLong(response.data.auth.nt_status);
00516 }
00517 
00518 #endif /* 0 */
00519 
00520 /* Get user info from name */
00521 
00522 static PyObject *py_getpwnam(PyObject *self, PyObject *args)
00523 {
00524         struct winbindd_request request;
00525         struct winbindd_response response;
00526         char *username;
00527         PyObject *result;
00528 
00529         if (!PyArg_ParseTuple(args, "s", &username))
00530                 return NULL;
00531 
00532         ZERO_STRUCT(request);
00533         ZERO_STRUCT(response);
00534 
00535         fstrcpy(request.data.username, username);
00536 
00537         if (winbindd_request_response(WINBINDD_GETPWNAM, &request, &response) 
00538             != NSS_STATUS_SUCCESS) {
00539                 PyErr_SetString(winbind_error, "lookup failed");
00540                 return NULL;            
00541         }
00542         
00543         if (!py_from_winbind_passwd(&result, &response)) {
00544                 result = Py_None;
00545                 Py_INCREF(result);
00546         }
00547 
00548         return result;
00549 }
00550 
00551 /* Get user info from uid */
00552 
00553 static PyObject *py_getpwuid(PyObject *self, PyObject *args)
00554 {
00555         struct winbindd_request request;
00556         struct winbindd_response response;
00557         uid_t uid;
00558         PyObject *result;
00559 
00560         if (!PyArg_ParseTuple(args, "i", &uid))
00561                 return NULL;
00562 
00563         ZERO_STRUCT(request);
00564         ZERO_STRUCT(response);
00565 
00566         request.data.uid = uid;
00567 
00568         if (winbindd_request_response(WINBINDD_GETPWUID, &request, &response) 
00569             != NSS_STATUS_SUCCESS) {
00570                 PyErr_SetString(winbind_error, "lookup failed");
00571                 return NULL;            
00572         }
00573         
00574         if (!py_from_winbind_passwd(&result, &response)) {
00575                 result = Py_None;
00576                 Py_INCREF(result);
00577         }
00578 
00579         return result;
00580 }
00581 
00582 /*
00583  * Method dispatch table
00584  */
00585 
00586 static PyMethodDef winbind_methods[] = {
00587 
00588         { "getpwnam", (PyCFunction)py_getpwnam, METH_VARARGS, "getpwnam(3)" },
00589         { "getpwuid", (PyCFunction)py_getpwuid, METH_VARARGS, "getpwuid(3)" },
00590 
00591         /* Name <-> SID conversion */
00592 
00593         { "name_to_sid", (PyCFunction)py_name_to_sid, METH_VARARGS,
00594           "name_to_sid(s) -> string\n"
00595 "\n"
00596 "Return the SID for a name.\n"
00597 "\n"
00598 "Example:\n"
00599 "\n"
00600 ">>> winbind.name_to_sid('FOO/Administrator')\n"
00601 "'S-1-5-21-406022937-1377575209-526660263-500' " },
00602 
00603         { "sid_to_name", (PyCFunction)py_sid_to_name, METH_VARARGS,
00604           "sid_to_name(s) -> string\n"
00605 "\n"
00606 "Return the name for a SID.\n"
00607 "\n"
00608 "Example:\n"
00609 "\n"
00610 ">>> import winbind\n"
00611 ">>> winbind.sid_to_name('S-1-5-21-406022937-1377575209-526660263-500')\n"
00612 "'FOO/Administrator' " },
00613 
00614         /* Enumerate users/groups */
00615 
00616         { "enum_domain_users", (PyCFunction)py_enum_domain_users, METH_VARARGS,
00617           "enum_domain_users() -> list of strings\n"
00618 "\n"
00619 "Return a list of domain users.\n"
00620 "\n"
00621 "Example:\n"
00622 "\n"
00623 ">>> winbind.enum_domain_users()\n"
00624 "['FOO/Administrator', 'FOO/anna', 'FOO/Anne Elk', 'FOO/build', \n"
00625 "'FOO/foo', 'FOO/foo2', 'FOO/foo3', 'FOO/Guest', 'FOO/user1', \n"
00626 "'FOO/whoops-ptang'] " },
00627 
00628         { "enum_domain_groups", (PyCFunction)py_enum_domain_groups, 
00629           METH_VARARGS,
00630           "enum_domain_groups() -> list of strings\n"
00631 "\n"
00632 "Return a list of domain groups.\n"
00633 "\n"
00634 "Example:\n"
00635 "\n"
00636 ">>> winbind.enum_domain_groups()\n"
00637 "['FOO/cows', 'FOO/Domain Admins', 'FOO/Domain Guests', \n"
00638 "'FOO/Domain Users'] " },
00639 
00640         /* ID mapping */
00641 
00642         { "uid_to_sid", (PyCFunction)py_uid_to_sid, METH_VARARGS,
00643           "uid_to_sid(int) -> string\n"
00644 "\n"
00645 "Return the SID for a UNIX uid.\n"
00646 "\n"
00647 "Example:\n"
00648 "\n"
00649 ">>> winbind.uid_to_sid(10000)   \n"
00650 "'S-1-5-21-406022937-1377575209-526660263-500' " },
00651 
00652         { "gid_to_sid", (PyCFunction)py_gid_to_sid, METH_VARARGS,
00653           "gid_to_sid(int) -> string\n"
00654 "\n"
00655 "Return the UNIX gid for a SID.\n"
00656 "\n"
00657 "Example:\n"
00658 "\n"
00659 ">>> winbind.gid_to_sid(10001)\n"
00660 "'S-1-5-21-406022937-1377575209-526660263-512' " },
00661 
00662         { "sid_to_uid", (PyCFunction)py_sid_to_uid, METH_VARARGS,
00663           "sid_to_uid(string) -> int\n"
00664 "\n"
00665 "Return the UNIX uid for a SID.\n"
00666 "\n"
00667 "Example:\n"
00668 "\n"
00669 ">>> winbind.sid_to_uid('S-1-5-21-406022937-1377575209-526660263-500')\n"
00670 "10000 " },
00671 
00672         { "sid_to_gid", (PyCFunction)py_sid_to_gid, METH_VARARGS,
00673           "sid_to_gid(string) -> int\n"
00674 "\n"
00675 "Return the UNIX gid corresponding to a SID.\n"
00676 "\n"
00677 "Example:\n"
00678 "\n"
00679 ">>> winbind.sid_to_gid('S-1-5-21-406022937-1377575209-526660263-512')\n"
00680 "10001 " },
00681 
00682         /* Miscellaneous */
00683 
00684         { "check_secret", (PyCFunction)py_check_secret, METH_VARARGS,
00685           "check_secret() -> int\n"
00686 "\n"
00687 "Check the machine trust account password.  The NT status is returned\n"
00688 "with zero indicating success. " },
00689 
00690         { "enum_trust_dom", (PyCFunction)py_enum_trust_dom, METH_VARARGS,
00691           "enum_trust_dom() -> list of strings\n"
00692 "\n"
00693 "Return a list of trusted domains.  The domain the server is a member \n"
00694 "of is not included.\n"
00695 "\n"
00696 "Example:\n"
00697 "\n"
00698 ">>> winbind.enum_trust_dom()\n"
00699 "['NPSD-TEST2', 'SP2NDOM'] " },
00700 
00701         /* PAM authorisation functions */
00702 
00703         { "auth_plaintext", (PyCFunction)py_auth_plaintext, METH_VARARGS,
00704           "auth_plaintext(s, s) -> int\n"
00705 "\n"
00706 "Authenticate a username and password using plaintext authentication.\n"
00707 "The NT status code is returned with zero indicating success." },
00708 
00709         { "auth_crap", (PyCFunction)py_auth_crap, METH_VARARGS | METH_KEYWORDS,
00710           "auth_crap(s, s) -> int\n"
00711 "\n"
00712 "Authenticate a username and password using the challenge/response\n"
00713 "protocol.  The NT status code is returned with zero indicating\n"
00714 "success." },
00715 
00716 #if 0                           /* Include when smbd_auth merged to HEAD */
00717 
00718         { "auth_smbd", (PyCFunction)py_auth_crap, METH_VARARGS,
00719           "auth_smbd(s, s) -> int\n"
00720 "\n"
00721 "Authenticate a username and password using the challenge/response\n"
00722 "protocol but using the domain secret to prove we are root.  The NT \n"
00723 "status code is returned with zero indicating success." },
00724 
00725 #endif
00726 
00727         { NULL }
00728 };
00729 
00730 static struct const_vals {
00731         char *name;
00732         uint32 value;
00733         char *docstring;
00734 } module_const_vals[] = {
00735 
00736         /* Well known RIDs */
00737         
00738         { "DOMAIN_USER_RID_ADMIN", DOMAIN_USER_RID_ADMIN, 
00739           "Well-known RID for Administrator user" },
00740 
00741         { "DOMAIN_USER_RID_GUEST", DOMAIN_USER_RID_GUEST,
00742           "Well-known RID for Guest user" },
00743 
00744         { "DOMAIN_GROUP_RID_ADMINS", DOMAIN_GROUP_RID_ADMINS,
00745           "Well-known RID for Domain Admins group" },
00746 
00747         { "DOMAIN_GROUP_RID_USERS", DOMAIN_GROUP_RID_USERS,
00748           "Well-known RID for Domain Users group" },
00749 
00750         { "DOMAIN_GROUP_RID_GUESTS", DOMAIN_GROUP_RID_GUESTS,
00751           "Well-known RID for Domain Guests group" }, 
00752         
00753         { NULL }
00754 };
00755 
00756 static void const_init(PyObject *dict)
00757 {
00758         struct const_vals *tmp;
00759         PyObject *obj;
00760 
00761         for (tmp = module_const_vals; tmp->name; tmp++) {
00762                 obj = PyInt_FromLong(tmp->value);
00763                 PyDict_SetItemString(dict, tmp->name, obj);
00764                 Py_DECREF(obj);
00765         }
00766 }
00767 
00768 /*
00769  * Module initialisation 
00770  */
00771 
00772 static char winbind_module__doc__[] =
00773 "A python extension to winbind client functions.";
00774 
00775 void initwinbind(void)
00776 {
00777         PyObject *module, *dict;
00778 
00779         /* Initialise module */
00780 
00781         module = Py_InitModule3("winbind", winbind_methods,
00782                                 winbind_module__doc__);
00783 
00784         dict = PyModule_GetDict(module);
00785 
00786         winbind_error = PyErr_NewException("winbind.error", NULL, NULL);
00787         PyDict_SetItemString(dict, "error", winbind_error);
00788 
00789         /* Do samba initialisation */
00790 
00791         py_samba_init();
00792 
00793         /* Initialise constants */
00794 
00795         const_init(dict);
00796 
00797         /* Insert configuration dictionary */
00798 
00799         PyDict_SetItemString(dict, "config", py_config_dict());
00800 }

Sambaに対してSat Aug 29 21:23:14 2009に生成されました。  doxygen 1.4.7