Proposal: filename map
Luke Kenneth Casson Leighton
lkcl at switchboard.net
Sat Jun 13 17:26:21 GMT 1998
On Fri, 12 Jun 1998, Kevin Currie wrote:
> >first things first: would you like to have a go at abstracting the "map
> >username" code?
>
> >we need to use it [the code that currently only reads the "map username"
> >option] in other places, and your suggestion is one of them.
>
>
> Okay after looking at the "map username" code (the part that reads the
> file anyway), here is how I interpret what you are talking about.
> we have a function something like:
>
> char * file_mapping(char * mapfilename, char * variable);
yep.
> This fucntion will read mapfilename line by line. It will change any
> Samba % qualifiers into their equivilant values and both sides of the "="
map_username() in username.c doesn't actually do this, but if an extra
argument is added (BOOL subst) then call standard_sub() on the lhs and
rhs.
what benefit does this give you?
> then try and match variable to something on the right side of the "=" and if
> it does, it will change variable to the match on the left side of the "=".
> Thus,
>
>
> // code sort of semi-example
>
> char * user = "Administrator";
> char * file = "/etc/smbusers";
>
> // This is the old way
>
> mapuser(user);
actually map_username() in username.c
> // this becomes, or something similar
>
> user = file_mapping(file, user);
user = file_mapping(lp_username (), user);
or group = file_mapping(lp_groupname(), group);
> Is this sort of what you had in mind?
yep, and if you call the function file_mapping.c, it should go in a new
module called filemap.c. and then map_username(char *user) becomes {
return file_mapping(lp_username(), user); }
simple, really.
More information about the samba-technical
mailing list