summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJean-François Micouleau <jfm@samba.org>2000-10-10 13:08:55 +0000
committerJean-François Micouleau <jfm@samba.org>2000-10-10 13:08:55 +0000
commit11d999f2bc0c841696bc3ea1ddda48524242482c (patch)
treed73b35ac9fde76d355a81ecab65ad4c2ef2a4652 /source3
parent2d33e87424197b993e8e7d218c0945cc2b66078a (diff)
downloadsamba-11d999f2bc0c841696bc3ea1ddda48524242482c.tar.gz
samba-11d999f2bc0c841696bc3ea1ddda48524242482c.tar.bz2
samba-11d999f2bc0c841696bc3ea1ddda48524242482c.zip
a netlogon enum trust query doesn't have a function_code at end.
a sam_user_info_24 doesn't have a uint16 at end samr_create_user also creates the unix account now samr_set_userinfo changes the password. J.F. (This used to be commit 94f4024481fcd0cb6647af1bd4364033be020641)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/include/rpc_netlogon.h2
-rw-r--r--source3/include/rpc_samr_old.h2
-rw-r--r--source3/rpc_parse/parse_net.c6
-rw-r--r--source3/rpc_parse/parse_samr.c4
-rw-r--r--source3/rpc_server/srv_samr.c67
-rw-r--r--source3/smbd/reply.c2
7 files changed, 58 insertions, 26 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 985a6efa0d..6911c43be7 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3709,6 +3709,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
int reply_unknown(char *inbuf,char *outbuf);
int reply_ioctl(connection_struct *conn,
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int smb_create_user(char *unix_user);
int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h
index 0404afd9e5..f5fc45ac52 100644
--- a/source3/include/rpc_netlogon.h
+++ b/source3/include/rpc_netlogon.h
@@ -208,8 +208,6 @@ typedef struct net_q_trust_dom_info
{
uint32 ptr; /* undocumented buffer pointer */
UNISTR2 uni_server_name; /* server name, starting with two '\'s */
-
- uint32 function_code; /* 0x31 */
} NET_Q_TRUST_DOM_LIST;
diff --git a/source3/include/rpc_samr_old.h b/source3/include/rpc_samr_old.h
index 656a9de434..17af1befda 100644
--- a/source3/include/rpc_samr_old.h
+++ b/source3/include/rpc_samr_old.h
@@ -1258,8 +1258,6 @@ typedef struct sam_user_info_23
typedef struct sam_user_info_24
{
uint8 pass[516];
- uint16 unk_0;
-
} SAM_USER_INFO_24;
/* SAM_USERINFO_CTR - sam user info */
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c
index 6aa7f5e518..098a5ca98c 100644
--- a/source3/rpc_parse/parse_net.c
+++ b/source3/rpc_parse/parse_net.c
@@ -374,12 +374,6 @@ BOOL net_io_q_trust_dom(char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, i
if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
return False;
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("function_code", ps, depth, &q_l->function_code))
- return False;
-
return True;
}
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 0bd1c29710..a2dda316f2 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -4248,7 +4248,7 @@ static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 *usr, prs_struct *ps
return False;
/* ok, this is only guess-work (as usual) */
- if (usr->unknown_3 != 0x0) {
+ if (usr->unknown_5 != 0x0) {
if(!prs_uint32("unknown_6", ps, depth, &usr->unknown_6))
return False;
if(!prs_uint32("padding4", ps, depth, &usr->padding4))
@@ -4282,8 +4282,6 @@ static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 *usr, prs_struct *ps
if(!prs_uint8s(False, "password", ps, depth, usr->pass, sizeof(usr->pass)))
return False;
- if(!prs_uint16("unk_0", ps, depth, &usr->unk_0)) /* unknown */
- return False;
return True;
}
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index 93f1f704a8..1d2626f8fe 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -1870,6 +1870,11 @@ static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint
* to create a user. JRA.
*/
+ /* add the user in the /etc/passwd file or the unix authority system */
+ if (lp_adduser_script())
+ smb_create_user(mach_acct);
+
+ /* add the user in the smbpasswd file or the Samba authority database */
if (!local_password_change(mach_acct, local_flags, NULL, err_str, sizeof(err_str), msg_str, sizeof(msg_str))) {
DEBUG(0, ("%s\n", err_str));
close_lsa_policy_hnd(user_pol);
@@ -2340,6 +2345,13 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
new_pwd.smb_passwd = lm_hash;
new_pwd.smb_nt_passwd = nt_hash;
+ /* update the UNIX password */
+ if (lp_unix_password_sync())
+ if(!chgpasswd(new_pwd.smb_name, "", buf, True))
+ return False;
+
+ memset(buf, 0, sizeof(buf));
+
if(!mod_sam21pwd_entry(&new_pwd, True))
return False;
@@ -2372,6 +2384,14 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid)
new_pwd.smb_passwd = lm_hash;
new_pwd.smb_nt_passwd = nt_hash;
+ /* update the UNIX password */
+ if (lp_unix_password_sync())
+ if(!chgpasswd(new_pwd.smb_name, "", buf, True))
+ return False;
+
+ memset(buf, 0, sizeof(buf));
+
+ /* update the SAMBA password */
if(!mod_sam21pwd_entry(&new_pwd, True))
return False;
@@ -2381,34 +2401,58 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid)
/*******************************************************************
samr_reply_set_userinfo
********************************************************************/
-static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr, uint16 vuid)
+static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr, pipes_struct *p)
{
uint32 rid = 0x0;
DOM_SID sid;
- user_struct *vuser = NULL;
+ struct current_user user;
+ struct smb_passwd *smb_pass;
+ unsigned char sess_key[16];
+
+ DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__));
- DEBUG(5, ("samr_reply_set_userinfo: %d\n", __LINE__));
+ if (p->ntlmssp_auth_validated) {
+ memcpy(&user, &p->pipe_user, sizeof(user));
+ } else {
+ extern struct current_user current_user;
+ memcpy(&user, &current_user, sizeof(user));
+ }
/* search for the handle */
if (find_lsa_policy_by_hnd(pol) == -1)
return NT_STATUS_INVALID_HANDLE;
- if ((vuser = get_valid_user_struct(vuid)) == NULL)
- return NT_STATUS_INVALID_HANDLE;
-
/* find the policy handle. open a policy on it. */
if (!get_lsa_policy_samr_sid(pol, &sid))
return NT_STATUS_INVALID_HANDLE;
sid_split_rid(&sid, &rid);
- DEBUG(5, ("samr_reply_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value));
+ DEBUG(5, ("_samr_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value));
if (ctr == NULL) {
- DEBUG(5, ("samr_reply_set_userinfo: NULL info level\n"));
+ DEBUG(5, ("_samr_set_userinfo: NULL info level\n"));
return NT_STATUS_INVALID_INFO_CLASS;
}
+
+ /*
+ * We need the NT hash of the user who is changing the user's password.
+ * This NT hash is used to generate a "user session key"
+ * This "user session key" is in turn used to encrypt/decrypt the user's password.
+ */
+
+ become_root();
+ smb_pass = getsmbpwuid(user.uid);
+ unbecome_root();
+ if(smb_pass == NULL) {
+ DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd entry for uid %u\n", (unsigned int)user.uid ));
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ memset(sess_key, '\0', 16);
+ mdfour(sess_key, smb_pass->smb_nt_passwd, 16);
+
/* ok! user info levels (lots: see MSDEV help), off we go... */
switch (switch_value) {
case 0x12:
@@ -2417,14 +2461,13 @@ static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERI
break;
case 24:
- SamOEMhash(ctr->info.id24->pass, vuser->dc.sess_key, True);
+ SamOEMhash(ctr->info.id24->pass, sess_key, 1);
if (!set_user_info_24(ctr->info.id24, rid))
return NT_STATUS_ACCESS_DENIED;
break;
case 23:
- DEBUG(5, ("samr_reply_set_userinfo: sess key:[%s]\n", credstr(vuser->dc.sess_key)));
- SamOEMhash(ctr->info.id23->pass, vuser->dc.sess_key, 1);
+ SamOEMhash(ctr->info.id23->pass, sess_key, 1);
if (!set_user_info_23(ctr->info.id23, rid))
return NT_STATUS_ACCESS_DENIED;
break;
@@ -2459,7 +2502,7 @@ static BOOL api_samr_set_userinfo(pipes_struct *p)
return False;
}
- r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p->vuid);
+ r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p);
free_samr_q_set_userinfo(&q_u);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index fd4ff23461..efd18799a2 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -494,7 +494,7 @@ static int session_trust_account(connection_struct *conn, char *inbuf, char *out
Create a UNIX user on demand.
****************************************************************************/
-static int smb_create_user(char *unix_user)
+int smb_create_user(char *unix_user)
{
pstring add_script;
int ret;