Re: [exim] getpwuid equivalent for username lookup?

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Mike Cardwell
Fecha:  
A: exim-users
Asunto: Re: [exim] getpwuid equivalent for username lookup?
* 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:
>
> Figure out the owner of the "/etc/passwd" file and the "/etc/openvpn"
> dir:
>
> mike@clayman:~$ ls -l /etc/passwd
> -rw-r--r-- 1 root root 1858 2007-05-25 07:34 /etc/passwd
> mike@clayman:~$ ls -ld /etc/openvpn
> drwx------ 5 openvpn openvpn 4096 2007-05-02 20:52 /etc/openvpn
> mike@clayman:~$
> mike@clayman:~$ /usr/sbin/exim -be
> > ${if match{${sg{${readfile{/etc/passwd}}}{\n}{|}}}{^(.*\\|)?([^:]+):[^:]*:${extract{uid}{${stat:/etc/passwd}}}:}{$2}{UNKNOWN}}
> root
> > ${if match{${sg{${readfile{/etc/passwd}}}{\n}{|}}}{^(.*\\|)?([^:]+):[^:]*:${extract{uid}{${stat:/etc/openvpn}}}:}{$2}{UNKNOWN}}
> openvpn


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


    >


Mike