]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
idmap tdb2: fix broken logic in tdb2_store_bystring().
authorMichael Adam <obnox@samba.org>
Wed, 6 Aug 2008 20:33:58 +0000 (22:33 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 13 Aug 2008 09:54:07 +0000 (11:54 +0200)
1. use the return value that idmap_tdb2_open_perm_db() gives us
2. don't write to the local db if writing to the perm db failed.
3. fix wrong interpretation of return value of the local store

Michael

source/winbindd/idmap_tdb2.c

index cb5e9ec6d408bac846e6cc8e0820a46c94ce8581..172922b85f387afec93c7f988511c6c071b1a375 100644 (file)
@@ -383,15 +383,18 @@ static TDB_DATA tdb2_fetch_bystring(TALLOC_CTX *mem_ctx, const char *keystr)
 static NTSTATUS tdb2_store_bystring(const char *keystr, TDB_DATA data, int flags)
 {
        NTSTATUS ret;
-       NTSTATUS status = idmap_tdb2_open_perm_db();
-       if (!NT_STATUS_IS_OK(status)) {
-               return NT_STATUS_UNSUCCESSFUL;
+
+       ret = idmap_tdb2_open_perm_db();
+       if (!NT_STATUS_IS_OK(ret)) {
+               return ret;
        }
        ret = dbwrap_store_bystring(idmap_tdb2_perm, keystr, data, flags);
        if (!NT_STATUS_IS_OK(ret)) {
-               ret = tdb_store_bystring(idmap_tdb2_tmp, keystr, data, flags) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+               return ret;
        }
-       return ret;
+       return (tdb_store_bystring(idmap_tdb2_tmp, keystr, data, flags) == 0)
+               ? NT_STATUS_OK
+               : NT_STATUS_UNSUCCESSFUL;
 }
 
 /*