summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/lib/username.c25
2 files changed, 15 insertions, 13 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index b12787fecb..12958baa3a 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -382,6 +382,8 @@ void unbecome_unix_root_sec_ctxt(void);
/*The following definitions come from lib/username.c */
+struct passwd *hashed_getpwnam(const char *name);
+char *uidtoname(uid_t uid);
char *get_home_dir(char *user);
BOOL map_username(char *user);
struct passwd *Get_Pwnam(char *user,BOOL allow_change);
@@ -448,7 +450,6 @@ BOOL process_exists(int pid);
int get_unixgroups(char *user, uid_t uid, gid_t gid, int *p_ngroups, gid_t **p_groups);
BOOL get_unix_grps(int *p_ngroups, struct group **p_groups);
void free_unix_grps(int ngroups, struct group *p_groups);
-char *uidtoname(uid_t uid);
char *gidtoname(gid_t gid);
BOOL nametogid(const char *name, gid_t *gid);
BOOL nametouid(const char *name, uid_t *uid);
diff --git a/source3/lib/username.c b/source3/lib/username.c
index 4daf30fdd4..ef172b63de 100644
--- a/source3/lib/username.c
+++ b/source3/lib/username.c
@@ -51,7 +51,7 @@ struct passwd_hash_table_s {
NULL,0,NULL,NULL,NULL,0,{0,0}
};
-int name_hash_function(const char *name)
+static int name_hash_function(const char *name)
{
/* I guess that there must be better hash functions. This one was the
* first to come into mind :) */
@@ -65,13 +65,13 @@ int name_hash_function(const char *name)
return value;
}
-int uid_hash_function(uid_t uid)
+static int uid_hash_function(uid_t uid)
{
return uid%PASSWD_HASH_SIZE;
}
-BOOL build_passwd_hash_table()
+static BOOL build_passwd_hash_table(void)
{
struct passwd_hash_table_s *pht=&passwd_hash_table; /* Convenience */
int num_passwds=0;
@@ -213,7 +213,8 @@ BOOL build_passwd_hash_table()
return False;
}
-BOOL have_passwd_hash() {
+static BOOL have_passwd_hash(void)
+{
struct passwd_hash_table_s *pht=&passwd_hash_table;
struct timeval tv;
GetTimeOfDay(&tv);
@@ -233,9 +234,9 @@ struct passwd *hashed_getpwnam(const char *name)
if (have_passwd_hash()) {
int name_i=name_hash_function(name);
- int index=pht->names[name_i];
- while(index!=-1) {
- struct passwd *pass=&pht->passwds[pht->entries[index].entry];
+ int hash_index=pht->names[name_i];
+ while(hash_index!=-1) {
+ struct passwd *pass=&pht->passwds[pht->entries[hash_index].entry];
if (strcmp(name,pass->pw_name)==0) {
DEBUG(5,("Found: %s:%s:%d:%d:%s:%s:%s\n",
pass->pw_name,
@@ -247,7 +248,7 @@ struct passwd *hashed_getpwnam(const char *name)
pass->pw_shell));
return pass;
}
- index=pht->entries[index].next;
+ hash_index=pht->entries[hash_index].next;
}
/* Not found */
@@ -269,9 +270,9 @@ char *uidtoname(uid_t uid)
DEBUG(5,("uidtoname(%d)\n",uid));
if (have_passwd_hash()) {
- int index=pht->uids[uid_hash_function(uid)];
- while(index!=-1) {
- pass=&pht->passwds[pht->entries[index].entry];
+ int hash_index=pht->uids[uid_hash_function(uid)];
+ while(hash_index!=-1) {
+ pass=&pht->passwds[pht->entries[hash_index].entry];
if (pass->pw_uid==uid) {
DEBUG(5,("Found: %s:%s:%d:%d:%s:%s:%s\n",
pass->pw_name,
@@ -283,7 +284,7 @@ char *uidtoname(uid_t uid)
pass->pw_shell));
return pass->pw_name;
}
- index=pht->entries[index].next;
+ hash_index=pht->entries[hash_index].next;
}
DEBUG(5,("Hash miss"));
pass=NULL;