diff -aur dcron-4.4/database.c dcron-4.4.new/database.c --- dcron-4.4/database.c 2010-01-18 16:27:31.000000000 +0100 +++ dcron-4.4.new/database.c 2010-02-11 22:42:12.045860376 +0100 @@ -86,6 +86,17 @@ }; /* + * hash function to create JobNames when ID_TAG is missing + * Currently an sdbm, may be an other hash function is better. + */ +unsigned long hash(char *key) +{ + unsigned long h=0; + while(*key) h=*key++ + (h<<6) + (h<<16) - h; + return h; +} + +/* * Check the cron.update file in the specified directory. If user_override * is NULL then the files in the directory belong to the user whose name is * the file, otherwise they belong to the user_override user. @@ -277,7 +288,7 @@ fclose(fi); } else { int succeeded = 0; - printlogf(LOG_NOTICE, "no timestamp found (user %s job %s)\n", file->cf_UserName, line->cl_JobName); + printlogf(LOG_NOTICE, "no timestamp found (user %s file %s)\n", file->cf_UserName, line->cl_Timestamp); /* write a fake timestamp file so our initial NotUntil doesn't keep being reset every hour when crond does a SynchronizeDir */ if ((fi = fopen(line->cl_Timestamp, "w")) != NULL) { if (strftime(buf, sizeof(buf), CRONSTAMP_FMT, localtime(&line->cl_NotUntil))) @@ -370,6 +381,11 @@ break; memset(&line, 0, sizeof(line)); + + // Generating Hash ID, needed for @daily, hourly & CO when no ID_TAG was added + unsigned long h = hash(ptr); + line.hash = strdup("xxxxxxxx"); + sprintf(line.hash, "%ld", h%100000000); if (DebugOpt) printlogf(LOG_DEBUG, "User %s Entry %s\n", userName, buf); @@ -595,10 +611,6 @@ line.cl_Description = NULL; line.cl_JobName = NULL; } - if (ptr && line.cl_Delay > 0 && !line.cl_JobName) { - printlogf(LOG_WARNING, "failed parsing crontab for user %s: writing timestamp requires job %s to be named\n", userName, ptr); - ptr = NULL; - } if (!ptr) { /* couldn't parse so we abort; free any cl_Waiters */ if (line.cl_Waiters) { @@ -621,7 +633,12 @@ line.cl_Shell = strdup(ptr); if (line.cl_Delay > 0) { - if (!(line.cl_Timestamp = concat(TSDir, "/", userName, ".", line.cl_JobName, NULL))) { + if (!line.cl_JobName) { + line.cl_Timestamp = concat(TSDir, "/", userName, ".", line.hash, NULL); + } else { + line.cl_Timestamp = concat(TSDir, "/", userName, ".", line.cl_JobName, NULL); + } + if (!line.cl_Timestamp) { errno = ENOMEM; perror("SynchronizeFile"); exit(1); @@ -884,6 +901,7 @@ } else { *pline = line->cl_Next; free(line->cl_Shell); + free(line->hash); if (line->cl_JobName) /* this frees both cl_Description and cl_JobName diff -aur dcron-4.4/defs.h dcron-4.4.new/defs.h --- dcron-4.4/defs.h 2010-01-16 03:17:04.000000000 +0100 +++ dcron-4.4.new/defs.h 2010-02-11 22:19:53.789328185 +0100 @@ -146,6 +146,7 @@ char cl_Days[32]; /* 1-31 */ char cl_Mons[12]; /* 0-11 */ char cl_Dow[7]; /* 0-6, beginning sunday */ + char *hash; } CronLine; typedef struct CronWaiter {