532 static PyObject *py_sss_groupadd(PySssLocalObject *self,
533 PyObject *args,
534 PyObject *kwds)
535 {
536 struct tools_ctx *tctx = NULL;
537 char *groupname;
538 unsigned long gid = 0;
539 const char * const kwlist[] = { "groupname", "gid", NULL };
540
541 /* parse arguments */
542 if (!PyArg_ParseTupleAndKeywords(args, kwds,
543 discard_const_p(char, "s|k"),
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
544 discard_const_p(char *, kwlist),
545 &groupname,
546 &gid)) {
547 goto fail;
548 }
549
550 tctx = init_ctx(self->mem_ctx, self);
551 if (!tctx) {
552 PyErr_NoMemory();
when treating unknown struct tools_ctx * from src/python/pysss.c:551 as non-NULL
taking False path
553 return NULL;
554 }
555
556 tctx->octx->name = groupname;
557 tctx->octx->gid = gid;
when treating unknown struct ops_ctx * from src/python/pysss.c:557 as non-NULL
558
when treating unknown struct ops_ctx * from src/python/pysss.c:558 as non-NULL
559 /* Add the group within a transaction */
560 tctx->error = sysdb_transaction_start(tctx->sysdb);
561 if (tctx->error != EOK) {
562 PyErr_SetSssError(tctx->error);
when considering range: -0x80000000 <= value <= -1
taking True path
563 goto fail;
564 }
565
566 /* groupadd */
567 tctx->error = groupadd(tctx, tctx->sysdb, tctx->octx);
568 if (tctx->error) {
569 /* cancel transaction */
570 sysdb_transaction_cancel(tctx->sysdb);
571 PyErr_SetSssError(tctx->error);
572 goto fail;
573 }
574
575 tctx->error = sysdb_transaction_commit(tctx->sysdb);
576 if (tctx->error) {
577 PyErr_SetSssError(tctx->error);
578 goto fail;
579 }
580
581 talloc_zfree(tctx);
582 Py_RETURN_NONE;
583
584 fail:
585 talloc_zfree(tctx);
586 return NULL;
587 }
588