Re: [Exim] 'user' type?

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Derek Simkowiak
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: Re: [Exim] 'user' type?
>     So my questions are:
>
> 1. Can variables of type "string" still use the expansion variables in
> section 11.8?
>
> 2. Can I do a database lookup for the 'user' variable? The spec says "A
> string that is to be expanded may contain explicit lookup requests", but
> says nothing about lookups for regular (non-expanded) strings.


    I forgot to mention this was with version 4.12.


    I took a look at the code and found some things that make it look
like the docs have simply not been updated yet.  There are two types of
enum flags in the code: opt_uid, and opt_expand_uid.  'opt_expand_uid' is
used in route.c and transport.c, but 'opt_uid' is not used anywhere, so
perhaps 'opt_uid' was used in a previous version of Exim.


    The "user" option for both routers and transports are of the
expanded kind:


[dereks@dev src]$ grep opt_expand_uid transport.c route.c
transport.c:  { "user",             opt_expand_uid|opt_public,
route.c:  { "user",               opt_expand_uid | opt_public,


    Within readconf.c, near line 1165, the flag opt_expand_uid causes
the "user"  option to be transformed into the "expand_user" option.  The
internal transport "expand_user" option refers to the "expand_uid" field
of the transport_instance struct:


[dereks@dev src]$ grep -A 1 expand_user transport.c
  { "*expand_user",     opt_stringptr|opt_hidden|opt_public,
                 (void *)offsetof(transport_instance, expand_uid) },


    Grepping for 'expand_uid' led me to a function called
route_find_expanded_user(), which is called in deliver.c near line 1214.
That function calls expand_string() on the "user" option (cool!).


    Looking at expand.c, expand_string() (and hence
expand_string_internal() ) do seem to allow for database lookups, because
near line 2258 there is a comment that says:


    /* Handle database lookups unless locked out. [...]


    Finally, all of the above seems to apply to both routers and
transports, for both the "user" option and the "group" option.



    So based on this research, I would say:


> 1. Can variables of type "string" still use the expansion variables in
> section 11.8?


    No.  But contrary to the Spec, the global router and transport
options "user" and "group" are not actually of type "string", they are of
a new type "expanded user/group string".  These new types are first
expanded, but the resulting expansion must "either consist entirely of
digits, or be a name that can be looked up using the getpwnam() or
getgrnam() function".



> 2. Can I do a database lookup for the 'user' variable?


    Yes, the "user" and "group" options are subjected to the
expand_string() function, which means they are subject to database
lookups.


    If anyone can offer some verification of this (like a working
install of "user"/"group" with database lookups), I would appreciate it.



Thanks,
Derek