diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-03-11 23:30:55 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-12 09:22:15 -0400 |
commit | 40bb1ddf0a3f69922466b2b99bcdaf7746fc81ba (patch) | |
tree | d1e643223e87a99166a5c8b0493582f76914feba /src/python | |
parent | 488d314e6a330b92516577fe889bde52393288b4 (diff) | |
download | sssd-40bb1ddf0a3f69922466b2b99bcdaf7746fc81ba.tar.gz sssd-40bb1ddf0a3f69922466b2b99bcdaf7746fc81ba.tar.xz sssd-40bb1ddf0a3f69922466b2b99bcdaf7746fc81ba.zip |
Use the sysdb synchronous transaction functions
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/pysss.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/src/python/pysss.c b/src/python/pysss.c index bd6d16e36..48c5aea2e 100644 --- a/src/python/pysss.c +++ b/src/python/pysss.c @@ -237,25 +237,22 @@ static PyObject *py_sss_useradd(PySssLocalObject *self, } /* Add the user within a transaction */ - start_transaction(tctx); + tctx->error = sysdb_transaction_start(tctx->sysdb); if (tctx->error != EOK) { PyErr_SetSssError(tctx->error); goto fail; } /* useradd */ - ret = useradd(tctx, self->ev, - self->sysdb, tctx->handle, tctx->octx); - if (ret != EOK) { - tctx->error = ret; - + tctx->error = useradd(tctx, tctx->sysdb, tctx->octx); + if (tctx->error) { /* cancel transaction */ - talloc_zfree(tctx->handle); + sysdb_transaction_cancel(tctx->sysdb); PyErr_SetSssError(tctx->error); goto fail; } - end_transaction(tctx); + tctx->error = sysdb_transaction_commit(tctx->sysdb); if (tctx->error) { PyErr_SetSssError(tctx->error); goto fail; @@ -435,7 +432,6 @@ static PyObject *py_sss_usermod(PySssLocalObject *self, PyObject *kwds) { struct tools_ctx *tctx = NULL; - int ret; PyObject *py_addgroups = Py_None; PyObject *py_rmgroups = Py_None; unsigned long uid = 0; @@ -506,25 +502,22 @@ static PyObject *py_sss_usermod(PySssLocalObject *self, tctx->octx->lock = lock; /* Modify the user within a transaction */ - start_transaction(tctx); + tctx->error = sysdb_transaction_start(tctx->sysdb); if (tctx->error != EOK) { PyErr_SetSssError(tctx->error); goto fail; } /* usermod */ - ret = usermod(tctx, self->ev, - self->sysdb, tctx->handle, tctx->octx); - if (ret != EOK) { - tctx->error = ret; - + tctx->error = usermod(tctx, tctx->sysdb, tctx->octx); + if (tctx->error) { /* cancel transaction */ - talloc_zfree(tctx->handle); + sysdb_transaction_cancel(tctx->sysdb); PyErr_SetSssError(tctx->error); goto fail; } - end_transaction(tctx); + tctx->error = sysdb_transaction_commit(tctx->sysdb); if (tctx->error) { PyErr_SetSssError(tctx->error); goto fail; @@ -555,7 +548,6 @@ static PyObject *py_sss_groupadd(PySssLocalObject *self, struct tools_ctx *tctx = NULL; char *groupname; unsigned long gid = 0; - int ret; const char * const kwlist[] = { "groupname", "gid", NULL }; /* parse arguments */ @@ -577,25 +569,22 @@ static PyObject *py_sss_groupadd(PySssLocalObject *self, tctx->octx->gid = gid; /* Add the group within a transaction */ - start_transaction(tctx); + tctx->error = sysdb_transaction_start(tctx->sysdb); if (tctx->error != EOK) { PyErr_SetSssError(tctx->error); goto fail; } /* groupadd */ - ret = groupadd(tctx, self->ev, - self->sysdb, tctx->handle, tctx->octx); - if (ret != EOK) { - tctx->error = ret; - + tctx->error = groupadd(tctx, tctx->sysdb, tctx->octx); + if (tctx->error) { /* cancel transaction */ - talloc_zfree(tctx->handle); + sysdb_transaction_cancel(tctx->sysdb); PyErr_SetSssError(tctx->error); goto fail; } - end_transaction(tctx); + tctx->error = sysdb_transaction_commit(tctx->sysdb); if (tctx->error) { PyErr_SetSssError(tctx->error); goto fail; @@ -668,7 +657,6 @@ static PyObject *py_sss_groupmod(PySssLocalObject *self, PyObject *kwds) { struct tools_ctx *tctx = NULL; - int ret; PyObject *py_addgroups = Py_None; PyObject *py_rmgroups = Py_None; unsigned long gid = 0; @@ -717,25 +705,22 @@ static PyObject *py_sss_groupmod(PySssLocalObject *self, tctx->octx->gid = gid; /* Modify the group within a transaction */ - start_transaction(tctx); + tctx->error = sysdb_transaction_start(tctx->sysdb); if (tctx->error != EOK) { PyErr_SetSssError(tctx->error); goto fail; } /* groupmod */ - ret = groupmod(tctx, self->ev, - self->sysdb, tctx->handle, tctx->octx); - if (ret != EOK) { - tctx->error = ret; - + tctx->error = groupmod(tctx, tctx->sysdb, tctx->octx); + if (tctx->error) { /* cancel transaction */ - talloc_zfree(tctx->handle); + sysdb_transaction_cancel(tctx->sysdb); PyErr_SetSssError(tctx->error); goto fail; } - end_transaction(tctx); + tctx->error = sysdb_transaction_commit(tctx->sysdb); if (tctx->error) { PyErr_SetSssError(tctx->error); goto fail; |