fix wrong debug messages in idmap_util.c
authorSimo Sorce <idra@samba.org>
Thu, 1 May 2003 16:02:55 +0000 (16:02 +0000)
committerSimo Sorce <idra@samba.org>
Thu, 1 May 2003 16:02:55 +0000 (16:02 +0000)
correctly handle allocated rids in tdbsam

source/passdb/pdb_tdb.c
source/sam/idmap_util.c

index 3ed5d2d4d683bfe8aacf126f66c443ed6887daff..74437cba6f33a540dec307493cba636263ef68ee 100644 (file)
@@ -640,7 +640,7 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT
                return nt_status;
        }
 
-       fstrcpy (name, data.dptr);
+       fstrcpy(name, data.dptr);
        SAFE_FREE(data.dptr);
        
        tdb_close (pwd_tdb);
@@ -771,6 +771,11 @@ static BOOL tdb_update_sam(struct pdb_methods *my_methods, SAM_ACCOUNT* newpwd,
                                ret = False;
                                goto done;
                        }
+                       if (!pdb_set_user_sid_from_rid(newpwd, user_rid, PDB_CHANGED)) {
+                               DEBUG(0, ("tdbsam: not able to set new allocated user RID into sam account!\n"));
+                               ret = False;
+                               goto done;
+                       }
                } else {
                        DEBUG (0,("tdb_update_sam: Failing to store a SAM_ACCOUNT for [%s] without a RID\n",pdb_get_username(newpwd)));
                        ret = False;
@@ -794,7 +799,7 @@ static BOOL tdb_update_sam(struct pdb_methods *my_methods, SAM_ACCOUNT* newpwd,
        /* setup the USER index key */
        slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
        key.dptr = keystr;
-       key.dsize = strlen (keystr) + 1;
+       key.dsize = strlen(keystr) + 1;
 
        /* add the account */
        if (tdb_store(pwd_tdb, key, data, flag) != TDB_SUCCESS) {
@@ -806,7 +811,7 @@ static BOOL tdb_update_sam(struct pdb_methods *my_methods, SAM_ACCOUNT* newpwd,
        }
        
        /* setup RID data */
-       data.dsize = sizeof(fstring);
+       data.dsize = strlen(name) + 1;
        data.dptr = name;
 
        /* setup the RID index key */
index 1508523ea6fb2050f83b076ffec279f26a9601b0..ff581d91bcdb797483c8689233989e5d79aa9837 100644 (file)
@@ -133,7 +133,7 @@ NTSTATUS uid_to_sid(DOM_SID *sid, uid_t uid)
 
        id.uid = uid;
        if (NT_STATUS_IS_ERR(ret = idmap_get_sid_from_id(sid, id, flags))) {
-               DEBUG(10, ("uid_to_sid: Failed to map sid = [%s]\n", sid_string_static(sid)));
+               DEBUG(10, ("uid_to_sid: Failed to map uid = [%s]\n", (unsigned int)uid));
                if (flags & ID_NOMAP) {
                        sid_copy(sid, get_global_sam_sid());
                        sid_append_rid(sid, fallback_pdb_uid_to_user_rid(uid));
@@ -170,7 +170,7 @@ NTSTATUS gid_to_sid(DOM_SID *sid, gid_t gid)
 
        id.gid = gid;
        if (NT_STATUS_IS_ERR(ret = idmap_get_sid_from_id(sid, id, flags))) {
-               DEBUG(10, ("gid_to_sid: Failed to map sid = [%s]\n", sid_string_static(sid)));
+               DEBUG(10, ("gid_to_sid: Failed to map gid = [%u]\n", (unsigned int)gid));
                if (flags & ID_NOMAP) {
                        sid_copy(sid, get_global_sam_sid());
                        sid_append_rid(sid, pdb_gid_to_group_rid(gid));