*/
#include "includes.h"
-
-/* users from session setup */
-static char *session_userlist = NULL;
-static int len_session_userlist = 0;
-/* workgroup from session setup. */
-static char *session_workgroup = NULL;
-
-/* this holds info on user ids that are already validated for this VC */
-static user_struct *validated_users;
-static int next_vuid = VUID_OFFSET;
-static int num_validated_vuids;
+#include "smbd/globals.h"
enum server_allocated_state { SERVER_ALLOCATED_REQUIRED_YES,
SERVER_ALLOCATED_REQUIRED_NO,
SERVER_ALLOCATED_REQUIRED_ANY};
-static user_struct *get_valid_user_struct_internal(uint16 vuid,
+static user_struct *get_valid_user_struct_internal(
+ struct smbd_server_connection *sconn,
+ uint16 vuid,
enum server_allocated_state server_allocated)
{
user_struct *usp;
if (vuid == UID_FIELD_INVALID)
return NULL;
- for (usp=validated_users;usp;usp=usp->next,count++) {
+ usp=sconn->smb1.sessions.validated_users;
+ for (;usp;usp=usp->next,count++) {
if (vuid == usp->vuid) {
switch (server_allocated) {
case SERVER_ALLOCATED_REQUIRED_YES:
break;
}
if (count > 10) {
- DLIST_PROMOTE(validated_users, usp);
+ DLIST_PROMOTE(sconn->smb1.sessions.validated_users,
+ usp);
}
return usp;
}
tell random client vuid's (normally zero) from valid vuids.
****************************************************************************/
-user_struct *get_valid_user_struct(uint16 vuid)
+user_struct *get_valid_user_struct(struct smbd_server_connection *sconn,
+ uint16 vuid)
{
- return get_valid_user_struct_internal(vuid,
+ return get_valid_user_struct_internal(sconn, vuid,
SERVER_ALLOCATED_REQUIRED_YES);
}
-bool is_partial_auth_vuid(uint16 vuid)
+bool is_partial_auth_vuid(struct smbd_server_connection *sconn, uint16 vuid)
{
- if (vuid == UID_FIELD_INVALID) {
- return False;
- }
- return get_valid_user_struct_internal(vuid,
- SERVER_ALLOCATED_REQUIRED_NO) ? True : False;
+ return (get_partial_auth_user_struct(sconn, vuid) != NULL);
}
/****************************************************************************
Get the user struct of a partial NTLMSSP login
****************************************************************************/
-user_struct *get_partial_auth_user_struct(uint16 vuid)
+user_struct *get_partial_auth_user_struct(struct smbd_server_connection *sconn,
+ uint16 vuid)
{
- return get_valid_user_struct_internal(vuid,
+ return get_valid_user_struct_internal(sconn, vuid,
SERVER_ALLOCATED_REQUIRED_NO);
}
Invalidate a uid.
****************************************************************************/
-void invalidate_vuid(uint16 vuid)
+void invalidate_vuid(struct smbd_server_connection *sconn, uint16 vuid)
{
user_struct *vuser = NULL;
- if (vuid == UID_FIELD_INVALID) {
- return;
- }
-
- vuser = get_valid_user_struct_internal(vuid,
+ vuser = get_valid_user_struct_internal(sconn, vuid,
SERVER_ALLOCATED_REQUIRED_ANY);
if (vuser == NULL) {
return;
session_yield(vuser);
- data_blob_free(&vuser->session_key);
+ if (vuser->auth_ntlmssp_state) {
+ auth_ntlmssp_end(&vuser->auth_ntlmssp_state);
+ }
- DLIST_REMOVE(validated_users, vuser);
+ DLIST_REMOVE(sconn->smb1.sessions.validated_users, vuser);
/* clear the vuid from the 'cache' on each connection, and
from the vuid 'owner' of connections */
- conn_clear_vuid_cache(vuid);
+ conn_clear_vuid_caches(sconn, vuid);
TALLOC_FREE(vuser);
- num_validated_vuids--;
+ sconn->smb1.sessions.num_validated_vuids--;
}
/****************************************************************************
Invalidate all vuid entries for this process.
****************************************************************************/
-void invalidate_all_vuids(void)
+void invalidate_all_vuids(struct smbd_server_connection *sconn)
{
- user_struct *usp, *next=NULL;
+ while (sconn->smb1.sessions.validated_users != NULL) {
+ invalidate_vuid(sconn,
+ sconn->smb1.sessions.validated_users->vuid);
+ }
+}
+
+static void increment_next_vuid(uint16_t *vuid)
+{
+ *vuid += 1;
- for (usp=validated_users;usp;usp=next) {
- next = usp->next;
- invalidate_vuid(usp->vuid);
+ /* Check for vuid wrap. */
+ if (*vuid == UID_FIELD_INVALID) {
+ *vuid = VUID_OFFSET;
}
}
Create a new partial auth user struct.
*****************************************************/
-int register_initial_vuid(void)
+int register_initial_vuid(struct smbd_server_connection *sconn)
{
user_struct *vuser;
}
/* Limit allowed vuids to 16bits - VUID_OFFSET. */
- if (num_validated_vuids >= 0xFFFF-VUID_OFFSET) {
+ if (sconn->smb1.sessions.num_validated_vuids >= 0xFFFF-VUID_OFFSET) {
return UID_FIELD_INVALID;
}
}
/* Allocate a free vuid. Yes this is a linear search... */
- while( get_valid_user_struct_internal(next_vuid,
+ while( get_valid_user_struct_internal(sconn,
+ sconn->smb1.sessions.next_vuid,
SERVER_ALLOCATED_REQUIRED_ANY) != NULL ) {
- next_vuid++;
- /* Check for vuid wrap. */
- if (next_vuid == UID_FIELD_INVALID) {
- next_vuid = VUID_OFFSET;
- }
+ increment_next_vuid(&sconn->smb1.sessions.next_vuid);
}
DEBUG(10,("register_initial_vuid: allocated vuid = %u\n",
- (unsigned int)next_vuid ));
+ (unsigned int)sconn->smb1.sessions.next_vuid ));
- vuser->vuid = next_vuid;
+ vuser->vuid = sconn->smb1.sessions.next_vuid;
/*
* This happens in an unfinished NTLMSSP session setup. We
* need to allocate a vuid between the first and second calls
* to NTLMSSP.
*/
- next_vuid++;
- num_validated_vuids++;
+ increment_next_vuid(&sconn->smb1.sessions.next_vuid);
+ sconn->smb1.sessions.num_validated_vuids++;
- DLIST_ADD(validated_users, vuser);
+ DLIST_ADD(sconn->smb1.sessions.validated_users, vuser);
return vuser->vuid;
}
+static int register_homes_share(const char *username)
+{
+ int result;
+ struct passwd *pwd;
+
+ result = lp_servicenumber(username);
+ if (result != -1) {
+ DEBUG(3, ("Using static (or previously created) service for "
+ "user '%s'; path = '%s'\n", username,
+ lp_pathname(result)));
+ return result;
+ }
+
+ pwd = getpwnam_alloc(talloc_tos(), username);
+
+ if ((pwd == NULL) || (pwd->pw_dir[0] == '\0')) {
+ DEBUG(3, ("No home directory defined for user '%s'\n",
+ username));
+ TALLOC_FREE(pwd);
+ return -1;
+ }
+
+ DEBUG(3, ("Adding homes service for user '%s' using home directory: "
+ "'%s'\n", username, pwd->pw_dir));
+
+ result = add_home_service(username, username, pwd->pw_dir);
+
+ TALLOC_FREE(pwd);
+ return result;
+}
+
/**
* register that a valid login has been performed, establish 'session'.
* @param server_info The token returned from the authentication process.
*
*/
-int register_existing_vuid(uint16 vuid,
+int register_existing_vuid(struct smbd_server_connection *sconn,
+ uint16 vuid,
auth_serversupplied_info *server_info,
- DATA_BLOB session_key,
DATA_BLOB response_blob,
const char *smb_name)
{
- user_struct *vuser = get_partial_auth_user_struct(vuid);
+ fstring tmp;
+ user_struct *vuser;
+
+ vuser = get_partial_auth_user_struct(sconn, vuid);
if (!vuser) {
goto fail;
}
/* Use this to keep tabs on all our info from the authentication */
- vuser->server_info = server_info;
-
- /* Ensure that the server_info will disappear with
- * the vuser it is now attached to */
-
- talloc_steal(vuser, vuser->server_info);
-
- /* the next functions should be done by a SID mapping system (SMS) as
- * the new real sam db won't have reference to unix uids or gids
- */
-
- vuser->uid = server_info->uid;
- vuser->gid = server_info->gid;
-
- vuser->n_groups = server_info->n_groups;
- if (vuser->n_groups) {
- if (!(vuser->groups = (gid_t *)talloc_memdup(vuser,
- server_info->groups,
- sizeof(gid_t)*vuser->n_groups))) {
- DEBUG(0,("register_existing_vuid: "
- "failed to talloc_memdup vuser->groups\n"));
- goto fail;
- }
- }
-
- vuser->guest = server_info->guest;
- fstrcpy(vuser->user.unix_name, server_info->unix_name);
+ vuser->server_info = talloc_move(vuser, &server_info);
/* This is a potentially untrusted username */
- alpha_strcpy(vuser->user.smb_name, smb_name, ". _-$",
- sizeof(vuser->user.smb_name));
-
- fstrcpy(vuser->user.domain, pdb_get_domain(server_info->sam_account));
- fstrcpy(vuser->user.full_name,
- pdb_get_fullname(server_info->sam_account));
-
- {
- /* Keep the homedir handy */
- const char *homedir =
- pdb_get_homedir(server_info->sam_account);
- const char *logon_script =
- pdb_get_logon_script(server_info->sam_account);
-
- if (!IS_SAM_DEFAULT(server_info->sam_account,
- PDB_UNIXHOMEDIR)) {
- const char *unix_homedir =
- pdb_get_unix_homedir(server_info->sam_account);
- if (unix_homedir) {
- vuser->unix_homedir = unix_homedir;
- }
- } else {
- struct passwd *passwd =
- getpwnam_alloc(vuser, vuser->user.unix_name);
- if (passwd) {
- vuser->unix_homedir = passwd->pw_dir;
- /* Ensure that the unix_homedir now
- * belongs to vuser, so it goes away
- * with it, not with passwd below: */
- talloc_steal(vuser, vuser->unix_homedir);
- TALLOC_FREE(passwd);
- }
- }
+ alpha_strcpy(tmp, smb_name, ". _-$", sizeof(tmp));
- if (homedir) {
- vuser->homedir = homedir;
- }
- if (logon_script) {
- vuser->logon_script = logon_script;
- }
- }
- vuser->session_key = session_key;
+ vuser->server_info->sanitized_username = talloc_strdup(
+ vuser->server_info, tmp);
DEBUG(10,("register_existing_vuid: (%u,%u) %s %s %s guest=%d\n",
- (unsigned int)vuser->uid,
- (unsigned int)vuser->gid,
- vuser->user.unix_name, vuser->user.smb_name,
- vuser->user.domain, vuser->guest ));
+ (unsigned int)vuser->server_info->utok.uid,
+ (unsigned int)vuser->server_info->utok.gid,
+ vuser->server_info->unix_name,
+ vuser->server_info->sanitized_username,
+ pdb_get_domain(vuser->server_info->sam_account),
+ vuser->server_info->guest ));
DEBUG(3, ("register_existing_vuid: User name: %s\t"
- "Real name: %s\n", vuser->user.unix_name,
- vuser->user.full_name));
+ "Real name: %s\n", vuser->server_info->unix_name,
+ pdb_get_fullname(vuser->server_info->sam_account)));
- if (server_info->ptok) {
- vuser->nt_user_token = dup_nt_token(vuser, server_info->ptok);
- } else {
+ if (!vuser->server_info->ptok) {
DEBUG(1, ("register_existing_vuid: server_info does not "
"contain a user_token - cannot continue\n"));
goto fail;
}
DEBUG(3,("register_existing_vuid: UNIX uid %d is UNIX user %s, "
- "and will be vuid %u\n",
- (int)vuser->uid,vuser->user.unix_name, vuser->vuid));
-
- next_vuid++;
- num_validated_vuids++;
+ "and will be vuid %u\n", (int)vuser->server_info->utok.uid,
+ vuser->server_info->unix_name, vuser->vuid));
if (!session_claim(vuser)) {
DEBUG(1, ("register_existing_vuid: Failed to claim session "
If a share exists by this name (autoloaded or not) reuse it . */
vuser->homes_snum = -1;
- if ( (!vuser->guest) && vuser->unix_homedir && *(vuser->unix_homedir)) {
- int servicenumber = lp_servicenumber(vuser->user.unix_name);
- if ( servicenumber == -1 ) {
- DEBUG(3, ("Adding homes service for user '%s' using "
- "home directory: '%s'\n",
- vuser->user.unix_name, vuser->unix_homedir));
- vuser->homes_snum =
- add_home_service(vuser->user.unix_name,
- vuser->user.unix_name,
- vuser->unix_homedir);
- } else {
- DEBUG(3, ("Using static (or previously created) "
- "service for user '%s'; path = '%s'\n",
- vuser->user.unix_name,
- lp_pathname(servicenumber) ));
- vuser->homes_snum = servicenumber;
- }
+
+ if (!vuser->server_info->guest) {
+ vuser->homes_snum = register_homes_share(
+ vuser->server_info->unix_name);
}
- if (srv_is_signing_negotiated() && !vuser->guest &&
- !srv_signing_started()) {
+ if (srv_is_signing_negotiated(smbd_server_conn) &&
+ !vuser->server_info->guest) {
/* Try and turn on server signing on the first non-guest
* sessionsetup. */
- srv_set_signing(vuser->session_key, response_blob);
+ srv_set_signing(smbd_server_conn,
+ vuser->server_info->user_session_key,
+ response_blob);
}
/* fill in the current_user_info struct */
- set_current_user_info( &vuser->user );
+ set_current_user_info(
+ vuser->server_info->sanitized_username,
+ vuser->server_info->unix_name,
+ pdb_get_domain(vuser->server_info->sam_account));
+
return vuser->vuid;
fail:
if (vuser) {
- invalidate_vuid(vuid);
+ invalidate_vuid(sconn, vuid);
}
return UID_FIELD_INVALID;
}
Add a name to the session users list.
****************************************************************************/
-void add_session_user(const char *user)
+void add_session_user(struct smbd_server_connection *sconn,
+ const char *user)
{
- fstring suser;
- struct passwd *passwd;
-
- if (!(passwd = Get_Pwnam(user)))
- return;
+ struct passwd *pw;
+ char *tmp;
- fstrcpy(suser,passwd->pw_name);
+ pw = Get_Pwnam_alloc(talloc_tos(), user);
- if(!*suser)
+ if (pw == NULL) {
return;
+ }
- if( session_userlist && in_list(suser,session_userlist,False) )
- return;
+ if (sconn->smb1.sessions.session_userlist == NULL) {
+ sconn->smb1.sessions.session_userlist = SMB_STRDUP(pw->pw_name);
+ goto done;
+ }
- if( !session_userlist ||
- (strlen(suser) + strlen(session_userlist) + 2 >=
- len_session_userlist) ) {
- char *newlist;
+ if (in_list(pw->pw_name,sconn->smb1.sessions.session_userlist,false)) {
+ goto done;
+ }
- if (len_session_userlist > 128 * 1024) {
- DEBUG(3,("add_session_user: session userlist already "
- "too large.\n"));
- return;
- }
- newlist = (char *)SMB_REALLOC_KEEP_OLD_ON_ERROR(
- session_userlist,
- len_session_userlist + 1024 );
- if( newlist == NULL ) {
- DEBUG(1,("Unable to resize session_userlist\n"));
- return;
- }
- if (!session_userlist) {
- *newlist = '\0';
- }
- session_userlist = newlist;
- len_session_userlist += 1024;
+ if (strlen(sconn->smb1.sessions.session_userlist) > 128 * 1024) {
+ DEBUG(3,("add_session_user: session userlist already "
+ "too large.\n"));
+ goto done;
}
- safe_strcat(session_userlist," ",len_session_userlist-1);
- safe_strcat(session_userlist,suser,len_session_userlist-1);
+ if (asprintf(&tmp, "%s %s",
+ sconn->smb1.sessions.session_userlist, pw->pw_name) == -1) {
+ DEBUG(3, ("asprintf failed\n"));
+ goto done;
+ }
+
+ SAFE_FREE(sconn->smb1.sessions.session_userlist);
+ sconn->smb1.sessions.session_userlist = tmp;
+ done:
+ TALLOC_FREE(pw);
}
/****************************************************************************
what Vista uses for the NTLMv2 calculation.
****************************************************************************/
-void add_session_workgroup(const char *workgroup)
+void add_session_workgroup(struct smbd_server_connection *sconn,
+ const char *workgroup)
{
- if (session_workgroup) {
- SAFE_FREE(session_workgroup);
+ if (sconn->smb1.sessions.session_workgroup) {
+ SAFE_FREE(sconn->smb1.sessions.session_workgroup);
}
- session_workgroup = smb_xstrdup(workgroup);
+ sconn->smb1.sessions.session_workgroup = smb_xstrdup(workgroup);
}
/****************************************************************************
what Vista uses for the NTLMv2 calculation.
****************************************************************************/
-const char *get_session_workgroup(void)
+const char *get_session_workgroup(struct smbd_server_connection *sconn)
{
- return session_workgroup;
+ return sconn->smb1.sessions.session_workgroup;
}
/****************************************************************************
try lower case.
****************************************************************************/
-bool user_in_netgroup(const char *user, const char *ngname)
+bool user_in_netgroup(struct smbd_server_connection *sconn,
+ const char *user, const char *ngname)
{
#ifdef HAVE_NETGROUP
- static char *mydomain = NULL;
fstring lowercase_user;
- if (mydomain == NULL)
- yp_get_default_domain(&mydomain);
+ if (sconn->smb1.sessions.my_yp_domain == NULL) {
+ yp_get_default_domain(&sconn->smb1.sessions.my_yp_domain);
+ }
- if(mydomain == NULL) {
+ if (sconn->smb1.sessions.my_yp_domain == NULL) {
DEBUG(5,("Unable to get default yp domain, "
"let's try without specifying it\n"));
}
DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
- user, mydomain?mydomain:"(ANY)", ngname));
+ user,
+ sconn->smb1.sessions.my_yp_domain?
+ sconn->smb1.sessions.my_yp_domain:"(ANY)",
+ ngname));
- if (innetgr(ngname, NULL, user, mydomain)) {
+ if (innetgr(ngname, NULL, user, sconn->smb1.sessions.my_yp_domain)) {
DEBUG(5,("user_in_netgroup: Found\n"));
- return (True);
+ return true;
} else {
/*
strlower_m(lowercase_user);
DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
- lowercase_user, mydomain?mydomain:"(ANY)", ngname));
+ lowercase_user,
+ sconn->smb1.sessions.my_yp_domain?
+ sconn->smb1.sessions.my_yp_domain:"(ANY)",
+ ngname));
- if (innetgr(ngname, NULL, lowercase_user, mydomain)) {
+ if (innetgr(ngname, NULL, lowercase_user,
+ sconn->smb1.sessions.my_yp_domain)) {
DEBUG(5,("user_in_netgroup: Found\n"));
- return (True);
+ return true;
}
}
#endif /* HAVE_NETGROUP */
- return False;
+ return false;
}
/****************************************************************************
and netgroup lists.
****************************************************************************/
-bool user_in_list(const char *user,const char **list)
+bool user_in_list(struct smbd_server_connection *sconn,
+ const char *user,const char **list)
{
if (!list || !*list)
return False;
* Old behaviour. Check netgroup list
* followed by UNIX list.
*/
- if(user_in_netgroup(user, *list +1))
+ if(user_in_netgroup(sconn, user, *list +1))
return True;
if(user_in_group(user, *list +1))
return True;
*/
if(user_in_group(user, *list +2))
return True;
- if(user_in_netgroup(user, *list +2))
+ if(user_in_netgroup(sconn, user, *list +2))
return True;
} else {
/*
* Search netgroup list followed by UNIX list.
*/
- if(user_in_netgroup(user, *list +2))
+ if(user_in_netgroup(sconn, user, *list +2))
return True;
if(user_in_group(user, *list +2))
return True;
/*
* Just search netgroup list.
*/
- if(user_in_netgroup(user, *list +1))
+ if(user_in_netgroup(sconn, user, *list +1))
return True;
}
}
Check if a username is valid.
****************************************************************************/
-static bool user_ok(const char *user, int snum)
+static bool user_ok(struct smbd_server_connection *sconn,
+ const char *user, int snum)
{
char **valid, **invalid;
bool ret;
ret = True;
if (lp_invalid_users(snum)) {
- str_list_copy(&invalid, lp_invalid_users(snum));
+ invalid = str_list_copy(talloc_tos(), lp_invalid_users(snum));
if (invalid &&
str_list_substitute(invalid, "%S", lp_servicename(snum))) {
* around to pass to str_list_sub_basic() */
if ( invalid && str_list_sub_basic(invalid, "", "") ) {
- ret = !user_in_list(user,
+ ret = !user_in_list(sconn, user,
(const char **)invalid);
}
}
}
- if (invalid)
- str_list_free (&invalid);
+ TALLOC_FREE(invalid);
if (ret && lp_valid_users(snum)) {
- str_list_copy(&valid, lp_valid_users(snum));
+ valid = str_list_copy(talloc_tos(), lp_valid_users(snum));
if ( valid &&
str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
* around to pass to str_list_sub_basic() */
if ( valid && str_list_sub_basic(valid, "", "") ) {
- ret = user_in_list(user, (const char **)valid);
+ ret = user_in_list(sconn, user,
+ (const char **)valid);
}
}
}
- if (valid)
- str_list_free (&valid);
+ TALLOC_FREE(valid);
if (ret && lp_onlyuser(snum)) {
- char **user_list = str_list_make (lp_username(snum), NULL);
+ char **user_list = str_list_make_v3(
+ talloc_tos(), lp_username(snum), NULL);
if (user_list &&
str_list_substitute(user_list, "%S",
lp_servicename(snum))) {
- ret = user_in_list(user, (const char **)user_list);
+ ret = user_in_list(sconn, user,
+ (const char **)user_list);
}
- if (user_list) str_list_free (&user_list);
+ TALLOC_FREE(user_list);
}
return(ret);
Validate a group username entry. Return the username or NULL.
****************************************************************************/
-static char *validate_group(char *group, DATA_BLOB password,int snum)
+static char *validate_group(struct smbd_server_connection *sconn,
+ char *group, DATA_BLOB password,int snum)
{
#ifdef HAVE_NETGROUP
{
char *host, *user, *domain;
+ struct auth_context *actx = sconn->smb1.negprot.auth_context;
+ bool enc = sconn->smb1.negprot.encrypted_passwords;
setnetgrent(group);
while (getnetgrent(&host, &user, &domain)) {
if (user) {
- if (user_ok(user, snum) &&
- password_ok(user,password)) {
+ if (user_ok(sconn, user, snum) &&
+ password_ok(actx, enc,
+ get_session_workgroup(sconn),
+ user,password)) {
endnetgrent();
return(user);
}
#ifdef HAVE_GETGRENT
{
struct group *gptr;
+ struct auth_context *actx = sconn->smb1.negprot.auth_context;
+ bool enc = sconn->smb1.negprot.encrypted_passwords;
+
setgrent();
while ((gptr = (struct group *)getgrent())) {
if (strequal(gptr->gr_name,group))
member = member_list;
while (*member) {
- if (user_ok(member,snum) &&
- password_ok(member,password)) {
+ if (user_ok(sconn, member,snum) &&
+ password_ok(actx, enc,
+ get_session_workgroup(sconn),
+ member,password)) {
char *name = talloc_strdup(talloc_tos(),
member);
SAFE_FREE(member_list);
Note this is *NOT* used when logging on using sessionsetup_and_X.
****************************************************************************/
-bool authorise_login(int snum, fstring user, DATA_BLOB password,
+bool authorise_login(struct smbd_server_connection *sconn,
+ int snum, fstring user, DATA_BLOB password,
bool *guest)
{
bool ok = False;
+ struct auth_context *actx = sconn->smb1.negprot.auth_context;
+ bool enc = sconn->smb1.negprot.encrypted_passwords;
#ifdef DEBUG_PASSWORD
DEBUG(100,("authorise_login: checking authorisation on "
if (!ok) {
char *auser;
char *user_list = NULL;
+ char *saveptr;
- if ( session_userlist )
- user_list = SMB_STRDUP(session_userlist);
+ if (sconn->smb1.sessions.session_userlist)
+ user_list = SMB_STRDUP(sconn->smb1.sessions.session_userlist);
else
user_list = SMB_STRDUP("");
if (!user_list)
return(False);
- for (auser=strtok(user_list,LIST_SEP); !ok && auser;
- auser = strtok(NULL,LIST_SEP)) {
+ for (auser = strtok_r(user_list, LIST_SEP, &saveptr);
+ !ok && auser;
+ auser = strtok_r(NULL, LIST_SEP, &saveptr)) {
fstring user2;
fstrcpy(user2,auser);
- if (!user_ok(user2,snum))
+ if (!user_ok(sconn,user2,snum))
continue;
- if (password_ok(user2,password)) {
+ if (password_ok(actx, enc,
+ get_session_workgroup(sconn),
+ user2,password)) {
ok = True;
fstrcpy(user,user2);
DEBUG(3,("authorise_login: ACCEPTED: session "
TALLOC_CTX *ctx = talloc_tos();
char *auser;
char *user_list = talloc_strdup(ctx, lp_username(snum));
+ char *saveptr;
if (!user_list) {
goto check_guest;
goto check_guest;
}
- for (auser=strtok(user_list,LIST_SEP); auser && !ok;
- auser = strtok(NULL,LIST_SEP)) {
+ for (auser = strtok_r(user_list, LIST_SEP, &saveptr);
+ auser && !ok;
+ auser = strtok_r(NULL, LIST_SEP, &saveptr)) {
if (*auser == '@') {
- auser = validate_group(auser+1,password,snum);
+ auser = validate_group(sconn,auser+1,
+ password,snum);
if (auser) {
ok = True;
fstrcpy(user,auser);
} else {
fstring user2;
fstrcpy(user2,auser);
- if (user_ok(user2,snum) &&
- password_ok(user2,password)) {
+ if (user_ok(sconn,user2,snum) &&
+ password_ok(actx, enc,
+ get_session_workgroup(sconn),
+ user2,password)) {
ok = True;
fstrcpy(user,user2);
DEBUG(3,("authorise_login: ACCEPTED: "
/* check for a normal guest connection */
if (!ok && GUEST_OK(snum)) {
+ struct passwd *guest_pw;
fstring guestname;
fstrcpy(guestname,lp_guestaccount());
- if (Get_Pwnam(guestname)) {
+ guest_pw = Get_Pwnam_alloc(talloc_tos(), guestname);
+ if (guest_pw != NULL) {
fstrcpy(user,guestname);
ok = True;
DEBUG(3,("authorise_login: ACCEPTED: guest account "
DEBUG(0,("authorise_login: Invalid guest account "
"%s??\n",guestname));
}
+ TALLOC_FREE(guest_pw);
*guest = True;
}
- if (ok && !user_ok(user, snum)) {
+ if (ok && !user_ok(sconn, user, snum)) {
DEBUG(0,("authorise_login: rejected invalid user %s\n",user));
ok = False;
}