Replace sid_string_static by sid_string_dbg in DEBUGs
[amitay/samba.git] / source3 / rpc_server / srv_netlog_nt.c
index 7544d666c6b6f145ea9c5bfd2ed1c61e15851465..218ce734440482b4e277495b5c7d2e9c8618e9a9 100644 (file)
@@ -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. */
@@ -91,7 +90,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C
         uint32 logon_attempts = 0x0;
         uint32 tc_status;
        fstring servername, domain, dc_name, dc_name2;
-       struct in_addr dc_ip;
+       struct sockaddr_storage dc_ss;
 
        /* this should be \\global_myname() */
        unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername));
@@ -108,7 +107,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C
                        if ( !is_trusted_domain( domain ) )
                                break;
                                
-                       if ( !get_dc_name( domain, NULL, dc_name2, &dc_ip ) ) {
+                       if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) {
                                tc_status = ERROR_NO_LOGON_SERVERS;
                                break;
                        }
@@ -125,7 +124,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C
                        if ( !is_trusted_domain( domain ) )
                                break;
                                
-                       if ( !get_dc_name( domain, NULL, dc_name2, &dc_ip ) ) {
+                       if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) {
                                tc_status = ERROR_NO_LOGON_SERVERS;
                                break;
                        }
@@ -195,10 +194,12 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type)
 {
        struct samu *sampass = NULL;
        const uint8 *pass;
-       BOOL ret;
+       bool ret;
        uint32 acct_ctrl;
-
+       
 #if 0
+       char addr[INET6_ADDRSTRLEN];
+
     /*
      * Currently this code is redundent as we already have a filter
      * by hostname list. What this code really needs to do is to 
@@ -209,8 +210,8 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type)
      */
 
        if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(),
-                         client_name(), client_addr()))
-       {
+                       client_name(get_client_fd()),
+                       client_addr(get_client_fd(),addr,sizeof(addr)))) {
                DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct));
                return False;
        }
@@ -499,7 +500,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
 {
        fstring remote_machine;
        struct samu *sampass=NULL;
-       BOOL ret = False;
+       bool ret = False;
        unsigned char pwd[16];
        int i;
        uint32 acct_ctrl;
@@ -655,7 +656,7 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF
 
        if (!p->dc) {
                /* Restore the saved state of the netlogon creds. */
-               BOOL ret;
+               bool ret;
 
                become_root();
                ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx,
@@ -729,7 +730,7 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx,
 static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
                                        NET_Q_SAM_LOGON *q_u,
                                        NET_R_SAM_LOGON *r_u,
-                                       BOOL process_creds)
+                                       bool process_creds)
 {
        NTSTATUS status = NT_STATUS_OK;
        NET_USER_INFO_3 *usr_info = NULL;
@@ -785,7 +786,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
 
                if (!p->dc) {
                        /* Restore the saved state of the netlogon creds. */
-                       BOOL ret;
+                       bool ret;
 
                        become_root();
                        ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx,
@@ -947,18 +948,16 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
        /* This is the point at which, if the login was successful, that
            the SAM Local Security Authority should record that the user is
            logged in to the domain.  */
-    
+
        {
                DOM_GID *gids = NULL;
                const DOM_SID *user_sid = NULL;
                const DOM_SID *group_sid = NULL;
                DOM_SID domain_sid;
-               uint32 user_rid, group_rid; 
+               uint32 user_rid, group_rid;
 
                int num_gids = 0;
-               pstring my_name;
-               fstring user_sid_string;
-               fstring group_sid_string;
+               const char *my_name;
                unsigned char user_session_key[16];
                unsigned char lm_session_key[16];
                unsigned char pipe_session_key[16];
@@ -984,19 +983,18 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
                        DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid "
                                  "%s\n but group sid %s.\n"
                                  "The conflicting domain portions are not "
-                                 "supported for NETLOGON calls\n",         
+                                 "supported for NETLOGON calls\n",
                                  pdb_get_domain(sampw),
                                  pdb_get_username(sampw),
-                                 sid_to_string(user_sid_string, user_sid),
-                                 sid_to_string(group_sid_string, group_sid)));
+                                 sid_string_dbg(user_sid),
+                                 sid_string_dbg(group_sid)));
                        return NT_STATUS_UNSUCCESSFUL;
                }
-               
-               
+
                if(server_info->login_server) {
-                       pstrcpy(my_name, server_info->login_server);
+                       my_name = server_info->login_server;
                } else {
-                       pstrcpy(my_name, global_myname());
+                       my_name = global_myname();
                }
 
                status = nt_token_to_group_list(p->mem_ctx, &domain_sid,
@@ -1010,7 +1008,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
 
                if (server_info->user_session_key.length) {
                        memcpy(user_session_key,
-                              server_info->user_session_key.data, 
+                              server_info->user_session_key.data,
                               MIN(sizeof(user_session_key),
                                   server_info->user_session_key.length));
                        if (process_creds) {
@@ -1028,7 +1026,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
                }
                if (server_info->lm_session_key.length) {
                        memcpy(lm_session_key,
-                              server_info->lm_session_key.data, 
+                              server_info->lm_session_key.data,
                               MIN(sizeof(lm_session_key),
                                   server_info->lm_session_key.length));
                        if (process_creds) {
@@ -1044,10 +1042,10 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
                        SamOEMhash(lm_session_key, pipe_session_key, 16);
                        memset(pipe_session_key, '\0', 16);
                }
-               
-               init_net_user_info3(p->mem_ctx, usr_info, 
+
+               init_net_user_info3(p->mem_ctx, usr_info,
                                    user_rid,
-                                   group_rid,   
+                                   group_rid,
                                    pdb_get_username(sampw),
                                    pdb_get_fullname(sampw),
                                    pdb_get_homedir(sampw),
@@ -1070,7 +1068,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p,
                                    server_info->lm_session_key.length ? lm_session_key : NULL,
                                    my_name     , /* char *logon_srv */
                                    pdb_get_domain(sampw),
-                                   &domain_sid);     /* DOM_SID *dom_sid */  
+                                   &domain_sid);     /* DOM_SID *dom_sid */
                ZERO_STRUCT(user_session_key);
                ZERO_STRUCT(lm_session_key);
        }