You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
4.1 KiB
162 lines
4.1 KiB
Index: crontab.1 |
|
--- crontab.1.orig 1999-02-10 07:22:37 +0100 |
|
+++ crontab.1 2008-04-14 14:33:15 +0200 |
|
@@ -26,7 +26,7 @@ |
|
manipulates the crontab for a particular user. Only the superuser may |
|
specify a different user and/or crontab directory. Generally the -e |
|
option is used to edit your crontab. crontab will use /usr/bin/vi or |
|
-the editor specified by your VISUAL environment variable to edit the |
|
+the editor specified by your EDITOR environment variable to edit the |
|
crontab. |
|
.PP |
|
Unlike other crond/crontabs, this crontab does not try to do everything |
|
Index: crontab.c |
|
--- crontab.c.orig 2006-04-27 19:29:56 +0200 |
|
+++ crontab.c 2008-04-14 14:33:15 +0200 |
|
@@ -302,7 +302,7 @@ |
|
|
|
if (ChangeUser(user, 1) < 0) |
|
exit(0); |
|
- if ((ptr = getenv("VISUAL")) == NULL || strlen(ptr) > 256) |
|
+ if ((ptr = getenv("EDITOR")) == NULL || strlen(ptr) > 256) |
|
ptr = PATH_VI; |
|
|
|
snprintf(visual, sizeof(visual), "%s %s", ptr, file); |
|
Index: database.c |
|
--- database.c.orig 2006-05-16 18:20:01 +0200 |
|
+++ database.c 2008-04-14 14:33:15 +0200 |
|
@@ -225,7 +225,7 @@ |
|
if (--maxEntries == 0) |
|
break; |
|
|
|
- bzero(&line, sizeof(line)); |
|
+ memset(&line, 0, sizeof(line)); |
|
|
|
if (DebugOpt) |
|
log9("User %s Entry %s\n", userName, buf); |
|
Index: defs.h |
|
--- defs.h.orig 2006-05-16 18:24:45 +0200 |
|
+++ defs.h 2008-04-14 14:33:15 +0200 |
|
@@ -22,7 +22,7 @@ |
|
#include <pwd.h> |
|
#include <unistd.h> |
|
#include <grp.h> |
|
-#include <err.h> |
|
+#include <sys/termios.h> |
|
|
|
#define Prototype extern |
|
#define arysize(ary) (sizeof(ary)/sizeof((ary)[0])) |
|
@@ -60,6 +60,9 @@ |
|
#ifndef PATH_VI |
|
#define PATH_VI "/usr/bin/vi" /* location of vi */ |
|
#endif |
|
+#ifndef PIDFILE |
|
+#define PIDFILE "/var/run/dcron.pid" |
|
+#endif |
|
|
|
#define VERSION "V3.2" |
|
|
|
@@ -93,3 +96,6 @@ |
|
|
|
#include "protos.h" |
|
|
|
+#define errx my_errx |
|
+#define asprintf my_asprintf |
|
+ |
|
Index: main.c |
|
--- main.c.orig 2006-04-29 18:47:26 +0200 |
|
+++ main.c 2008-04-14 14:33:15 +0200 |
|
@@ -120,8 +120,14 @@ |
|
perror("fork"); |
|
exit(1); |
|
} |
|
- if (pid > 0) |
|
+ if (pid > 0) { |
|
+ FILE *fp; |
|
+ if ((fp = fopen(PIDFILE, "w")) != NULL) { |
|
+ fprintf(fp, "%d\n", pid); |
|
+ fclose(fp); |
|
+ } |
|
exit(0); |
|
+ } |
|
} |
|
|
|
/* |
|
Index: subs.c |
|
--- subs.c.orig 2006-04-27 19:29:56 +0200 |
|
+++ subs.c 2008-04-14 14:35:49 +0200 |
|
@@ -15,6 +15,8 @@ |
|
Prototype int ChangeUser(const char *user, short dochdir); |
|
Prototype void vlog(int level, int fd, const char *ctl, va_list va); |
|
Prototype int slog(char *buf, const char *ctl, int nmax, va_list va, short useDate); |
|
+Prototype void my_errx(int eval, const char *fmt, ...); |
|
+Prototype int my_asprintf(char **ret, const char *fmt, ...); |
|
|
|
void |
|
log9(const char *ctl, ...) |
|
@@ -79,7 +81,7 @@ |
|
|
|
buf[0] = 0; |
|
if (useDate) |
|
- strftime(buf, 128, "%d-%b-%y %H:%M ", tp); |
|
+ strftime(buf, 128, "%d-%b-%Y %H:%M ", tp); |
|
vsnprintf(buf + strlen(buf), nmax, ctl, va); |
|
return(strlen(buf)); |
|
} |
|
@@ -97,9 +99,15 @@ |
|
logn(9, "failed to get uid for %s", user); |
|
return(-1); |
|
} |
|
- setenv("USER", pas->pw_name, 1); |
|
- setenv("HOME", pas->pw_dir, 1); |
|
- setenv("SHELL", "/bin/sh", 1); |
|
+ { |
|
+ char buf[256]; |
|
+ snprintf(buf, sizeof(buf), "USER=%s", pas->pw_name); |
|
+ putenv(buf); |
|
+ snprintf(buf, sizeof(buf), "HOME=%s", pas->pw_dir); |
|
+ putenv(buf); |
|
+ snprintf(buf, sizeof(buf), "SHELL=%s", "/bin/sh"); |
|
+ putenv(buf); |
|
+ } |
|
|
|
/* |
|
* Change running state to the user in question |
|
@@ -143,3 +151,37 @@ |
|
} |
|
|
|
#endif |
|
+ |
|
+void my_errx(int eval, const char *fmt, ...) |
|
+{ |
|
+ va_list ap; |
|
+ |
|
+ va_start(ap, fmt); |
|
+ vfprintf(stderr, fmt, ap); |
|
+ va_end(ap); |
|
+ exit(eval); |
|
+} |
|
+ |
|
+int my_asprintf(char **ret, const char *fmt, ...) |
|
+{ |
|
+ va_list ap; |
|
+ va_list ap2; |
|
+ int l; |
|
+ |
|
+ va_start(ap, fmt); |
|
+#if defined(__STDC__) && defined(__STDC__VERSION__) && (__STDC_VERSION__ >= 199901L) |
|
+ va_copy(ap2, ap); |
|
+#else |
|
+ __builtin_va_copy(ap2, ap); |
|
+#endif |
|
+ l = vsnprintf(NULL, 0, fmt, ap2); |
|
+ if (((*ret) = (char *)malloc(l+1)) == NULL) { |
|
+ va_end(ap); |
|
+ *ret = NULL; |
|
+ return -1; |
|
+ } |
|
+ l = vsnprintf((*ret), l+1, fmt, ap); |
|
+ va_end(ap); |
|
+ return l; |
|
+} |
|
+
|
|
|