Turn the pdb_rid_algorithm into a capabilities call that returns flags
[metze/samba/wip.git] / source3 / passdb / pdb_smbpasswd.c
index 6cf54fbdf66bda3206111b29bd8dd7a97e4e7fc1..cac95c40a91e40bc80fd8e0f571bd4a1fdea6f51 100644 (file)
@@ -100,7 +100,7 @@ static bool do_file_lock(int fd, int waitsecs, int type)
        alarm(0);
        CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler);
 
-       if (gotalarm) {
+       if (gotalarm && ret == -1) {
                DEBUG(0, ("do_file_lock: failed to %s file.\n",
                        type == F_UNLCK ? "unlock" : "lock"));
                return False;
@@ -292,7 +292,7 @@ Error was %s\n", pfile, strerror(errno)));
                                return NULL;
                        }
 
-                       if( sbuf1.st_ino == sbuf2.st_ino) {
+                       if( sbuf1.st_ex_ino == sbuf2.st_ex_ino) {
                                /* No race. */
                                break;
                        }
@@ -1251,8 +1251,10 @@ static bool build_sam_account(struct smbpasswd_privates *smbpasswd_state,
 
        /* set remaining fields */
                
-       pdb_set_nt_passwd (sam_pass, pw_buf->smb_nt_passwd, PDB_SET);
-       pdb_set_lanman_passwd (sam_pass, pw_buf->smb_passwd, PDB_SET);                  
+       if (!pdb_set_nt_passwd (sam_pass, pw_buf->smb_nt_passwd, PDB_SET))
+               return False;
+       if (!pdb_set_lanman_passwd (sam_pass, pw_buf->smb_passwd, PDB_SET))
+               return False;
        pdb_set_acct_ctrl (sam_pass, pw_buf->acct_ctrl, PDB_SET);
        pdb_set_pass_last_set_time (sam_pass, pw_buf->pass_last_set_time, PDB_SET);
        pdb_set_pass_can_change_time (sam_pass, pw_buf->pass_last_set_time, PDB_SET);
@@ -1518,9 +1520,9 @@ done:
        return (ret);   
 }
 
-static bool smbpasswd_rid_algorithm(struct pdb_methods *methods)
+static uint32_t smbpasswd_capabilities(struct pdb_methods *methods)
 {
-       return True;
+       return 0;
 }
 
 static void free_private_data(void **vp) 
@@ -1559,8 +1561,24 @@ static bool smbpasswd_search_next_entry(struct pdb_search *search,
                return false;
        }
 
-       *entry = state->entries[state->current++];
+       entry->idx = state->entries[state->current].idx;
+       entry->rid = state->entries[state->current].rid;
+       entry->acct_flags = state->entries[state->current].acct_flags;
+
+       entry->account_name = talloc_strdup(
+               search, state->entries[state->current].account_name);
+       entry->fullname = talloc_strdup(
+               search, state->entries[state->current].fullname);
+       entry->description = talloc_strdup(
+               search, state->entries[state->current].description);
+
+       if ((entry->account_name == NULL) || (entry->fullname == NULL)
+           || (entry->description == NULL)) {
+               DEBUG(0, ("talloc_strdup failed\n"));
+               return false;
+       }
 
+       state->current += 1;
        return true;
 }
 
@@ -1575,8 +1593,7 @@ static bool smbpasswd_search_users(struct pdb_methods *methods,
        struct smb_passwd *pwd;
        FILE *fp;
 
-       search_state = TALLOC_ZERO_P(search->mem_ctx,
-                                    struct smbpasswd_search_state);
+       search_state = talloc_zero(search, struct smbpasswd_search_state);
        if (search_state == NULL) {
                DEBUG(0, ("talloc failed\n"));
                return false;
@@ -1665,7 +1682,7 @@ static NTSTATUS pdb_init_smbpasswd( struct pdb_methods **pdb_method, const char
        (*pdb_method)->rename_sam_account = smbpasswd_rename_sam_account;
        (*pdb_method)->search_users = smbpasswd_search_users;
 
-       (*pdb_method)->rid_algorithm = smbpasswd_rid_algorithm;
+       (*pdb_method)->capabilities = smbpasswd_capabilities;
 
        /* Setup private data and free function */