From 2a53d6f7077de596265a3e73e79827392054142c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Apr 1998 00:41:59 +0000 Subject: Modified interfaces to getting smb password entries from get_smbpwd_entry (now an internal function to smbpass.c) to a more UNIX-like : getsmbpwnam() - get entry by name. getsmbpwuid() - get entry by uid. Changed the type returned by the smbpasswd enumeration functions to be a void * so that people don't come to depend on it being a FILE *. These abstractions should make it much easier to replace the smbpasswd file with a better backend in future. Other files changed are to match the above changes. Jeremy. (This used to be commit 1161cfb7f2b0d5a6d3e2b524a14a6f325ce70efb) --- source3/rpc_server/srv_netlog.c | 4 ++-- source3/rpc_server/srv_samr.c | 18 +++++++++--------- source3/rpc_server/srv_util.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index a08ea2395b..3912ad7938 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -238,7 +238,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) } become_root(True); - smb_pass = get_smbpwd_entry(mach_acct, 0); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) @@ -637,7 +637,7 @@ static void api_net_sam_logon( int uid, DEBUG(3,("User:[%s]\n", samlogon_user)); become_root(True); - smb_pass = get_smbpwd_entry(samlogon_user, 0); + smb_pass = getsmbpwnam(samlogon_user); unbecome_root(True); if (smb_pass == NULL) diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 02c8cb0ffe..162d9c45d0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -43,7 +43,7 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, int max_num_entries, uint16 acb_mask) { - FILE *fp = NULL; + void *vp = NULL; struct smb_passwd *pwd = NULL; (*num_entries) = 0; @@ -51,14 +51,14 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, if (pw_buf == NULL) return False; - fp = startsmbpwent(False); - if (!fp) + vp = startsmbpwent(False); + if (!vp) { DEBUG(0, ("get_smbpwd_entries: Unable to open SMB password file.\n")); return False; } - while (((pwd = getsmbpwent(fp)) != NULL) && (*num_entries) < max_num_entries) + while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) { int user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); @@ -91,7 +91,7 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, (*total_entries)++; } - endsmbpwent(fp); + endsmbpwent(vp); return (*num_entries) > 0; } @@ -806,7 +806,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, } become_root(True); - smb_pass = get_smbpwd_entry(NULL, q_u->user_rid); + smb_pass = getsmbpwuid(q_u->user_rid); unbecome_root(True); /* check that the RID exists in our domain. */ @@ -877,7 +877,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) struct smb_passwd *smb_pass; become_root(True); - smb_pass = get_smbpwd_entry(NULL, rid); + smb_pass = getsmbpwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1095,7 +1095,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { become_root(True); - smb_pass = get_smbpwd_entry(NULL, rid); + smb_pass = getsmbpwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1191,7 +1191,7 @@ static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) q_u.uni_mach_acct.uni_str_len)); become_root(True); - smb_pass = get_smbpwd_entry(mach_acct, 0); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 3f4d66eab2..868cf3a4ac 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -367,7 +367,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) /* find the user account */ become_root(True); - smb_pass = get_smbpwd_entry(NULL, rid); /* lkclXXXX SHOULD use rid mapping here! */ + smb_pass = getsmbpwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ unbecome_root(True); if (smb_pass != NULL) @@ -427,7 +427,7 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) /* find the user account */ become_root(True); - smb_pass = get_smbpwd_entry(user_name, 0); + smb_pass = getsmbpwnam(user_name); unbecome_root(True); if (smb_pass != NULL) -- cgit