Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/auth/pyauth.c

    r740 r988  
    3131#include <tevent.h>
    3232#include "librpc/rpc/pyrpc_util.h"
     33#include "lib/events/events.h"
     34
     35void initauth(void);
    3336
    3437staticforward PyTypeObject PyAuthContext;
    3538
    36 /* There's no Py_ssize_t in 2.4, apparently */
    37 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
    38 typedef int Py_ssize_t;
    39 typedef inquiry lenfunc;
    40 typedef intargfunc ssizeargfunc;
    41 #endif
    42 
    43 #ifndef Py_RETURN_NONE
    44 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
    45 #endif
    46 
    47 static PyObject *py_auth_session_get_security_token(PyObject *self, void *closure)
    48 {
    49         struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
    50         PyObject *py_security_token;
    51         py_security_token = py_return_ndr_struct("samba.dcerpc.security", "token",
    52                                                  session->security_token, session->security_token);
    53         return py_security_token;
    54 }
    55 
    56 static int py_auth_session_set_security_token(PyObject *self, PyObject *value, void *closure)
    57 {
    58         struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
    59         session->security_token = talloc_reference(session, py_talloc_get_ptr(value));
    60         return 0;
    61 }
    62 
    63 static PyObject *py_auth_session_get_session_key(PyObject *self, void *closure)
    64 {
    65         struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
    66         return PyString_FromStringAndSize((char *)session->session_key.data, session->session_key.length);
    67 }
    68 
    69 static int py_auth_session_set_session_key(PyObject *self, PyObject *value, void *closure)
    70 {
    71         DATA_BLOB val;
    72         struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
    73         val.data = (uint8_t *)PyString_AsString(value);
    74         val.length = PyString_Size(value);
    75 
    76         session->session_key = data_blob_talloc(session, val.data, val.length);
    77         return 0;
    78 }
    79 
    80 static PyObject *py_auth_session_get_credentials(PyObject *self, void *closure)
    81 {
    82         struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
    83         PyObject *py_credentials;
    84         /* This is evil, as the credentials are not IDL structures */
    85         py_credentials = py_return_ndr_struct("samba.credentials", "Credentials", session->credentials, session->credentials);
    86         return py_credentials;
    87 }
    88 
    89 static int py_auth_session_set_credentials(PyObject *self, PyObject *value, void *closure)
    90 {
    91         struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
    92         session->credentials = talloc_reference(session, PyCredentials_AsCliCredentials(value));
    93         return 0;
    94 }
    95 
    96 static PyGetSetDef py_auth_session_getset[] = {
    97         { discard_const_p(char, "security_token"), (getter)py_auth_session_get_security_token, (setter)py_auth_session_set_security_token, NULL },
    98         { discard_const_p(char, "session_key"), (getter)py_auth_session_get_session_key, (setter)py_auth_session_set_session_key, NULL },
    99         { discard_const_p(char, "credentials"), (getter)py_auth_session_get_credentials, (setter)py_auth_session_set_credentials, NULL },
    100         { NULL }
    101 };
    102 
    103 static PyTypeObject PyAuthSession = {
    104         .tp_name = "AuthSession",
    105         .tp_basicsize = sizeof(py_talloc_Object),
    106         .tp_flags = Py_TPFLAGS_DEFAULT,
    107         .tp_getset = py_auth_session_getset,
    108 };
    109 
    110 PyObject *PyAuthSession_FromSession(struct auth_session_info *session)
    111 {
    112         return py_talloc_reference(&PyAuthSession, session);
     39static PyObject *PyAuthSession_FromSession(struct auth_session_info *session)
     40{
     41        return py_return_ndr_struct("samba.dcerpc.auth", "session_info", session, session);
    11342}
    11443
     
    208137        }
    209138
    210         ldb_ctx = PyLdb_AsLdbContext(py_ldb);
     139        ldb_ctx = pyldb_Ldb_AsLdbContext(py_ldb);
    211140
    212141        if (py_dn == Py_None) {
    213142                user_dn = NULL;
    214143        } else {
    215                 if (!PyObject_AsDn(ldb_ctx, py_dn, ldb_ctx, &user_dn)) {
     144                if (!pyldb_Object_AsDn(ldb_ctx, py_dn, ldb_ctx, &user_dn)) {
    216145                        talloc_free(mem_ctx);
    217146                        return NULL;
     
    267196}
    268197
    269 static PyObject *PyAuthContext_FromContext(struct auth_context *auth_context)
    270 {
    271         return py_talloc_reference(&PyAuthContext, auth_context);
     198static PyObject *PyAuthContext_FromContext(struct auth4_context *auth_context)
     199{
     200        return pytalloc_reference(&PyAuthContext, auth_context);
    272201}
    273202
     
    276205        PyObject *py_lp_ctx = Py_None;
    277206        PyObject *py_ldb = Py_None;
    278         PyObject *py_messaging_ctx = Py_None;
     207        PyObject *py_imessaging_ctx = Py_None;
    279208        PyObject *py_auth_context = Py_None;
    280209        PyObject *py_methods = Py_None;
    281210        TALLOC_CTX *mem_ctx;
    282         struct auth_context *auth_context;
    283         struct messaging_context *messaging_context = NULL;
     211        struct auth4_context *auth_context;
     212        struct imessaging_context *imessaging_context = NULL;
    284213        struct loadparm_context *lp_ctx;
    285214        struct tevent_context *ev;
    286         struct ldb_context *ldb;
     215        struct ldb_context *ldb = NULL;
    287216        NTSTATUS nt_status;
    288217        const char **methods;
     
    292221        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO",
    293222                                         discard_const_p(char *, kwnames),
    294                                          &py_lp_ctx, &py_messaging_ctx, &py_ldb, &py_methods))
     223                                         &py_lp_ctx, &py_imessaging_ctx, &py_ldb, &py_methods))
    295224                return NULL;
    296225
     
    302231
    303232        if (py_ldb != Py_None) {
    304                 ldb = PyLdb_AsLdbContext(py_ldb);
     233                ldb = pyldb_Ldb_AsLdbContext(py_ldb);
    305234        }
    306235
    307236        lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
    308 
    309         ev = tevent_context_init(mem_ctx);
     237        if (lp_ctx == NULL) {
     238                PyErr_NoMemory();
     239                return NULL;
     240        }
     241
     242        ev = s4_event_context_init(mem_ctx);
    310243        if (ev == NULL) {
    311244                PyErr_NoMemory();
     
    313246        }
    314247
    315         if (py_messaging_ctx != Py_None) {
    316                 messaging_context = py_talloc_get_type(py_messaging_ctx, struct messaging_context);
     248        if (py_imessaging_ctx != Py_None) {
     249                imessaging_context = pytalloc_get_type(py_imessaging_ctx, struct imessaging_context);
    317250        }
    318251
    319252        if (py_methods == Py_None && py_ldb == Py_None) {
    320                 nt_status = auth_context_create(mem_ctx, ev, messaging_context, lp_ctx, &auth_context);
     253                nt_status = auth_context_create(mem_ctx, ev, imessaging_context, lp_ctx, &auth_context);
    321254        } else {
    322255                if (py_methods != Py_None) {
     
    330263                }
    331264                nt_status = auth_context_create_methods(mem_ctx, methods, ev,
    332                                                         messaging_context, lp_ctx,
     265                                                        imessaging_context, lp_ctx,
    333266                                                        ldb, &auth_context);
    334267        }
     
    360293static PyTypeObject PyAuthContext = {
    361294        .tp_name = "AuthContext",
    362         .tp_basicsize = sizeof(py_talloc_Object),
    363295        .tp_flags = Py_TPFLAGS_DEFAULT,
    364296        .tp_new = py_auth_context_new,
    365         .tp_basicsize = sizeof(py_talloc_Object),
    366297};
    367298
     
    377308        PyObject *m;
    378309
    379         PyAuthSession.tp_base = PyTalloc_GetObjectType();
    380         if (PyAuthSession.tp_base == NULL)
    381                 return;
    382 
    383         if (PyType_Ready(&PyAuthSession) < 0)
    384                 return;
    385 
    386         PyAuthContext.tp_base = PyTalloc_GetObjectType();
    387         if (PyAuthContext.tp_base == NULL)
    388                 return;
    389 
    390         if (PyType_Ready(&PyAuthContext) < 0)
     310        if (pytalloc_BaseObject_PyType_Ready(&PyAuthContext) < 0)
    391311                return;
    392312
     
    396316                return;
    397317
    398         Py_INCREF(&PyAuthSession);
    399         PyModule_AddObject(m, "AuthSession", (PyObject *)&PyAuthSession);
    400318        Py_INCREF(&PyAuthContext);
    401319        PyModule_AddObject(m, "AuthContext", (PyObject *)&PyAuthContext);
Note: See TracChangeset for help on using the changeset viewer.