r23801: The FSF has moved around a lot. This fixes their Mass Ave address.
[kai/samba.git] / source3 / rpc_server / srv_netlog_nt.c
index d512115e832973a048a040d671c3bd707a2bd2a1..3f1b0916df5dce6c148abcf72c31828eb65a6912 100644 (file)
@@ -9,7 +9,7 @@
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -18,8 +18,7 @@
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /* This is the implementation of the netlogon pipe. */
@@ -75,22 +74,9 @@ Send a message to smbd to do a sam synchronisation
 
 static void send_sync_message(void)
 {
-        TDB_CONTEXT *tdb;
-
-        tdb = tdb_open_log(lock_path("connections.tdb"), 0,
-                           TDB_DEFAULT, O_RDONLY, 0);
-
-        if (!tdb) {
-                DEBUG(3, ("send_sync_message(): failed to open connections "
-                          "database\n"));
-                return;
-        }
-
         DEBUG(3, ("sending sam synchronisation message\n"));
-        
-        message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False, NULL);
-
-        tdb_close(tdb);
+        message_send_all(smbd_messaging_context(), MSG_SMB_SAM_SYNC, NULL, 0,
+                        NULL);
 }
 
 /*************************************************************************
@@ -238,7 +224,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type)
        ret = pdb_getsampwnam(sampass, mach_acct);
        unbecome_root();
  
-       if (ret == False) {
+       if (!ret) {
                DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct));
                TALLOC_FREE(sampass);
                return NT_STATUS_ACCESS_DENIED;
@@ -296,7 +282,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type)
        }
 
        memcpy(md4pw, pass, 16);
-       dump_data(5, md4pw, 16);
+       dump_data(5, (uint8 *)md4pw, 16);
 
        TALLOC_FREE(sampass);
        
@@ -562,26 +548,30 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
        }
 
        /* We must store the creds state after an update. */
+       sampass = samu_new( NULL );
+       if (!sampass) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
        become_root();
        secrets_store_schannel_session_info(p->pipe_state_mem_ctx,
                                                remote_machine,
                                                p->dc);
-       if ( (sampass = samu_new( NULL )) != NULL ) {
-               ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
-       }
+       ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
        unbecome_root();
 
-       if ( !sampass ) 
-               return NT_STATUS_NO_MEMORY;
+       if (!ret) {
+               TALLOC_FREE(sampass);
+               return NT_STATUS_ACCESS_DENIED;
+       }
 
        /* Ensure the account exists and is a machine account. */
        
        acct_ctrl = pdb_get_acct_ctrl(sampass);
 
-       if (!(ret 
-             && (acct_ctrl & ACB_WSTRUST ||
+       if (!(acct_ctrl & ACB_WSTRUST ||
                      acct_ctrl & ACB_SVRTRUST ||
-                     acct_ctrl & ACB_DOMTRUST))) {
+                     acct_ctrl & ACB_DOMTRUST)) {
                TALLOC_FREE(sampass);
                return NT_STATUS_NO_SUCH_USER;
        }
@@ -619,14 +609,14 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
                        return NT_STATUS_NO_MEMORY;
                }
                
-               if (!pdb_set_pass_changed_now(sampass)) {
+               if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) {
                        TALLOC_FREE(sampass);
                        /* Not quite sure what this one qualifies as, but this will do */
                        return NT_STATUS_UNSUCCESSFUL; 
                }
                
                become_root();
-               r_u->status = pdb_update_sam_account (sampass);
+               r_u->status = pdb_update_sam_account(sampass);
                unbecome_root();
        }
 
@@ -981,6 +971,11 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
                user_sid = pdb_get_user_sid(sampw);
                group_sid = pdb_get_group_sid(sampw);
 
+               if ((user_sid == NULL) || (group_sid == NULL)) {
+                       DEBUG(1, ("_net_sam_logon: User without group or user SID\n"));
+                       return NT_STATUS_UNSUCCESSFUL;
+               }
+
                sid_copy(&domain_sid, user_sid);
                sid_split_rid(&domain_sid, &user_rid);