summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-10-21 17:00:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:36 -0500
commit2a10d7686553a2c2377165b7f80269d2dcae8847 (patch)
tree57aeaaf00ce40449e9a603d05124ce22c6636d36 /source3/lib
parentf916352de90f5f5cd1e33d7264895e9d7e2992b5 (diff)
downloadsamba-2a10d7686553a2c2377165b7f80269d2dcae8847.tar.gz
samba-2a10d7686553a2c2377165b7f80269d2dcae8847.tar.bz2
samba-2a10d7686553a2c2377165b7f80269d2dcae8847.zip
r19448: Convert delete_share_security to struct share_params plus some cleanups
(This used to be commit c73d0815a3a1f58b951caa62fac601a8f4630894)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/sharesec.c9
-rw-r--r--source3/lib/util_tdb.c29
2 files changed, 34 insertions, 4 deletions
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index 0c8035e3dc..81b383d167 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -188,18 +188,19 @@ out:
Delete a security descriptor.
********************************************************************/
-BOOL delete_share_security(int snum)
+BOOL delete_share_security(const struct share_params *params)
{
TDB_DATA kbuf;
fstring key;
- slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum));
+ slprintf(key, sizeof(key)-1, "SECDESC/%s",
+ lp_servicename(params->service));
kbuf.dptr = key;
kbuf.dsize = strlen(key)+1;
- if (tdb_delete(share_tdb, kbuf) != 0) {
+ if (tdb_trans_delete(share_tdb, kbuf) != 0) {
DEBUG(0,("delete_share_security: Failed to delete entry for share %s\n",
- lp_servicename(snum) ));
+ lp_servicename(params->service) ));
return False;
}
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c
index 3e18c09fbf..e847c79369 100644
--- a/source3/lib/util_tdb.c
+++ b/source3/lib/util_tdb.c
@@ -809,3 +809,32 @@ int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
return res;
}
+
+/****************************************************************************
+ tdb_delete, wrapped in a transaction. This way we make sure that a process
+ that dies within deleting does not leave a corrupt tdb behind.
+****************************************************************************/
+
+int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key)
+{
+ int res;
+
+ if ((res = tdb_transaction_start(tdb)) != 0) {
+ DEBUG(5, ("tdb_transaction_start failed\n"));
+ return res;
+ }
+
+ if ((res = tdb_delete(tdb, key)) != 0) {
+ DEBUG(10, ("tdb_delete failed\n"));
+ if (tdb_transaction_cancel(tdb) != 0) {
+ smb_panic("Cancelling transaction failed\n");
+ }
+ return res;
+ }
+
+ if ((res = tdb_transaction_commit(tdb)) != 0) {
+ DEBUG(5, ("tdb_transaction_commit failed\n"));
+ }
+
+ return res;
+}