* on the Fri, May 25, 2007 at 02:31:54PM +0100, John Robinson wrote:
> I'm trying to get the name of the owner of a file, because I want to run
> spamassassin as that user (one real user per domain, basically). I
> started with
> address_data = ${extract{uid}
> {${stat:/etc/mail/domains/$domain/mailboxes}} {$value} fail}
> but of course that gets me the uid, not the user name. I've looked and I
> don't see any expansion method of turning a uid into a username, and a
> grep of the source doesn't point up any calls to getpwuid() in
> likely-looking places. So then I've tried
> address_data = ${run{stat -c %U /etc/mail/domains/$domain/mailboxes}
> {$value} fail}
> which seems to fail, then in desperation
> address_data = ${run{bash -c "stat -c %U
> /etc/mail/domains/$domain/mailboxes"} {$value} fail}
> which is no better. The following is the result of testing with `exim -v
> -d+all -bv`, firstly without bash:
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
Mike