1

I was trying to configure dkimproxy on my server, after having used dkfilter for long time with success. The reason why I chose to "upgrade" is that DKIM protocol seems to be better supported than DomainKeys by major providers like Gmail.

I want only to sign outbound messages, and not to verify inbound ones. I configured dkimproxy_out.conf correctly but rcdkimproxy start does nothing. If I do rcdkimproxy start-out, instead, it works.

I'm no great bash expert, but I found this in /etc/init.d/dkimproxy

    start)
            test -f $DKIMPROXY_IN_CFG && $0 start-in || exit $?
            test -f $DKIMPROXY_OUT_CFG && $0 start-out || exit $?
            ;;

Which "should" test if the configuration file exists, and if so run the dkimproxy start-out command. I'm sure that the file exists and is correct (otherwise it won't manually start), however I found that manually doing test -f /usr/share/dkimproxy/etc/dkimproxy_out.conf; echo $? returns 0.

What could be wrong in these statements? I use openSUSE 11.3 kernel 2.6.32. If you think this script is broken I can try to report a bug to the author of dkimproxy.

Thank you

usr-local-ΕΨΗΕΛΩΝ
  • 2,339
  • 7
  • 33
  • 50
  • 2
    Remember that in the world of shell scripts, `0` means "success". So "test -f" returns `0` if the file exists. You can try running the script with the `-x` flag (`sh -x /etc/init.d/dkimproxy start`) to see exactly what's going on. – larsks Jan 28 '11 at 20:19
  • So here is the problem. AND is short-circuited, and the second statement doesn't get executed! The author should have done something like if !test like I would do in other scripting languages – usr-local-ΕΨΗΕΛΩΝ Jan 28 '11 at 20:26
  • In the world of bash, the shell expects `0` to be success, and logic is arranged accordingly (non-zero command return values are "false"). I suspect what's really happening is that "$0 start-in" is exiting but not returning a non-zero value indicating a problem. This is pretty common with servers that fork into the background, by the time the command exits the server hasn't crashed yet so everything is OK – DerfK Jan 28 '11 at 20:43
  • Actually, $0 start-out (which is what I'm interested in) is not executed at all, because I see no output, so even start-in is not executed. I temporary replaced the whole function with $0 start-out (and the stop methods accordingly) and works, but I would have liked to understand WHY it didn't work... and thanks to the comment by larsks I'm starting to understand... – usr-local-ΕΨΗΕΛΩΝ Jan 28 '11 at 20:49

1 Answers1

1

Newest dkimproxy package uses following lines:

start)
     test -f $DKIMPROXY_IN_CFG && { $0 start-in || exit $?; }
     test -f $DKIMPROXY_OUT_CFG && { $0 start-out || exit $?; }
     ;;

Changing your init script to use lines above should fix problem correctly, with checking existence of config files.

Funny thing is that in Debian both formats work without any problems at all.

As usual, script uses /bin/sh instead of bash, and in some systems (including Debian) sh is Bourne Shell, while /bin/bash is more advanced Bourne Again Shell. Both shells expect 0 as success from test, so "test && command" is right format when wanting to run command if test succeeds.

Olli
  • 768
  • 6
  • 16