[Bug 344667] New: cron incorrectly compares files under /etc/cron.d
https://bugzilla.novell.com/show_bug.cgi?id=344667 Summary: cron incorrectly compares files under /etc/cron.d Product: SUSE Linux 10.1 Version: Final Platform: i586 OS/Version: SLES 10 Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: Marshall_Rob@emc.com QAContact: qa@suse.de Found By: Other Because cron organizes its database around users, a problem can arise when comparing the files under /etc/cron.d. If the mtime on /etc/cron.d changes, cron will re-read all the files and update the database. But if the order in which the files get read is different from the current order, comparing the mtimes of the files can lead to overwriting the wrong entry. To test this: # cd /etc/cron.d # touch file1 file2 create a few cron files: cron1, cron2, cron3 also do: # ln -fs /etc/sysstat/sysstat.cron /etc/cron.d/sysstat The above is normally done when the system restarts (/etc/init.d/sysstat). # rm file1 file2 Restart cron. The files will be read into the database in the order: cron1 cron2 cron3 sysstat Wait a minute or two...then: # ln -fs /etc/sysstat/sysstat.cron /etc/cron.d/sysstat The next time cron runs it will see that the mtime on /etc/cron.d has changed and will re-read the files but get them in the order: sysstat cron1 cron2 cron3 It will compare the mtimes against the current database: cron1 -> sysstat cron2 -> cron1 cron3 -> cron2 sysstat -> cron3 What can happen is that a file will get overwritten with a different file and you end up with two entries once and one missing. I did a quick fix in database.c (from vixie-cron-4.1 patched for SLES10) that deletes the old database completely and re-loads everything if we notice that /etc/cron.d has changed: 127,130c127,129 < /* something's different. make a new database, moving unchanged < * elements from the old database, reloading elements that have < * actually changed. Whatever is left in the old database when < * we're done is chaff -- crontabs that disappeared. ---
/* something's different. make a new database, remove the old * database because we can't trust the order in which the files * get loaded.
131a131,138
Debug(DLOAD, ("unlinking old database:\n")) for (u = old_db->head; u != NULL; u = nu) { Debug(DLOAD, ("\t%s\n", u->name)) nu = u->next; unlink_user(old_db, u); free_user(u); }
226,235d232 < /* whatever's left in the old database is now junk. < */ < Debug(DLOAD, ("unlinking old database:\n")) < for (u = old_db->head; u != NULL; u = nu) { < Debug(DLOAD, ("\t%s\n", u->name)) < nu = u->next; < unlink_user(old_db, u); < free_user(u); < } < Rob -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=344667
Mark Gordon
https://bugzilla.novell.com/show_bug.cgi?id=344667
User mkoenig@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=344667#c1
Matthias Koenig
https://bugzilla.novell.com/show_bug.cgi?id=344667
User mkoenig@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=344667#c2
--- Comment #2 from Matthias Koenig
https://bugzilla.novell.com/show_bug.cgi?id=344667
User mkoenig@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=344667#c3
Matthias Koenig
participants (1)
-
bugzilla_noreply@novell.com