Vixie-cron recently switched from logging messages as "cron" to logging with the string it was called by (argv[0]). So, using the current init script, I get messages from /usr/sbin/cron, which I find a bit ugly. I modified my /etc/init.d/vixie-cron by adding a "cd /usr/sbin" just after 'ebegin "Starting vixie-cron"' and changing "start-stop-daemon --start --quiet --exec /usr/sbin/cron" to "start-stop-daemon --start --quiet --exec cron" Everything works just fine here, and my syslog is a bit cleaner. I think it would be a nice, if insignifigant, enhancement to the init script.
Yeah this has bothered me for a while too.. like you said insignificant, but still annoying. There's two options; either use 'cd /usr/sbin' in the init script or patch vixie to use basename(argv[0]). I prefer the latter tbh. Ciaran?
Is . in PATH for init scripts?
no (but if it is, please file a bug so we can fix that)
no, . is not in the $PATH. but to answer ciaran's question, the reason my hack works is because the shell is not executing cron, and so it doesn't matter what the $PATH variable is. The executable is being run by start-stop-daemon, which is probably doing something like execv("cron"), so the cron binary only needs to be given as a pathname, when I tried changing the argument of start-stop-daemon to "./cron" I started getting syslog messages from ./cron[pid]. so this convirms my belief that newer versions of cron are logging with argv[0]. If you don't like my init script hack, and you don't want to waste time writing a basename(argv[0]) patch like ka0ttic suggested, then let me know, I think I may be able to produce such a patch.
ok I got bored and wrote a patch anyway. Its my first time writing any real C, and I'm not sure I used diff correctly, so feel free to tell me I'm dumb. In any event, its only a 3 line patch. should I also edit the ebuild to use the patch?
Created attachment 51316 [details, diff] basename patch
Looks better than my first patch ;) The patch would be fine if Linux was the only operating system Gentoo ran on. A better alternative would be using the POSIX version (via libgen.h) as it would run on any POSIX-compliant OS. Whether or not we decide to patch vixie or modify the init script (or another unthought of option) is still in the air though.
I had another patch that used he POSIX version of basename, but I switched to the GNU version because it doesnt modify its argument. I can go back to libgen.h very easily though, so I'll put that patch on here when I get the chance.
Created attachment 51481 [details, diff] POSIX compliant basename patch This doesn't backup and restore argv[0], but I don't think that will be a problem. If you think it will be, or you hit any bugs, I'll make a new patch.
Fixed. Thanks for the patch.