summaryrefslogtreecommitdiff
path: root/source3/lib/username.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-07-24 20:02:48 +0000
committerSimo Sorce <idra@samba.org>2001-07-24 20:02:48 +0000
commit1cbae7315f99835ee294ce96858f73b5f8a18cfe (patch)
treed1c791f20d4e2b3246b3f53ed5dcc02956b3080d /source3/lib/username.c
parent78dfa74852896dcc18513c1ba9a0dcaaf0c2a146 (diff)
downloadsamba-1cbae7315f99835ee294ce96858f73b5f8a18cfe.tar.gz
samba-1cbae7315f99835ee294ce96858f73b5f8a18cfe.tar.bz2
samba-1cbae7315f99835ee294ce96858f73b5f8a18cfe.zip
Convert other parameters (read list, write list, valid users...) to the P_LIST format.
changed functions to use list instead of strings addedd lp_list_substitute function (This used to be commit 7257d07563ba21bd88733d5d2b4ec4829fab2507)
Diffstat (limited to 'source3/lib/username.c')
-rw-r--r--source3/lib/username.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/source3/lib/username.c b/source3/lib/username.c
index 403a855f1a..6abc4f9a77 100644
--- a/source3/lib/username.c
+++ b/source3/lib/username.c
@@ -93,6 +93,7 @@ BOOL map_username(char *user)
while((s=fgets_slash(buf,sizeof(buf),f))!=NULL) {
char *unixname = s;
char *dosname = strchr_m(unixname,'=');
+ char **dosuserlist;
BOOL return_if_mapped = False;
if (!dosname)
@@ -120,17 +121,26 @@ BOOL map_username(char *user)
}
}
- if (strchr_m(dosname,'*') || user_in_list(user,dosname)) {
+ dosuserlist = lp_list_make(dosname);
+ if (!dosuserlist) {
+ DEBUG(0,("Unable to build user list\n"));
+ return False;
+ }
+
+ if (strchr_m(dosname,'*') || user_in_list(user, dosuserlist)) {
DEBUG(3,("Mapped user %s to %s\n",user,unixname));
mapped_user = True;
fstrcpy(last_from,user);
sscanf(unixname,"%s",user);
fstrcpy(last_to,user);
- if(return_if_mapped) {
+ if(return_if_mapped) {
+ lp_list_free (&dosuserlist);
fclose(f);
return True;
}
}
+
+ lp_list_free (&dosuserlist);
}
fclose(f);
@@ -382,18 +392,18 @@ BOOL user_in_group_list(char *user,char *gname)
and netgroup lists.
****************************************************************************/
-BOOL user_in_list(char *user,char *list)
+BOOL user_in_list(char *user,char **list)
{
- pstring tok;
- char *p=list;
- DEBUG(10,("user_in_list: checking user %s in list %s\n", user, list));
+ if (!list || !*list) return False;
+
+ DEBUG(10,("user_in_list: checking user %s in list\n", user));
- while (next_token(&p,tok,LIST_SEP, sizeof(tok))) {
+ while (*list) {
/*
* Check raw username.
*/
- if (strequal(user,tok))
+ if (strequal(user, *list))
return(True);
/*
@@ -401,24 +411,24 @@ BOOL user_in_list(char *user,char *list)
* of UNIX and netgroups has been specified.
*/
- if(*tok == '@') {
+ if(**list == '@') {
/*
* Old behaviour. Check netgroup list
* followed by UNIX list.
*/
- if(user_in_netgroup_list(user,&tok[1]))
+ if(user_in_netgroup_list(user, *list +1))
return True;
- if(user_in_group_list(user,&tok[1]))
+ if(user_in_group_list(user, *list +1))
return True;
- } else if (*tok == '+') {
+ } else if (**list == '+') {
- if(tok[1] == '&') {
+ if((*(*list +1)) == '&') {
/*
* Search UNIX list followed by netgroup.
*/
- if(user_in_group_list(user,&tok[2]))
+ if(user_in_group_list(user, *list +2))
return True;
- if(user_in_netgroup_list(user,&tok[2]))
+ if(user_in_netgroup_list(user, *list +2))
return True;
} else {
@@ -427,28 +437,30 @@ BOOL user_in_list(char *user,char *list)
* Just search UNIX list.
*/
- if(user_in_group_list(user,&tok[1]))
+ if(user_in_group_list(user, *list +1))
return True;
}
- } else if (*tok == '&') {
+ } else if (**list == '&') {
- if(tok[1] == '+') {
+ if(*(*list +1) == '+') {
/*
* Search netgroup list followed by UNIX list.
*/
- if(user_in_netgroup_list(user,&tok[2]))
+ if(user_in_netgroup_list(user, *list +2))
return True;
- if(user_in_group_list(user,&tok[2]))
+ if(user_in_group_list(user, *list +2))
return True;
} else {
/*
* Just search netgroup list.
*/
- if(user_in_netgroup_list(user,&tok[1]))
+ if(user_in_netgroup_list(user, *list +1))
return True;
}
}
+
+ list++;
}
return(False);
}