idmap_tdb: Use dom_sid_str_buf
[amitay/samba.git] / source3 / winbindd / idmap_tdb.c
index cc930fffb7a40f4e6652a150aa68eb2a12d2bfa9..c3215c4dd9b0f4f29db3cf6d385536a134e7e78a 100644 (file)
@@ -62,8 +62,8 @@ static int convert_fn(struct db_record *rec, void *private_data)
        char *p;
        NTSTATUS status;
        struct dom_sid sid;
-       uint32 rid;
-       fstring keystr;
+       uint32_t rid;
+       struct dom_sid_buf keystr;
        fstring dom_name;
        TDB_DATA key;
        TDB_DATA key2;
@@ -104,8 +104,7 @@ static int convert_fn(struct db_record *rec, void *private_data)
 
        sid_compose(&sid, &domain->sid, rid);
 
-       sid_to_fstring(keystr, &sid);
-       key2 = string_term_tdb_data(keystr);
+       key2 = string_term_tdb_data(dom_sid_str_buf(&sid, &keystr));
 
        value = dbwrap_record_get_value(rec);
 
@@ -145,7 +144,7 @@ static int convert_fn(struct db_record *rec, void *private_data)
 
 static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
 {
-       int32 vers;
+       int32_t vers;
        struct convert_fn_state s;
        NTSTATUS status;
 
@@ -161,7 +160,7 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
                 * big endian machine and will need byte-reversing.
                 */
 
-               int32 wm;
+               int32_t wm;
 
                status = dbwrap_fetch_int32_bystring(db, HWM_USER, &wm);
                if (!NT_STATUS_IS_OK(status)) {
@@ -310,7 +309,7 @@ static NTSTATUS idmap_tdb_open_db(struct idmap_domain *dom)
        mem_ctx = talloc_stackframe();
 
        /* use the old database if present */
-       tdbfile = state_path("winbindd_idmap.tdb");
+       tdbfile = state_path(talloc_tos(), "winbindd_idmap.tdb");
        if (!tdbfile) {
                DEBUG(0, ("Out of memory!\n"));
                ret = NT_STATUS_NO_MEMORY;
@@ -321,7 +320,7 @@ static NTSTATUS idmap_tdb_open_db(struct idmap_domain *dom)
 
        /* Open idmap repository */
        db = db_open(mem_ctx, tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644,
-                    DBWRAP_LOCK_ORDER_1);
+                    DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
        if (!db) {
                DEBUG(0, ("Unable to open idmap database\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
@@ -434,7 +433,7 @@ static struct idmap_methods db_methods = {
        .allocate_id = idmap_tdb_common_get_new_id,
 };
 
-NTSTATUS idmap_tdb_init(void)
+NTSTATUS idmap_tdb_init(TALLOC_CTX *mem_ctx)
 {
        DEBUG(10, ("calling idmap_tdb_init\n"));