Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 82057 - Minor change to init script to clean up syslog
Summary: Minor change to init script to clean up syslog
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Cron Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-14 17:37 UTC by Colin Kingsley (RETIRED)
Modified: 2005-02-23 03:17 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
basename patch (basename.patch,396 bytes, patch)
2005-02-15 19:56 UTC, Colin Kingsley (RETIRED)
Details | Diff
POSIX compliant basename patch (basename.patch,384 bytes, patch)
2005-02-17 15:34 UTC, Colin Kingsley (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Kingsley (RETIRED) gentoo-dev 2005-02-14 17:37:57 UTC
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.
Comment 1 Aaron Walker (RETIRED) gentoo-dev 2005-02-15 02:16:51 UTC
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?
Comment 2 Ciaran McCreesh 2005-02-15 07:24:31 UTC
Is . in PATH for init scripts?
Comment 3 SpanKY gentoo-dev 2005-02-15 08:47:39 UTC
no

(but if it is, please file a bug so we can fix that)
Comment 4 Colin Kingsley (RETIRED) gentoo-dev 2005-02-15 18:32:48 UTC
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.
Comment 5 Colin Kingsley (RETIRED) gentoo-dev 2005-02-15 19:56:01 UTC
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?
Comment 6 Colin Kingsley (RETIRED) gentoo-dev 2005-02-15 19:56:41 UTC
Created attachment 51316 [details, diff]
basename patch
Comment 7 Aaron Walker (RETIRED) gentoo-dev 2005-02-16 03:17:08 UTC
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.
Comment 8 Colin Kingsley (RETIRED) gentoo-dev 2005-02-16 10:41:57 UTC
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.
Comment 9 Colin Kingsley (RETIRED) gentoo-dev 2005-02-17 15:34:45 UTC
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.
Comment 10 Aaron Walker (RETIRED) gentoo-dev 2005-02-23 03:17:18 UTC
Fixed.  Thanks for the patch.