}
+/****************************************************************************
+ does _both_ nt->unix and unix->unix username remappings.
+****************************************************************************/
+static void map_nt_and_unix_username(const char *domain, char *user)
+{
+ DOM_NAME_MAP gmep;
+ fstring nt_username;
+
+ /*
+ * Pass the user through the NT -> unix user mapping
+ * function.
+ */
+
+ if (lp_server_role() != ROLE_DOMAIN_NONE)
+ {
+ memset(nt_username, 0, sizeof(nt_username));
+ if (domain != NULL)
+ {
+ slprintf(nt_username, sizeof(nt_username)-1, "%s\\%s",
+ domain, user);
+ }
+ else
+ {
+ fstrcpy(nt_username, user);
+ }
+
+ if (lookupsmbpwntnam(nt_username, &gmep))
+ {
+ fstrcpy(user, gmep.unix_name);
+ }
+ }
+
+ /*
+ * Pass the user through the unix -> unix user mapping
+ * function.
+ */
+
+ (void)map_username(user);
+
+ /*
+ * Do any UNIX username case mangling.
+ */
+ (void)Get_Pwnam( user, True);
+}
+
/****************************************************************************
reply to an special message
****************************************************************************/
parse_connect(smb_buf(inbuf)+1,service,user,password,&pwlen,dev);
- /*
- * Pass the user through the NT -> unix user mapping
- * function.
- */
-
- (void)map_username(user);
-
- /*
- * Do any UNIX username case mangling.
- */
- (void)Get_Pwnam( user, True);
+ map_nt_and_unix_username(global_myworkgroup, user);
conn = make_connection(service,user,password,pwlen,dev,vuid,&ecode);
StrnCpy(devicename,path + strlen(path) + 1,6);
DEBUG(4,("Got device type %s\n",devicename));
- /*
- * Pass the user through the NT -> unix user mapping
- * function.
- */
-
- (void)map_username(user);
-
- /*
- * Do any UNIX username case mangling.
- */
- (void)Get_Pwnam(user, True);
-
+ map_nt_and_unix_username(global_myworkgroup, user);
+
conn = make_connection(service,user,password,passlen,devicename,vuid,&ecode);
if (!conn)
int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
uint16 sess_vuid;
+ uchar user_sess_key[16];
int gid;
int uid;
int smb_bufsize;
pstrcpy( orig_user, user);
- /*
- * Pass the user through the NT -> unix user mapping
- * function.
- */
-
- (void)map_username(user);
-
- /*
- * Do any UNIX username case mangling.
- */
- (void)Get_Pwnam( user, True);
+ map_nt_and_unix_username(domain, user);
add_session_user(user);
if(smb_ntpasslen)
{
- if(!password_ok(user, smb_ntpasswd,smb_ntpasslen,NULL))
+ if(!password_ok(user, smb_ntpasswd,smb_ntpasslen,NULL,user_sess_key))
DEBUG(0,("NT Password did not match ! Defaulting to Lanman\n"));
else
valid_nt_password = True;
}
- if (!valid_nt_password && !password_ok(user, smb_apasswd,smb_apasslen,NULL))
+ if (!valid_nt_password && !password_ok(user, smb_apasswd,smb_apasslen,NULL,user_sess_key))
{
if (lp_security() >= SEC_USER)
{
int homes = lp_servicenumber(HOMES_NAME);
char *home = get_home_dir(user);
if (homes >= 0 && home)
- lp_add_home(user,homes,home);
+ {
+ pstring home_dir;
+ fstrcpy(home_dir, home);
+ lp_add_home(user,homes,home_dir);
+ }
}
/* register the name and uid as being validated, so further connections
to a uid can get through without a password, on the same VC */
- sess_vuid = register_vuid(uid,gid,user,sesssetup_user,guest);
+ sess_vuid = register_vuid(uid,gid,user,sesssetup_user,guest,user_sess_key);
SSVAL(outbuf,smb_uid,sess_vuid);
SSVAL(inbuf,smb_uid,sess_vuid);