[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] Stupid cron question
* Chris J/#6 (sixie [at] nccnet.co.uk) wrote:
>
>
> > Just out of interest, how does the system figure where to store a
> > user's crontab?
> >
>
> Hard coded in cron I'd imagine -- do a "strings crontab" and a "strings cron"
> see if the path leaps out at you. Failing that, strace the bugger :)
>
>
> > Why bother with the wierdly named /tmp/ file?
> >
>
> When you type "crontab -e", crontab starts $EDITOR. This editor is editing
> that temproray file. When you save and close $EDITOR, it installs the
> temporary file /tmp/foo.bar to /var/spool/cron/crontabs (or wherever). The
> temporary filename is random, and in your case I'd imagine the template for
> the name is /tmp/crontab.<pid>. On my box, the temporary file is
> /tmp/crontab.XXXXQQe4uS.
>
I wouldn't swear to it.. but maybe to get around problems with the
editor not writing atomicly, and possibility of there being only part of
a crontab there at the moment cron runs?
I'm probably wrong of course.. and it's just be to stop the user
needing permissions to /var/spool/cron/crontabs/.
I also recall reading an argument against using pid's in temporary
filenames, although I can't remember it now, and possibly it was against
using consecutive pid's.. but I seem to recall it being by one of the
OpenBSD folks..
And seeing as I'm babbling like a cretin anyway.
Why is it, that every peice of information about creating secure tmp
files, says to use mkstemp(), but the mkstemp() manpage says not to use it,
and to use tmpfile()? :) (and seeing as mkstemp() uses the pid, I guess
what I was thinking about, must be random pids).
*goes to sit quietly with his dunce cap in readiness* :)
--
[ Richard Lowe - richlowe - richlowe [at] richlowe.demon.co.uk ]
[ http://www.snowman.net/~richlowe/ ]
---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word
"unsubscribe" in the body of the message.
GNU the choice of a complete generation.