a netlogon enum trust query doesn't have a function_code at end.
authorJean-François Micouleau <jfm@samba.org>
Tue, 10 Oct 2000 13:08:55 +0000 (13:08 +0000)
committerJean-François Micouleau <jfm@samba.org>
Tue, 10 Oct 2000 13:08:55 +0000 (13:08 +0000)
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)

source3/include/proto.h
source3/include/rpc_netlogon.h
source3/include/rpc_samr_old.h
source3/rpc_parse/parse_net.c
source3/rpc_parse/parse_samr.c
source3/rpc_server/srv_samr.c
source3/smbd/reply.c

index 985a6efa0d73768d46bd15e598a466e3499be48e..6911c43be73fdc4b29aded3b25d737963904dad1 100644 (file)
@@ -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);
index 0404afd9e5a0b8d6f995419cb4d880eea548b112..f5fc45ac5211dba05ddf7140e4d5b2141fa0824a 100644 (file)
@@ -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;
 
index 656a9de4340f664a300a6d4f4711461c637f8598..17af1befdaab303b81e991d239e2b0840ccebf0a 100644 (file)
@@ -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 */
index 6aa7f5e51895a3c7dfc37b625ac93b44a8526d5d..098a5ca98c608931be4af2f12daf0b190d8ca3cb 100644 (file)
@@ -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;
 }
 
index 0bd1c297108f2f8849a49b02b2c6b14d7957f4e4..a2dda316f22fde8b7a0e01097d397ff5b4f56718 100644 (file)
@@ -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;
 }
index 93f1f704a817628ac2d801c89e8c02668ad20bd8..1d2626f8fef93bd41e653c687a9a98cdb0c2e5f1 100644 (file)
@@ -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);
        
index fd4ff23461fef8aa7b639d618e8c149a6600e531..efd18799a2d7925f469e94acb6bb32e76a5572c1 100644 (file)
@@ -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;