summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_netlog.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server/srv_netlog.c')
-rw-r--r--source3/rpc_server/srv_netlog.c434
1 files changed, 220 insertions, 214 deletions
diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c
index c0233d80c6..db1a4a9c6b 100644
--- a/source3/rpc_server/srv_netlog.c
+++ b/source3/rpc_server/srv_netlog.c
@@ -1,4 +1,3 @@
-
/*
* Unix SMB/Netbios implementation.
* Version 1.9.
@@ -23,9 +22,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
#include "includes.h"
-#include "nterr.h"
extern int DEBUGLEVEL;
@@ -302,21 +299,24 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct)
return False;
}
+extern struct current_user current_user; /* To pick up vuid */
+
/*************************************************************************
api_net_req_chal:
*************************************************************************/
-static BOOL api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata)
+static BOOL api_net_req_chal(prs_struct *data, prs_struct *rdata)
{
NET_Q_REQ_CHAL q_r;
uint32 status = 0x0;
+ uint16 vuid = current_user.vuid;
fstring mach_acct;
fstring mach_name;
user_struct *vuser;
- DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid));
+ DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid));
if ((vuser = get_valid_user_struct(vuid)) == NULL)
return False;
@@ -367,8 +367,9 @@ static BOOL api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata)
api_net_auth_2:
*************************************************************************/
-static BOOL api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata)
+static BOOL api_net_auth_2(prs_struct *data, prs_struct *rdata)
{
+ uint16 vuid = current_user.vuid;
NET_Q_AUTH_2 q_a;
uint32 status = 0x0;
@@ -414,8 +415,9 @@ static BOOL api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata)
api_net_srv_pwset:
*************************************************************************/
-static BOOL api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata)
+static BOOL api_net_srv_pwset(prs_struct *data, prs_struct *rdata)
{
+ uint16 vuid = current_user.vuid;
NET_Q_SRV_PWSET q_a;
uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000;
DOM_CRED srv_cred;
@@ -495,8 +497,9 @@ static BOOL api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata)
api_net_sam_logoff:
*************************************************************************/
-static BOOL api_net_sam_logoff( uint16 vuid, prs_struct *data, prs_struct *rdata)
+static BOOL api_net_sam_logoff(prs_struct *data, prs_struct *rdata)
{
+ uint16 vuid = current_user.vuid;
NET_Q_SAM_LOGOFF q_l;
NET_ID_INFO_CTR ctr;
@@ -629,211 +632,216 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass)
api_net_sam_logon:
*************************************************************************/
-static BOOL api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata)
+static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata)
{
- NET_Q_SAM_LOGON q_l;
- NET_ID_INFO_CTR ctr;
- NET_USER_INFO_3 usr_info;
- uint32 status = 0x0;
- DOM_CRED srv_cred;
- struct smb_passwd *smb_pass = NULL;
- UNISTR2 *uni_samlogon_user = NULL;
- fstring nt_username;
-
- user_struct *vuser = NULL;
-
- if ((vuser = get_valid_user_struct(vuid)) == NULL)
- return False;
-
- memset(&q_l, '\0', sizeof(q_l));
- memset(&ctr, '\0', sizeof(ctr));
- memset(&usr_info, '\0', sizeof(usr_info));
-
- q_l.sam_id.ctr = &ctr;
-
- if(!net_io_q_sam_logon("", &q_l, data, 0)) {
- DEBUG(0,("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n"));
- return False;
- }
-
- /* checks and updates credentials. creates reply credentials */
- if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred),
- &(q_l.sam_id.client.cred), &srv_cred))
- status = 0xC0000000 | NT_STATUS_INVALID_HANDLE;
- else
- memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred));
-
- /* find the username */
-
- if (status == 0) {
- switch (q_l.sam_id.logon_level) {
- case INTERACTIVE_LOGON_TYPE:
- uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name;
-
- DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup()));
- break;
- case NET_LOGON_TYPE:
- uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name;
-
- DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup()));
- break;
- default:
- DEBUG(2,("SAM Logon: unsupported switch value\n"));
- status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
- break;
- } /* end switch */
- } /* end if status == 0 */
-
- /* check username exists */
-
- if (status == 0) {
- pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer,
- uni_samlogon_user->uni_str_len));
-
- DEBUG(3,("User:[%s]\n", nt_username));
-
- /*
- * Convert to a UNIX username.
- */
- map_username(nt_username);
-
- /*
- * Do any case conversions.
- */
- (void)Get_Pwnam(nt_username, True);
-
- become_root(True);
- smb_pass = getsmbpwnam(nt_username);
- unbecome_root(True);
-
- if (smb_pass == NULL)
- status = 0xC0000000 | NT_STATUS_NO_SUCH_USER;
- else if (smb_pass->acct_ctrl & ACB_PWNOTREQ)
- status = 0;
- else if (smb_pass->acct_ctrl & ACB_DISABLED)
- status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED;
- }
-
- /* Validate password - if required. */
-
- if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) {
- switch (q_l.sam_id.logon_level) {
- case INTERACTIVE_LOGON_TYPE:
- /* interactive login. */
- status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser);
- break;
- case NET_LOGON_TYPE:
- /* network login. lm challenge and 24 byte responses */
- status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass);
- break;
+ uint16 vuid = current_user.vuid;
+ NET_Q_SAM_LOGON q_l;
+ NET_ID_INFO_CTR ctr;
+ NET_USER_INFO_3 usr_info;
+ uint32 status = 0x0;
+ DOM_CRED srv_cred;
+ struct smb_passwd *smb_pass = NULL;
+ UNISTR2 *uni_samlogon_user = NULL;
+ fstring nt_username;
+
+ user_struct *vuser = NULL;
+
+ if ((vuser = get_valid_user_struct(vuid)) == NULL)
+ return False;
+
+ memset(&q_l, '\0', sizeof(q_l));
+ memset(&ctr, '\0', sizeof(ctr));
+ memset(&usr_info, '\0', sizeof(usr_info));
+
+ q_l.sam_id.ctr = &ctr;
+
+ if(!net_io_q_sam_logon("", &q_l, data, 0)) {
+ DEBUG(0,
+ ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n"));
+ return False;
}
- }
-
- /* lkclXXXX 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.
- */
-
- /* return the profile plus other bits :-) */
-
- if (status == 0) {
- DOM_GID *gids = NULL;
- int num_gids = 0;
- NTTIME dummy_time;
- pstring logon_script;
- pstring profile_path;
- pstring home_dir;
- pstring home_drive;
- pstring my_name;
- pstring my_workgroup;
- pstring domain_groups;
- uint32 r_uid;
- uint32 r_gid;
-
- /* set up pointer indicating user/password failed to be found */
- usr_info.ptr_user_info = 0;
-
- dummy_time.low = 0xffffffff;
- dummy_time.high = 0x7fffffff;
-
- /* XXXX hack to get standard_sub_basic() to use sam logon username */
- /* possibly a better way would be to do a become_user() call */
- sam_logon_in_ssb = True;
- pstrcpy(samlogon_user, nt_username);
-
- pstrcpy(logon_script, lp_logon_script());
- pstrcpy(profile_path, lp_logon_path());
-
- pstrcpy(my_workgroup, lp_workgroup());
-
- pstrcpy(home_drive, lp_logon_drive());
- pstrcpy(home_dir, lp_logon_home());
-
- pstrcpy(my_name, global_myname);
- strupper(my_name);
-
- /*
- * This is the point at which we get the group
- * database - we should be getting the gid_t list
- * from /etc/group and then turning the uids into
- * rids and then into machine sids for this user.
- * JRA.
- */
-
- get_domain_user_groups(domain_groups, nt_username);
-
- /*
- * make_dom_gids allocates the gids array. JRA.
- */
- gids = NULL;
- num_gids = make_dom_gids(domain_groups, &gids);
-
- sam_logon_in_ssb = False;
-
- if (pdb_name_to_rid(nt_username, &r_uid, &r_gid))
- init_net_user_info3(&usr_info,
- &dummy_time, /* logon_time */
- &dummy_time, /* logoff_time */
- &dummy_time, /* kickoff_time */
- &dummy_time, /* pass_last_set_time */
- &dummy_time, /* pass_can_change_time */
- &dummy_time, /* pass_must_change_time */
-
- nt_username , /* user_name */
- vuser->real_name, /* full_name */
- logon_script , /* logon_script */
- profile_path , /* profile_path */
- home_dir , /* home_dir */
- home_drive , /* dir_drive */
-
- 0, /* logon_count */
- 0, /* bad_pw_count */
-
- r_uid , /* RID user_id */
- r_gid , /* RID group_id */
- num_gids, /* uint32 num_groups */
- gids , /* DOM_GID *gids */
- 0x20 , /* uint32 user_flgs (?) */
-
- NULL, /* char sess_key[16] */
-
- my_name , /* char *logon_srv */
- my_workgroup, /* char *logon_dom */
-
- &global_sam_sid, /* DOM_SID *dom_sid */
- NULL); /* char *other_sids */
+
+ /* checks and updates credentials. creates reply credentials */
+ if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred),
+ &(q_l.sam_id.client.cred), &srv_cred))
+ status = 0xC0000000 | NT_STATUS_INVALID_HANDLE;
else
- status = 0xC0000000 | NT_STATUS_NO_SUCH_USER;
-
- /* Free any allocated groups array. */
- if(gids)
- free((char *)gids);
- }
+ memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred),
+ sizeof(vuser->dc.clnt_cred));
+
+ /* find the username */
+
+ if (status == 0) {
+ switch (q_l.sam_id.logon_level) {
+ case INTERACTIVE_LOGON_TYPE:
+ uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name;
+
+ DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ",
+ lp_workgroup()));
+ break;
+ case NET_LOGON_TYPE:
+ uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name;
+
+ DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup()));
+ break;
+ default:
+ DEBUG(2,("SAM Logon: unsupported switch value\n"));
+ status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
+ break;
+ } /* end switch */
+ } /* end if status == 0 */
- if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status))
- return False;
+ /* check username exists */
- return True;
+ if (status == 0) {
+ pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer,
+ uni_samlogon_user->uni_str_len));
+
+ DEBUG(3,("User:[%s]\n", nt_username));
+
+ /*
+ * Convert to a UNIX username.
+ */
+ map_username(nt_username);
+
+ /*
+ * Do any case conversions.
+ */
+ (void)Get_Pwnam(nt_username, True);
+
+ become_root(True);
+ smb_pass = getsmbpwnam(nt_username);
+ unbecome_root(True);
+
+ if (smb_pass == NULL)
+ status = 0xC0000000 | NT_STATUS_NO_SUCH_USER;
+ else if (smb_pass->acct_ctrl & ACB_PWNOTREQ)
+ status = 0;
+ else if (smb_pass->acct_ctrl & ACB_DISABLED)
+ status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED;
+ }
+
+ /* Validate password - if required. */
+
+ if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) {
+ switch (q_l.sam_id.logon_level) {
+ case INTERACTIVE_LOGON_TYPE:
+ /* interactive login. */
+ status = net_login_interactive(&q_l.sam_id.ctr->auth.id1,
+ smb_pass, vuser);
+ break;
+ case NET_LOGON_TYPE:
+ /* network login. lm challenge and 24 byte responses */
+ status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass);
+ break;
+ }
+ }
+
+ /* lkclXXXX 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.
+ */
+
+ /* return the profile plus other bits :-) */
+
+ if (status == 0) {
+ DOM_GID *gids = NULL;
+ int num_gids = 0;
+ NTTIME dummy_time;
+ pstring logon_script;
+ pstring profile_path;
+ pstring home_dir;
+ pstring home_drive;
+ pstring my_name;
+ pstring my_workgroup;
+ pstring domain_groups;
+ uint32 r_uid;
+ uint32 r_gid;
+
+ /* set up pointer indicating user/password failed to be found */
+ usr_info.ptr_user_info = 0;
+
+ dummy_time.low = 0xffffffff;
+ dummy_time.high = 0x7fffffff;
+
+ /* XXXX hack to get standard_sub_basic() to use sam logon username */
+ /* possibly a better way would be to do a become_user() call */
+ sam_logon_in_ssb = True;
+ pstrcpy(samlogon_user, nt_username);
+
+ pstrcpy(logon_script, lp_logon_script());
+ pstrcpy(profile_path, lp_logon_path());
+
+ pstrcpy(my_workgroup, lp_workgroup());
+
+ pstrcpy(home_drive, lp_logon_drive());
+ pstrcpy(home_dir, lp_logon_home());
+
+ pstrcpy(my_name, global_myname);
+ strupper(my_name);
+
+ /*
+ * This is the point at which we get the group
+ * database - we should be getting the gid_t list
+ * from /etc/group and then turning the uids into
+ * rids and then into machine sids for this user.
+ * JRA.
+ */
+
+ get_domain_user_groups(domain_groups, nt_username);
+
+ /*
+ * make_dom_gids allocates the gids array. JRA.
+ */
+ gids = NULL;
+ num_gids = make_dom_gids(domain_groups, &gids);
+
+ sam_logon_in_ssb = False;
+
+ if (pdb_name_to_rid(nt_username, &r_uid, &r_gid))
+ init_net_user_info3(&usr_info,
+ &dummy_time, /* logon_time */
+ &dummy_time, /* logoff_time */
+ &dummy_time, /* kickoff_time */
+ &dummy_time, /* pass_last_set_time */
+ &dummy_time, /* pass_can_change_time */
+ &dummy_time, /* pass_must_change_time */
+
+ nt_username , /* user_name */
+ vuser->real_name, /* full_name */
+ logon_script , /* logon_script */
+ profile_path , /* profile_path */
+ home_dir , /* home_dir */
+ home_drive , /* dir_drive */
+
+ 0, /* logon_count */
+ 0, /* bad_pw_count */
+
+ r_uid , /* RID user_id */
+ r_gid , /* RID group_id */
+ num_gids, /* uint32 num_groups */
+ gids , /* DOM_GID *gids */
+ 0x20 , /* uint32 user_flgs (?) */
+
+ NULL, /* char sess_key[16] */
+
+ my_name , /* char *logon_srv */
+ my_workgroup, /* char *logon_dom */
+
+ &global_sam_sid, /* DOM_SID *dom_sid */
+ NULL); /* char *other_sids */
+ else
+ status = 0xC0000000 | NT_STATUS_NO_SUCH_USER;
+
+ /* Free any allocated groups array. */
+ if(gids)
+ free((char *)gids);
+ }
+
+ if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status))
+ return False;
+
+ return True;
}
@@ -841,10 +849,9 @@ static BOOL api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata)
api_net_trust_dom_list:
*************************************************************************/
-static BOOL api_net_trust_dom_list( uint16 vuid,
- prs_struct *data,
- prs_struct *rdata)
+static BOOL api_net_trust_dom_list(prs_struct *data, prs_struct *rdata)
{
+ uint16 vuid = current_user.vuid;
NET_Q_TRUST_DOM_LIST q_t;
char *trusted_domain = "test_domain";
@@ -877,10 +884,9 @@ static BOOL api_net_trust_dom_list( uint16 vuid,
api_net_logon_ctrl2:
*************************************************************************/
-static BOOL api_net_logon_ctrl2( uint16 vuid,
- prs_struct *data,
- prs_struct *rdata)
+static BOOL api_net_logon_ctrl2(prs_struct *data, prs_struct *rdata)
{
+ uint16 vuid = current_user.vuid;
NET_Q_LOGON_CTRL2 q_l;
/* lkclXXXX - guess what - absolutely no idea what these are! */