File: src/python/pysss.c
Function: py_sss_usermod
Error: returning (PyObject*)NULL without setting an exception
418 static PyObject *py_sss_usermod(PySssLocalObject *self,
419                                 PyObject *args,
420                                 PyObject *kwds)
421 {
422     struct tools_ctx *tctx = NULL;
423     PyObject *py_addgroups = Py_None;
424     PyObject *py_rmgroups = Py_None;
425     unsigned long uid = 0;
426     unsigned long gid = 0;
427     char *gecos = NULL;
428     char *home = NULL;
429     char *shell = NULL;
430     char *username = NULL;
431     unsigned long lock = 0;
432     const char * const kwlist[] = { "username", "uid", "gid", "lock",
433                                     "gecos",  "homedir", "shell",
434                                     "addgroups", "rmgroups", NULL };
435 
436     /* parse arguments */
437     if (!PyArg_ParseTupleAndKeywords(args, kwds,
438                                      discard_const_p(char, "s|kkksssO!O!"),
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
439                                      discard_const_p(char *, kwlist),
440                                      &username,
441                                      &uid,
442                                      &gid,
443                                      &lock,
444                                      &gecos,
445                                      &home,
446                                      &shell,
447                                      &PyList_Type,
448                                      &py_addgroups,
449                                      &PyList_Type,
450                                      &py_rmgroups)) {
451         goto fail;
452     }
453 
454     tctx = init_ctx(self->mem_ctx, self);
455     if (!tctx) {
456         PyErr_NoMemory();
when treating unknown struct tools_ctx * from src/python/pysss.c:455 as non-NULL
taking False path
457         return NULL;
458     }
459 
460     if (lock && lock != DO_LOCK && lock != DO_UNLOCK) {
461         PyErr_SetString(PyExc_ValueError,
when considering range: 0 <= value <= 2
taking False path
462                         "Unkown value for lock parameter");
463         goto fail;
464     }
465 
466     if (py_addgroups != Py_None) {
467         tctx->octx->addgroups = PyList_AsStringList(tctx,
taking True path
468                                                     py_addgroups,
when treating unknown struct ops_ctx * from src/python/pysss.c:468 as non-NULL
469                                                     "addgroups");
470         if (!tctx->octx->addgroups) {
471             return NULL;
when treating unknown struct ops_ctx * from src/python/pysss.c:471 as non-NULL
when treating unknown char * * from src/python/pysss.c:471 as non-NULL
taking False path
472         }
473     }
474 
475     if (py_rmgroups != Py_None) {
476         tctx->octx->rmgroups = PyList_AsStringList(tctx,
taking True path
477                                                    py_rmgroups,
when treating unknown struct ops_ctx * from src/python/pysss.c:477 as non-NULL
478                                                    "rmgroups");
479         if (!tctx->octx->rmgroups) {
480             return NULL;
when treating unknown struct ops_ctx * from src/python/pysss.c:480 as non-NULL
when treating unknown char * * from src/python/pysss.c:480 as non-NULL
taking False path
481         }
482     }
483 
484     tctx->octx->name  = username;
485     tctx->octx->uid   = uid;
when treating unknown struct ops_ctx * from src/python/pysss.c:485 as non-NULL
486     tctx->octx->gid   = gid;
when treating unknown struct ops_ctx * from src/python/pysss.c:486 as non-NULL
487     tctx->octx->gecos = gecos;
when treating unknown struct ops_ctx * from src/python/pysss.c:487 as non-NULL
488     tctx->octx->home  = home;
when treating unknown struct ops_ctx * from src/python/pysss.c:488 as non-NULL
489     tctx->octx->shell = shell;
when treating unknown struct ops_ctx * from src/python/pysss.c:489 as non-NULL
490     tctx->octx->lock  = lock;
when treating unknown struct ops_ctx * from src/python/pysss.c:490 as non-NULL
491 
when treating unknown struct ops_ctx * from src/python/pysss.c:491 as non-NULL
492     /* Modify the user within a transaction */
493     tctx->error = sysdb_transaction_start(tctx->sysdb);
494     if (tctx->error != EOK) {
495         PyErr_SetSssError(tctx->error);
when considering range: -0x80000000 <= value <= -1
taking True path
496         goto fail;
497     }
498 
499     /* usermod */
500     tctx->error = usermod(tctx, tctx->sysdb, tctx->octx);
501     if (tctx->error) {
502         /* cancel transaction */
503         sysdb_transaction_cancel(tctx->sysdb);
504         PyErr_SetSssError(tctx->error);
505         goto fail;
506     }
507 
508     tctx->error = sysdb_transaction_commit(tctx->sysdb);
509     if (tctx->error) {
510         PyErr_SetSssError(tctx->error);
511         goto fail;
512     }
513 
514     talloc_zfree(tctx);
515     Py_RETURN_NONE;
516 
517 fail:
518     talloc_zfree(tctx);
519     return NULL;
520 }
521 
returning (PyObject*)NULL without setting an exception found 7 similar trace(s) to this