Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/auth/credentials/pycredentials.c

    r414 r745  
    1717*/
    1818
     19
    1920#include "includes.h"
    20 #include <Python.h>
    2121#include "pycredentials.h"
    2222#include "param/param.h"
     
    2525#include "libcli/util/pyerrors.h"
    2626#include "param/pyparam.h"
    27 
    28 #ifndef Py_RETURN_NONE
    29 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
    30 #endif
     27#include <tevent.h>
    3128
    3229static PyObject *PyString_FromStringOrNULL(const char *str)
     
    197194}
    198195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
    199206static PyObject *py_creds_guess(py_talloc_Object *self, PyObject *args)
    200207{
    201208        PyObject *py_lp_ctx = Py_None;
    202209        struct loadparm_context *lp_ctx;
     210
     211
     212
     213
     214
    203215        if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
    204216                return NULL;
    205217
    206         lp_ctx = lp_from_py_object(py_lp_ctx);
    207         if (lp_ctx == NULL)
    208                 return NULL;
    209 
    210         cli_credentials_guess(PyCredentials_AsCliCredentials(self), lp_ctx);
     218        mem_ctx = talloc_new(NULL);
     219        if (mem_ctx == NULL) {
     220                PyErr_NoMemory();
     221                return NULL;
     222        }
     223
     224        lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
     225        if (lp_ctx == NULL) {
     226                talloc_free(mem_ctx);
     227                return NULL;
     228        }
     229
     230        cli_credentials_guess(creds, lp_ctx);
     231
     232        talloc_free(mem_ctx);
    211233
    212234        Py_RETURN_NONE;
     
    218240        struct loadparm_context *lp_ctx;
    219241        NTSTATUS status;
     242
     243
     244
     245
     246
    220247        if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
    221248                return NULL;
    222249
    223         lp_ctx = lp_from_py_object(py_lp_ctx);
    224         if (lp_ctx == NULL)
    225                 return NULL;
    226 
    227         status = cli_credentials_set_machine_account(PyCredentials_AsCliCredentials(self), lp_ctx);
     250        mem_ctx = talloc_new(NULL);
     251        if (mem_ctx == NULL) {
     252                PyErr_NoMemory();
     253                return NULL;
     254        }
     255
     256        lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
     257        if (lp_ctx == NULL) {
     258                talloc_free(mem_ctx);
     259                return NULL;
     260        }
     261
     262        status = cli_credentials_set_machine_account(creds, lp_ctx);
     263        talloc_free(mem_ctx);
     264
    228265        PyErr_NTSTATUS_IS_ERR_RAISE(status);
    229266
    230267        Py_RETURN_NONE;
    231268}
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
    232355
    233356static PyMethodDef py_creds_methods[] = {
     
    285408        { "set_kerberos_state", (PyCFunction)py_creds_set_kerberos_state, METH_VARARGS,
    286409                NULL },
     410
     411
    287412        { "guess", (PyCFunction)py_creds_guess, METH_VARARGS, NULL },
    288413        { "set_machine_account", (PyCFunction)py_creds_set_machine_account, METH_VARARGS, NULL },
     414
     415
     416
    289417        { NULL }
    290418};
     
    293421        .tp_name = "Credentials",
    294422        .tp_basicsize = sizeof(py_talloc_Object),
    295         .tp_dealloc = py_talloc_dealloc,
    296423        .tp_new = py_creds_new,
    297424        .tp_flags = Py_TPFLAGS_DEFAULT,
     
    299426};
    300427
     428
     429
     430
     431
     432
     433
     434
    301435void initcredentials(void)
    302436{
    303437        PyObject *m;
     438
     439
     440
     441
     442
    304443
    305444        if (PyType_Ready(&PyCredentials) < 0)
     445
     446
     447
    306448                return;
    307449
     
    314456        PyModule_AddObject(m, "MUST_USE_KERBEROS", PyInt_FromLong(CRED_MUST_USE_KERBEROS));
    315457
     458
     459
     460
     461
    316462        Py_INCREF(&PyCredentials);
    317463        PyModule_AddObject(m, "Credentials", (PyObject *)&PyCredentials);
    318 }
     464        Py_INCREF(&PyCredentialCacheContainer);
     465        PyModule_AddObject(m, "CredentialCacheContainer", (PyObject *)&PyCredentialCacheContainer);
     466}
Note: See TracChangeset for help on using the changeset viewer.