From 952a631d5de34bd7bf938b0c1349126a0243a3d0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Feb 2006 21:32:31 +0000 Subject: r13548: Always use the get_remote_macinhe_name() as the key for the creds store. This should fix the problems Jerry reported (but I have still to run tests :-). Jeremy. (This used to be commit 43f095a38d66caa774d80fe32e1b96ec25dd1f07) --- source3/passdb/secrets.c | 6 ++- source3/rpc_server/srv_netlog_nt.c | 96 +++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 51 deletions(-) (limited to 'source3') diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index 55fb0cfc0e..ece17cc718 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -930,13 +930,15 @@ static TDB_CONTEXT *open_schannel_session_store(TALLOC_CTX *mem_ctx) Note we must be root here. *******************************************************************************/ -BOOL secrets_store_schannel_session_info(TALLOC_CTX *mem_ctx, const struct dcinfo *pdc) +BOOL secrets_store_schannel_session_info(TALLOC_CTX *mem_ctx, + const char *remote_machine, + const struct dcinfo *pdc) { TDB_CONTEXT *tdb_sc = NULL; TDB_DATA value; BOOL ret; char *keystr = talloc_asprintf(mem_ctx, "%s/%s", SECRETS_SCHANNEL_STATE, - pdc->remote_machine); + remote_machine); if (!keystr) { return False; } diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 109f936ec6..af1f0ebdcf 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -281,10 +281,6 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u q_u->uni_logon_clnt.buffer, sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); - /* Remember the workstation name. This is what we'll use to look - up the secrets.tdb record later. */ - fstrcpy(p->wks, p->dc->remote_machine); - /* Save the client challenge to the server. */ memcpy(p->dc->clnt_chal.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); @@ -448,7 +444,9 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* Store off the state so we can continue after client disconnect. */ become_root(); - secrets_store_schannel_session_info(p->mem_ctx, p->dc); + secrets_store_schannel_session_info(p->mem_ctx, + get_remote_machine_name(), + p->dc); unbecome_root(); return r_u->status; @@ -480,7 +478,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* Restore the saved state of the netlogon creds. */ become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - workstation, + get_remote_machine_name(), &p->dc); unbecome_root(); if (!ret) { @@ -505,7 +503,9 @@ 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. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + p->dc); pdb_init_sam(&sampass); ret=pdb_getsampwnam(sampass, p->dc->mach_acct); unbecome_root(); @@ -579,8 +579,6 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { - fstring workstation; - if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -588,12 +586,10 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF /* Restore the saved state of the netlogon creds. */ BOOL ret; - *workstation = '\0'; - rpcstr_pull_unistr2_fstring(workstation, &q_u->sam_id.client.login.uni_comp_name); - become_root(); - ret = secrets_restore_schannel_session_info( - p->pipe_state_mem_ctx, workstation, &p->dc); + ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -616,7 +612,9 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + p->dc); unbecome_root(); r_u->status = NT_STATUS_OK; @@ -694,44 +692,15 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - /* We need the workstation name for the creds lookup. */ - - switch (q_u->sam_id.logon_level) { - case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id1.uni_user_name; - uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; - - uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); - break; - case NET_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id2.uni_user_name; - uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; - uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); - break; - default: - DEBUG(2,("SAM Logon: unsupported switch value\n")); - return NT_STATUS_INVALID_INFO_CLASS; - } /* end switch */ - - rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); - rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); - rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); - - DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); - if (process_creds) { if (!p->dc) { /* Restore the saved state of the netlogon creds. */ BOOL ret; become_root(); - ret = secrets_restore_schannel_session_info( - p->pipe_state_mem_ctx, nt_workstation, - &p->dc); + ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -748,7 +717,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, schannel, the client did offer it in auth2, but obviously did not use it. */ DEBUG(0,("_net_sam_logon: client %s not using schannel for netlogon\n", - p->dc->remote_machine )); + get_remote_machine_name() )); return NT_STATUS_ACCESS_DENIED; } @@ -763,10 +732,39 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + p->dc); unbecome_root(); } + + switch (q_u->sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + uni_samlogon_user = &ctr->auth.id1.uni_user_name; + uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; + + uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + break; + case NET_LOGON_TYPE: + uni_samlogon_user = &ctr->auth.id2.uni_user_name; + uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; + uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } /* end switch */ + + rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); + rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); + rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); + + DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); -- cgit