BOOL initialise_password_db(void);
struct smb_passwd *iterate_getsmbpwrid(uint32 user_rid);
struct smb_passwd *iterate_getsmbpwuid(uid_t smb_userid);
-struct smb_passwd *iterate_getsmbpwnam(char *name);
+struct smb_passwd *iterate_getsmbpwnam(const char *name);
void *startsmbpwent(BOOL update);
void endsmbpwent(void *vp);
struct smb_passwd *getsmbpwent(void *vp);
BOOL add_smbpwd_entry(struct smb_passwd *newpwd);
BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override);
-struct smb_passwd *getsmbpwnam(char *name);
+struct smb_passwd *getsmbpwnam(const char *name);
struct smb_passwd *getsmbpwrid(uint32 user_rid);
struct smb_passwd *getsmbpwuid(uid_t smb_userid);
-struct sam_passwd *iterate_getsam21pwnam(char *name);
+struct sam_passwd *iterate_getsam21pwnam(const char *name);
struct sam_passwd *iterate_getsam21pwrid(uint32 rid);
struct sam_passwd *iterate_getsam21pwuid(uid_t uid);
struct sam_disp_info *getsamdisprid(uint32 rid);
struct sam_passwd *getsam21pwent(void *vp);
-struct sam_passwd *getsam21pwnam(char *name);
+struct sam_passwd *getsam21pwnam(const char *name);
struct sam_passwd *getsam21pwrid(uint32 rid);
void pwdb_init_smb(struct smb_passwd *user);
void pwdb_init_sam(struct sam_passwd *user);
void pwdb_set_can_change_time(char *p, int max_len, time_t t);
void pwdb_set_must_change_time(char *p, int max_len, time_t t);
void pwdb_set_last_set_time(char *p, int max_len, time_t t);
-void pwdb_sethexpwd(char *p, char *pwd, uint16 acct_ctrl);
-BOOL pwdb_gethexpwd(char *p, char *pwd);
+void pwdb_sethexpwd(char *p, const char *pwd, uint16 acct_ctrl);
+BOOL pwdb_gethexpwd(const char *p, char *pwd);
uid_t pwdb_user_rid_to_uid(uint32 user_rid);
uint32 pwdb_uid_to_user_rid(uid_t uid);
uint32 pwdb_gid_to_group_rid(gid_t gid);
DOM_CRED srv_cred;
struct smb_passwd *smb_pass = NULL;
UNISTR2 *uni_samlogon_user = NULL;
+ fstring nt_username;
user_struct *vuser = NULL;
if (status == 0)
{
- pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer,
- uni_samlogon_user->uni_str_len));
+ pstrcpy(nt_username, unistrn2(uni_samlogon_user->buffer,
+ uni_samlogon_user->uni_str_len));
- DEBUG(3,("User:[%s]\n", samlogon_user));
+ DEBUG(3,("User:[%s]\n", nt_username));
/*
* Convert to a UNIX username.
*/
- map_username(samlogon_user);
+ map_username(nt_username);
/*
* Do any case conversions.
*/
- (void)Get_Pwnam(samlogon_user, True);
+ (void)Get_Pwnam(nt_username, True);
become_root(True);
- smb_pass = getsmbpwnam(samlogon_user);
+ smb_pass = getsmbpwnam(nt_username);
unbecome_root(True);
if (smb_pass == NULL)
/* 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_name, global_myname);
strupper(my_name);
- status = lookup_user_rids(samlogon_user, &r_uid, &r_gid);
- status = getusergroupsnam(samlogon_user, &grp_mem, &num_gids) ? 0 : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP;
+ status = lookup_user_rids(nt_username, &r_uid, &r_gid);
+ status = getusergroupsnam(nt_username, &grp_mem, &num_gids) ? 0 : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP;
+
+ sam_logon_in_ssb = False;
if (status == 0x0)
{
&dummy_time, /* pass_can_change_time */
&dummy_time, /* pass_must_change_time */
- samlogon_user , /* user_name */
+ nt_username , /* user_name */
vuser->real_name, /* full_name */
logon_script , /* logon_script */
profile_path , /* profile_path */
}
if (strequal(grp->nt_domain, global_sam_name) &&
- lookup_wk_group_name(grp->nt_name, &sid, &tmp_type))
+ lookup_builtin_grp_name(grp->nt_name, &sid, &tmp_type) == 0x0)
{
sid_copy(&grp->sid, &sid);
return True;
}
else
{
+ BOOL ret;
+ fstring sid_str;
if (type == GROUP_DOMAIN)
{
tmp_rid = pwdb_gid_to_group_rid(grp->unix_gid);
{
tmp_rid = pwdb_gid_to_alias_rid(grp->unix_gid);
}
- return sid_append_rid(&(grp->sid), tmp_rid);
+ ret = sid_append_rid(&(grp->sid), tmp_rid);
+ sid_to_string(sid_str, &grp->sid);
+ DEBUG(10,("nt name %s gid %d mapped to %s\n",
+ grp->nt_name, grp->unix_gid, sid_str));
+ return ret;
}
}
/**************************************************************************
Load a name map file. Sets last accessed timestamp.
***************************************************************************/
-static void load_name_map(GROUP_TYPE type)
+static ubi_slList *load_name_map(GROUP_TYPE type)
{
static time_t groupmap_file_last_modified = (time_t)0;
static time_t aliasmap_file_last_modified = (time_t)0;
if (!(*initialised))
{
+ DEBUG(10,("initialising group map %s\n", map_file));
ubi_slInitList(map_list);
(*initialised) = True;
}
if (!*map_file)
{
- return;
+ return map_list;
}
if (sys_stat(map_file, &st) != 0)
{
DEBUG(0, ("load_name_map: Unable to stat file %s. Error was %s\n",
map_file, strerror(errno) ));
- return;
+ return map_list;
}
/*
*/
if (st.st_mtime <= (*file_last_modified))
{
- return;
+ return map_list;
}
(*file_last_modified) = st.st_mtime;
{
DEBUG(0,("load_name_map: can't open name map %s. Error was %s\n",
map_file, strerror(errno)));
- return;
+ return map_list;
}
/*
if (make_name_entry(&new_ep, nt_domain, nt_name, unixname, type))
{
- ubi_slAddHead(map_list, (ubi_slNode *)new_ep);
+ ubi_slAddTail(map_list, (ubi_slNode *)new_ep);
}
}
DEBUG(10,("load_name_map: Added %ld entries to name map.\n",
- ubi_slCount(map_list)));
+ ubi_slCount(map_list)));
fclose(fp);
+
+ return map_list;
}
/***********************************************************
Lookup by SID
************************************************************/
-static BOOL map_sid(GROUP_TYPE type, ubi_slList *map_list,
+static BOOL map_sid(GROUP_TYPE type,
DOM_SID *psid, gid_t *gid, char *ntname, char *ntdomain)
{
name_map_entry *gmep;
+ ubi_slList *map_list;
/*
- * Initialize and load if not already loaded.
+ * Initialise and load if not already loaded.
*/
- load_name_map(type);
+ map_list = load_name_map(type);
for (gmep = (name_map_entry *)ubi_slFirst(map_list);
gmep != NULL;
/***********************************************************
Lookup nt name.
************************************************************/
-static BOOL map_ntname(GROUP_TYPE type, ubi_slList *map_list,
+static BOOL map_ntname(GROUP_TYPE type,
char *ntname, char *ntdomain, DOM_SID *psid,
char *unixname, gid_t *gid)
{
name_map_entry *gmep;
+ ubi_slList *map_list;
/*
- * Initialize and load if not already loaded.
+ * Initialise and load if not already loaded.
*/
- load_name_map(type);
+ map_list = load_name_map(type);
- for (gmep = (name_map_entry *)ubi_slFirst(&map_list);
+ for (gmep = (name_map_entry *)ubi_slFirst(map_list);
gmep != NULL;
gmep = (name_map_entry *)ubi_slNext(gmep ))
{
{
if (psid != NULL)
{
- *psid = gmep->grp.sid;
+ sid_copy(psid, &gmep->grp.sid);
}
if (gid != NULL)
{
/***********************************************************
Lookup unix name.
************************************************************/
-static BOOL map_unixname(GROUP_TYPE type, ubi_slList *map_list,
+static BOOL map_unixname(GROUP_TYPE type,
char *unixname, DOM_SID *psid, char *ntname, char *ntdomain)
{
name_map_entry *gmep;
+ ubi_slList *map_list;
/*
- * Initialize and load if not already loaded.
+ * Initialise and load if not already loaded.
*/
- load_name_map(type);
+ map_list = load_name_map(type);
- for (gmep = (name_map_entry *)ubi_slFirst(&map_list);
+ for (gmep = (name_map_entry *)ubi_slFirst(map_list);
gmep != NULL;
gmep = (name_map_entry *)ubi_slNext(gmep ))
{
{
if (psid != NULL)
{
- *psid = gmep->grp.sid;
+ sid_copy(psid, &gmep->grp.sid);
}
if (ntname != NULL)
{
/***********************************************************
Lookup by gid_t.
************************************************************/
-static BOOL map_gid(GROUP_TYPE type, ubi_slList *map_list,
+static BOOL map_gid(GROUP_TYPE type,
gid_t gid, DOM_SID *psid, char *ntname, char *ntdomain)
{
name_map_entry *gmep;
+ ubi_slList *map_list;
/*
- * Initialize and load if not already loaded.
+ * Initialise and load if not already loaded.
*/
- load_name_map(type);
+ map_list = load_name_map(type);
- for (gmep = (name_map_entry *)ubi_slFirst(&map_list);
+ for (gmep = (name_map_entry *)ubi_slFirst(map_list);
gmep != NULL;
gmep = (name_map_entry *)ubi_slNext(gmep ))
{
+ fstring sid_str;
+ sid_to_string(sid_str, &gmep->grp.sid);
+ DEBUG(10,("map_gid: enum entry unix group %s %d nt %s %s\n",
+ gmep->grp.unix_name, gmep->grp.unix_gid, gmep->grp.nt_name, sid_str));
if (gmep->grp.unix_gid == gid)
{
if (psid != NULL)
{
- *psid = gmep->grp.sid;
+ sid_copy(psid, &gmep->grp.sid);
}
if (ntname != NULL)
{
************************************************************/
BOOL map_group_sid(DOM_SID *psid, gid_t *gid, char *group_name, char *nt_domain)
{
- return map_sid(GROUP_DOMAIN, &groupname_map_list, psid, gid, group_name, nt_domain);
+ return map_sid(GROUP_DOMAIN, psid, gid, group_name, nt_domain);
}
/***********************************************************
************************************************************/
BOOL map_alias_sid(DOM_SID *psid, gid_t *gid, char *alias_name, char *nt_domain)
{
- return map_sid(GROUP_LOCAL, &aliasname_map_list, psid, gid, alias_name, nt_domain);
+ return map_sid(GROUP_LOCAL, psid, gid, alias_name, nt_domain);
}
/***********************************************************
************************************************************/
BOOL map_unix_group_name(char *group_name, DOM_SID *psid, char *ntgroup_name, char *nt_domain)
{
- return map_unixname(GROUP_DOMAIN, &groupname_map_list, group_name, psid, ntgroup_name, nt_domain);
+ return map_unixname(GROUP_DOMAIN, group_name, psid, ntgroup_name, nt_domain);
}
/***********************************************************
************************************************************/
BOOL map_unix_alias_name(char *alias_name, DOM_SID *psid, char *ntalias_name, char *nt_domain)
{
- return map_unixname(GROUP_LOCAL, &aliasname_map_list, alias_name, psid, ntalias_name, nt_domain);
+ return map_unixname(GROUP_LOCAL, alias_name, psid, ntalias_name, nt_domain);
}
/***********************************************************
************************************************************/
BOOL map_nt_group_name(char *ntgroup_name, char *nt_domain, DOM_SID *psid, char *group_name, gid_t *gid)
{
- return map_ntname(GROUP_DOMAIN, &groupname_map_list, ntgroup_name, nt_domain, psid, group_name, gid);
+ return map_ntname(GROUP_DOMAIN, ntgroup_name, nt_domain, psid, group_name, gid);
}
/***********************************************************
************************************************************/
BOOL map_nt_alias_name(char *ntalias_name, char *nt_domain, DOM_SID *psid, char *alias_name, gid_t *gid)
{
- return map_ntname(GROUP_LOCAL, &aliasname_map_list, ntalias_name, nt_domain, psid, alias_name, gid);
+ return map_ntname(GROUP_LOCAL, ntalias_name, nt_domain, psid, alias_name, gid);
}
/***********************************************************
************************************************************/
BOOL map_alias_gid(gid_t gid, DOM_SID *psid, char *nt_als_name, char *nt_domain)
{
- return map_gid(GROUP_LOCAL, &aliasname_map_list, gid, psid, nt_als_name, nt_domain);
+ return map_gid(GROUP_LOCAL, gid, psid, nt_als_name, nt_domain);
}
/***********************************************************
************************************************************/
BOOL map_group_gid( gid_t gid, DOM_SID *psid, char *nt_grp_name, char *nt_domain)
{
- return map_gid(GROUP_DOMAIN, &groupname_map_list, gid, psid, nt_grp_name, nt_domain);
+ return map_gid(GROUP_DOMAIN, gid, psid, nt_grp_name, nt_domain);
}