Re: [exim] getpwuid equivalent for username lookup?

Top Page
Delete this message
Reply to this message
Author: John Robinson
Date:  
To: Exim Users
Subject: Re: [exim] getpwuid equivalent for username lookup?
On 25/05/2007 16:16, Mike Cardwell wrote:
> * on the Fri, May 25, 2007 at 03:20:43PM +0100, Mike Cardwell wrote:
>> I don't know if there's a nice solution. If your users are locally
>> stored in /etc/passwd you can grab the uid via stat and then look them
>> up from /etc/passwd using a ${readfile} and some regex's. The horrifying
>> solution:

[...]
>>> ${if match{${sg{${readfile{/etc/passwd}}}{\n}{|}}}{^(.*\\|)?([^:]+):[^:]*:${extract{uid}{${stat:/etc/passwd}}}:}{$2}{UNKNOWN}}
>> root


Yeuch! But it works. Good effort...

[...]
> I forgot to suggest a reason as to why your run expansion wasn't
> working. This perhaps?
>
>     > ${run{stat -c %U /etc/passwd}}

>
>     > ${run{/usr/bin/stat -c %U /etc/passwd}}
>     root


Doh! That works.

I think I prefer the yeuch answer, as I suspect that it's more
efficient, certainly if things like readfile and compiled regexps get
cached, as fork()ing and/or exec()ing will probably be more expensive.

Thank you!

Cheers,

John.