643 static PyObject *py_sss_groupmod(PySssLocalObject *self,
644 PyObject *args,
645 PyObject *kwds)
646 {
647 struct tools_ctx *tctx = NULL;
648 PyObject *py_addgroups = Py_None;
649 PyObject *py_rmgroups = Py_None;
650 unsigned long gid = 0;
651 char *groupname = NULL;
652 const char * const kwlist[] = { "groupname", "gid", "addgroups",
653 "rmgroups", NULL };
654
655 /* parse arguments */
656 if (!PyArg_ParseTupleAndKeywords(args, kwds,
657 discard_const_p(char, "s|kO!O!"),
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
658 discard_const_p(char *, kwlist),
659 &groupname,
660 &gid,
661 &PyList_Type,
662 &py_addgroups,
663 &PyList_Type,
664 &py_rmgroups)) {
665 goto fail;
666 }
667
668 tctx = init_ctx(self->mem_ctx, self);
669 if (!tctx) {
670 PyErr_NoMemory();
when treating unknown struct tools_ctx * from src/python/pysss.c:669 as non-NULL
taking False path
671 return NULL;
672 }
673
674 if (py_addgroups != Py_None) {
675 tctx->octx->addgroups = PyList_AsStringList(tctx,
taking True path
676 py_addgroups,
when treating unknown struct ops_ctx * from src/python/pysss.c:676 as non-NULL
677 "addgroups");
678 if (!tctx->octx->addgroups) {
679 return NULL;
when treating unknown struct ops_ctx * from src/python/pysss.c:679 as non-NULL
when treating unknown char * * from src/python/pysss.c:679 as non-NULL
taking False path
680 }
681 }
682
683 if (py_rmgroups != Py_None) {
684 tctx->octx->rmgroups = PyList_AsStringList(tctx,
taking True path
685 py_rmgroups,
when treating unknown struct ops_ctx * from src/python/pysss.c:685 as non-NULL
686 "rmgroups");
687 if (!tctx->octx->rmgroups) {
688 return NULL;
when treating unknown struct ops_ctx * from src/python/pysss.c:688 as non-NULL
when treating unknown char * * from src/python/pysss.c:688 as non-NULL
taking False path
689 }
690 }
691
692 tctx->octx->name = groupname;
693 tctx->octx->gid = gid;
when treating unknown struct ops_ctx * from src/python/pysss.c:693 as non-NULL
694
when treating unknown struct ops_ctx * from src/python/pysss.c:694 as non-NULL
695 /* Modify the group within a transaction */
696 tctx->error = sysdb_transaction_start(tctx->sysdb);
697 if (tctx->error != EOK) {
698 PyErr_SetSssError(tctx->error);
when considering range: -0x80000000 <= value <= -1
taking True path
699 goto fail;
700 }
701
702 /* groupmod */
703 tctx->error = groupmod(tctx, tctx->sysdb, tctx->octx);
704 if (tctx->error) {
705 /* cancel transaction */
706 sysdb_transaction_cancel(tctx->sysdb);
707 PyErr_SetSssError(tctx->error);
708 goto fail;
709 }
710
711 tctx->error = sysdb_transaction_commit(tctx->sysdb);
712 if (tctx->error) {
713 PyErr_SetSssError(tctx->error);
714 goto fail;
715 }
716
717 talloc_zfree(tctx);
718 Py_RETURN_NONE;
719
720 fail:
721 talloc_zfree(tctx);
722 return NULL;
723 }
724