all sarcasm on my part.
hate the whole /etc/hourly /etc/daily /etc/whim-time cron crap

was happy to see Theo's reaction.  Was jerking the list's chain.


sven falempin wrote:
Look what linux are accepting now : stuff like systemd, how modern ! and so
nicely done !

Maybe having a .d looks .damned cool but does it really solve something ?

New is not better, modern surely isn't.

If there is a way for OpenBSD to move to a cron.d  it probably needs a nice
explanation :
 - problems to be solved
 - why is it the best way to solved it
 - what other solution has been discarded and why.
 - (and does the gain of the change worth the work of the change)

PS:
If you install a software that require recurrent task it should be done
with a user with specific priviledge , so set up a crontab for this user.


Geez don't you have a TLS server to patch !

On Tue, Apr 8, 2014 at 4:59 PM, Dag Richards <[email protected]>wrote:

No Theo I don't think understand, if you accept the patch then you will be
more like Ubuntu and other MODERN operating systems.

Why put everything in a single easily readable file, when you can split it
up in to multiple directories.

Which reminds me when are you going to ditch /etc for a nice registry data
base.




Theo de Raadt wrote:

In your dreams.


 here is a simple patch to replace /etc/crontab by /etc/cron.d/.
You need to manually mkdir /etc/cron.d.


--- pathnames_original.h        Mon Apr  7 22:31:53 2014
+++ pathnames.h Tue Apr  8 16:12:30 2014
@@ -92,8 +92,8 @@
  #define PIDFILE                "cron.pid"
  #define _PATH_CRON_PID PIDDIR PIDFILE

-                       /* 4.3BSD-style crontab */
-#define SYSCRONTAB     "/etc/crontab"
+                       /* system crontab dir */
+#define SYSCRON_DIR    "/etc/cron.d"

                         /* what editor to use if no EDITOR or VISUAL
                          * environment variable specified.
@@ -42,30 +42,31 @@

         Debug(DLOAD, ("[%ld] load_database()\n", (long)getpid()))

-       /* before we start loading any data, do a stat on SPOOL_DIR
-        * so that if anything changes as of this moment (i.e., before
we've
-        * cached any of the database), we'll see the changes next time.
+       /* before we start loading any data, do a stat on SPOOL_DIR and
+        * SYSCRON_DIR so that if anything changes as of this moment
+        * (i.e., before we've cached any of the database), we'll see
+        * the changes next time.
          */
         if (stat(SPOOL_DIR, &statbuf) < OK) {
                 log_it("CRON", getpid(), "STAT FAILED", SPOOL_DIR);
                 return;
         }

-       /* track system crontab file
-        */
-       if (stat(SYSCRONTAB, &syscron_stat) < OK)
-               syscron_stat.st_mtime = 0;
+       if (stat(SYSCRON_DIR, &syscron_stat) < OK) {
+               log_it("CRON", getpid(), "STAT FAILED", SYSCRON_DIR);
+               return;
+       }

-       /* if spooldir's mtime has not changed, we don't need to fiddle
with
-        * the database.
+       /* if spooldir's and syscrondir's mtime has not changed, we don't
+        * need to fiddle with the database.
          *
          * Note that old_db->mtime is initialized to 0 in main(), and
          * so is guaranteed to be different than the stat() mtime the
first
          * time this function is called.
          */
         if (old_db->mtime == HASH(statbuf.st_mtime,
syscron_stat.st_mtime)) {
-               Debug(DLOAD, ("[%ld] spool dir mtime unch, no load
needed.\n",
-                             (long)getpid()))
+               Debug(DLOAD, ("[%ld] spool dirs mtime unch, no load
needed.\n",
+                       (long)getpid()))
                 return;
         }

@@ -77,28 +78,45 @@
         new_db.mtime = HASH(statbuf.st_mtime, syscron_stat.st_mtime);
         new_db.head = new_db.tail = NULL;

-       if (syscron_stat.st_mtime) {
-               process_crontab(ROOT_USER, NULL, SYSCRONTAB,
&syscron_stat,
-                               &new_db, old_db);
-       }
-
         /* we used to keep this dir open all the time, for the sake of
          * efficiency.  however, we need to close it in every fork, and
          * we fork a lot more often than the mtime of the dir changes.
          */
-       if (!(dir = opendir(SPOOL_DIR))) {
-               log_it("CRON", getpid(), "OPENDIR FAILED", SPOOL_DIR);
+       if (!(dir = opendir(SYSCRON_DIR))) {
+               log_it("CRON", getpid(), "OPENDIR FAILED", SYSCRON_DIR);
                 return;
         }

-       while (NULL != (dp = readdir(dir))) {
-               char fname[MAXNAMLEN+1], tabname[MAXNAMLEN];
+       char fname[MAXNAMLEN+1], tabname[MAXNAMLEN];

+       while (NULL != (dp = readdir(dir))) {
                 /* avoid file names beginning with ".".  this is good
                  * because we would otherwise waste two guaranteed calls
                  * to getpwnam() for . and .., and also because user
names
                  * starting with a period are just too nasty to
consider.
                  */
+               if (dp->d_name[0] == '.')
+                       continue;
+
+               if (strlcpy(fname, dp->d_name, sizeof fname) >= sizeof
fname)
+                       continue;       /* XXX log? */
+
+               if (snprintf(tabname, sizeof tabname, "%s/%s",
SYSCRON_DIR,
+                       fname) >= sizeof(tabname))
+                       continue;       /* XXX log? */
+
+               process_crontab(ROOT_USER, NULL, tabname, &syscron_stat,
+                       &new_db, old_db);
+       }
+
+       closedir(dir);
+
+       if (!(dir = opendir(SPOOL_DIR))) {
+               log_it("CRON", getpid(), "OPENDIR FAILED", SPOOL_DIR);
+               return;
+       }
+
+       while (NULL != (dp = readdir(dir))) {
                 if (dp->d_name[0] == '.')
                         continue;


--- cron_original.8     Mon Apr  7 22:31:53 2014
+++ cron.8      Tue Apr  8 16:12:30 2014
@@ -71,9 +71,8 @@
  commands.
  Additionally,
  .Nm
-checks the modification time on the system crontab file
-.Pq Pa /etc/crontab ,
-the crontab spool
+checks the modification time on the crontab spool dirs
+.Pq Pa /etc/cron.d,
  .Pq Pa /var/cron/tabs ,
  and the at spool
  .Pq Pa /var/cron/atjobs
@@ -187,8 +186,8 @@
  .El
  .Sh FILES
  .Bl -tag -width "/var/cron/tabs/.sock" -compact
-.It Pa /etc/crontab
-system crontab file
+.It Pa /etc/cron.d
+system crontab directory
  .It Pa /var/cron/atjobs
  directory containing
  .Xr at 1
@@ -217,6 +216,9 @@
  For user crontab files created by
  .Xr crontab 1 ,
  the mode must be 0400 or 0600.
-If the system crontab file is used,
-.Pa /etc/crontab
-must not be writable by any user other than root.
+If the system crontab spool dir is used,
+.Pa /etc/cron.d
+files inside must not be writable by any user other than root.
+Files inside the system crontab directory
+.Pa /etc/cron.d
+will be ignored if they start by a dot (.).


--- crontab_original.5  Tue Apr  8 16:33:54 2014
+++ crontab.5   Tue Apr  8 16:22:27 2014
@@ -279,7 +279,7 @@
  .El
  .Sh FILES
  .Bl -tag -width "/var/cron/tabs/<user>XXX" -compact
-.It Pa /etc/crontab
+.It Pa /etc/cron.d
  System crontab.
  .It Pa /var/cron/tabs/ Ns Aq Ar user
  User crontab.

Reply via email to