[exim] Transport command lookup, splitting argv[0] after exp…

Top Page
Delete this message
Reply to this message
Author: Guillaume Blairon
Date:  
To: exim-users
Subject: [exim] Transport command lookup, splitting argv[0] after expansion
Hi list,


I'm trying to setup a pipe transport with a dbm lookup of its command.
Apparently, it only works without args because it doesn't split args
after lookup. Here's an example :


1 - Create a dbm with a key containing a command with 1 or more args :
--
$ perl -e 'dbmopen(my %db, "/tmp/test.db", 0666); $db{test} = "/bin/echo test"; dbmclose(%db);'


2 - Configure a simple transport looking up this command :
--
test_delivery:
driver = pipe
command = ${lookup{test}dbmnz{/tmp/test.db}}


3 - Test it (this is Exim 4.43) :
--
>>>>>>>>>>>>>>>> Local deliveries >>>>>>>>>>>>>>>>

--------> test@??? <--------
locking /var/spool/exim/db/retry.lockfile
locked /var/spool/exim/db/retry.lockfile
opened hints database /var/spool/exim/db/retry: flags=0
dbfn_read: key=T:test@???
no retry record exists
search_tidyup called
changed uid/gid: local delivery to test <test@???> transport=test_t
uid=8 gid=12 pid=17434
auxiliary group list: <none>
home=NULL current=/
set_process_info: 17434 delivering 1MsvKS-0004X2-CT to test using test_t
test_t transport entered
direct command:
argv[0] = ${lookup{test}dbmnz{/tmp/test.db}}
search_open: dbmnz "/tmp/test.db"
search_find: file="/tmp/test.db"
key="test" partial=-1 affix=NULL starflags=0
LRU list:
2/tmp/test.db
End
internal_search_find: file="/tmp/test.db"
type=dbmnz key="test"
file lookup required for test
in /tmp/test.db
lookup yielded: /bin/echo test
direct command after expansion:
argv[0] = /bin/echo test
set_process_info: 17436 reading output from |${lookup{test}dbmnz{/tmp/test.db}}
Writing message to pipe
writing data block fd=9 size=54 timeout=3600
writing error 32: Broken pipe
transport error EPIPE ignored
test_t transport yielded 2
search_tidyup called
test_t transport returned FAIL for test@???
post-process test@??? (2)
LOG: MAIN
** test@??? R=test_r T=test_t: Child process of test_t transport returned 127 (could mean unable to exec or command does not exist) from command: "/bin/echo test"
>>>>>>>>>>>>>>>> deliveries are done >>>>>>>>>>>>>>>>



As you can see, argv[0] contains "/bin/echo test". I'm not a programming
expert but according to execve(2), that's bad.

Is this a normal behaviour ? If so, how can I ensure that exim will
correctly split the command and its args before calling execve() ?


Thanks,

--
Guillaume