s3:auth:check_sam_security: improve calling and logging of pdb_update_sam_account
authorMichael Adam <obnox@samba.org>
Wed, 6 Jan 2010 12:53:10 +0000 (13:53 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 25 Jan 2010 11:49:25 +0000 (12:49 +0100)
Log what went wrongl, and also call pdb_update_sam_account inside
become_root/unbecome_root: do the logging outside.

Michael
(cherry picked from commit 640dfa851a296a403e218096444b203da13ebf10)

source3/auth/auth_sam.c

index 7835b1818325708d4212bf65f65c13b956510b67..e7b9f2b019098299184b1db59e17b1edc5d733b7 100644 (file)
@@ -365,10 +365,16 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
                                                      &updated_badpw);
                }
                if (updated_autolock || updated_badpw){
+                       NTSTATUS status;
+
                        become_root();
-                       if(!NT_STATUS_IS_OK(pdb_update_sam_account(sampass)))
-                               DEBUG(1, ("Failed to modify entry.\n"));
+                       status = pdb_update_sam_account(sampass);
                        unbecome_root();
+
+                       if (!NT_STATUS_IS_OK(status)) {
+                               DEBUG(1, ("Failed to modify entry: %s\n",
+                                         nt_errstr(status)));
+                       }
                }
                goto done;
        }
@@ -381,10 +387,16 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
        }
 
        if (updated_autolock || updated_badpw){
+               NTSTATUS status;
+
                become_root();
-               if(!NT_STATUS_IS_OK(pdb_update_sam_account(sampass)))
-                       DEBUG(1, ("Failed to modify entry.\n"));
+               status = pdb_update_sam_account(sampass);
                unbecome_root();
+
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(1, ("Failed to modify entry: %s\n",
+                                 nt_errstr(status)));
+               }
        }
 
        nt_status = sam_account_ok(mem_ctx, sampass, user_info);