head 1.7; access; symbols OPENPKG_E1_MP_HEAD:1.5 OPENPKG_E1_MP:1.5 OPENPKG_E1_MP_2_STABLE:1.4.2.1 OPENPKG_E1_FP:1.4.2.1 OPENPKG_2_STABLE_MP:1.5 OPENPKG_2_STABLE_20061018:1.4 OPENPKG_2_STABLE_20060622:1.4 OPENPKG_2_STABLE:1.4.0.2 OPENPKG_2_STABLE_BP:1.4 OPENPKG_2_5_RELEASE:1.2 OPENPKG_2_5_SOLID:1.2.0.8 OPENPKG_2_5_SOLID_BP:1.2 OPENPKG_2_4_RELEASE:1.2 OPENPKG_2_4_SOLID:1.2.0.6 OPENPKG_2_4_SOLID_BP:1.2 OPENPKG_CW_FP:1.2 OPENPKG_2_3_RELEASE:1.2 OPENPKG_2_3_SOLID:1.2.0.4 OPENPKG_2_3_SOLID_BP:1.2 OPENPKG_2_2_RELEASE:1.2 OPENPKG_2_2_SOLID:1.2.0.2 OPENPKG_2_2_SOLID_BP:1.2 OPENPKG_1_STABLE_MP:1.2; locks; strict; comment @# @; 1.7 date 2008.04.14.12.38.46; author rse; state Exp; branches; next 1.6; commitid WrJZgHOBjehAJ4Zs; 1.6 date 2008.04.14.12.00.21; author rse; state Exp; branches; next 1.5; commitid OlNJRRPTiC2pw4Zs; 1.5 date 2006.10.24.07.16.34; author rse; state Exp; branches; next 1.4; commitid QLb4myEDwg8efURr; 1.4 date 2006.04.30.17.32.20; author rse; state Exp; branches 1.4.2.1; next 1.3; commitid zJLtXhnXiMqdldvr; 1.3 date 2006.04.23.07.52.09; author rse; state Exp; branches; next 1.2; commitid JCcNOL6h8Kj8mgur; 1.2 date 2003.02.02.09.36.10; author rse; state Exp; branches; next 1.1; 1.1 date 2002.05.29.19.56.11; author rse; state Exp; branches; next ; 1.4.2.1 date 2006.10.24.07.17.19; author rse; state Exp; branches; next ; commitid NY7w4NTSyYzufURr; desc @@ 1.7 log @fix segfault by making a copy of the argument list in the asprintf() fallback function @ text @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 #include #include -#include +#include #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; +} + @ 1.6 log @fix editor usage (like Gentoo) and use my_ names for own functions @ text @d3 1 a3 1 +++ crontab.1 2008-04-14 13:57:33 +0200 d15 1 a15 1 +++ crontab.c 2008-04-14 13:57:23 +0200 d26 2 a27 2 --- database.c.orig 2006-05-16 18:20:01.000000000 +0200 +++ database.c 2006-10-24 09:04:26.497144006 +0200 d38 2 a39 2 --- defs.h.orig 2006-05-16 18:24:45.000000000 +0200 +++ defs.h 2006-10-24 09:05:15.063043609 +0200 d67 2 a68 2 --- main.c.orig 2006-04-29 18:47:26.000000000 +0200 +++ main.c 2006-10-24 09:00:36.395498701 +0200 d86 2 a87 2 --- subs.c.orig 2006-04-27 19:29:56.000000000 +0200 +++ subs.c 2006-10-24 09:13:53.222197790 +0200 d125 1 a125 1 @@@@ -143,3 +151,31 @@@@ d143 1 d147 6 a152 1 + l = vsnprintf(NULL, 0, fmt, ap); @ 1.5 log @make more portable and this way finally get it building under Sun Solaris, too @ text @d1 24 d130 1 a130 1 +void errx(int eval, const char *fmt, ...) d140 1 a140 1 +int asprintf(char **ret, const char *fmt, ...) @ 1.4 log @upgrading package: dcron 3.0 -> 3.1 @ text @d1 12 d14 4 a17 3 --- defs.h.orig 2006-04-29 19:20:58 +0200 +++ defs.h 2006-04-30 19:28:14 +0200 @@@@ -23,6 +23,7 @@@@ d20 1 a20 1 #include d25 1 a25 1 @@@@ -60,6 +61,9 @@@@ d33 5 a37 1 #define VERSION "V3.1" d39 3 d43 2 a44 2 --- main.c.orig 2006-04-29 18:47:26 +0200 +++ main.c 2006-04-30 19:27:08 +0200 d62 12 a73 3 --- subs.c.orig 2006-04-27 19:29:56 +0200 +++ subs.c 2006-04-30 19:27:08 +0200 @@@@ -79,7 +79,7 @@@@ d82 1 a82 1 @@@@ -97,9 +97,15 @@@@ d101 32 @ 1.4.2.1 log @MFC: make more portable and this way finally get it building under Sun Solaris, too @ text @a0 12 Index: database.c --- database.c.orig 2006-05-16 18:20:01.000000000 +0200 +++ database.c 2006-10-24 09:04:26.497144006 +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); d2 3 a4 4 --- defs.h.orig 2006-05-16 18:24:45.000000000 +0200 +++ defs.h 2006-10-24 09:05:15.063043609 +0200 @@@@ -22,7 +22,7 @@@@ #include d7 1 a7 1 -#include d12 1 a12 1 @@@@ -60,6 +60,9 @@@@ d20 1 a20 5 #define VERSION "V3.2" @@@@ -93,3 +96,6 @@@@ #include "protos.h" a21 3 +#define errx my_errx +#define asprintf my_asprintf + d23 2 a24 2 --- main.c.orig 2006-04-29 18:47:26.000000000 +0200 +++ main.c 2006-10-24 09:00:36.395498701 +0200 d42 3 a44 12 --- subs.c.orig 2006-04-27 19:29:56.000000000 +0200 +++ subs.c 2006-10-24 09:13:53.222197790 +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 @@@@ d53 1 a53 1 @@@@ -97,9 +99,15 @@@@ a71 32 @@@@ -143,3 +151,31 @@@@ } #endif + +void errx(int eval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(eval); +} + +int asprintf(char **ret, const char *fmt, ...) +{ + va_list ap; + int l; + + va_start(ap, fmt); + l = vsnprintf(NULL, 0, fmt, ap); + 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; +} + @ 1.3 log @upgrading package: dcron 2.9 -> 3.0 @ text @d2 2 a3 2 --- defs.h.orig 2006-04-22 17:59:38 +0200 +++ defs.h 2006-04-23 09:46:45 +0200 d12 1 a12 1 @@@@ -51,7 +52,9 @@@@ a15 1 - d20 1 a20 1 #define VERSION "V3.00" d23 3 a25 3 --- main.c.orig 2006-04-22 17:52:57 +0200 +++ main.c 2006-04-23 09:46:02 +0200 @@@@ -122,8 +122,14 @@@@ d42 2 a43 2 --- subs.c.orig 2006-04-22 17:45:49 +0200 +++ subs.c 2006-04-23 09:46:02 +0200 @ 1.2 log @upgrade to version 2.9 @ text @d1 7 a7 6 --- defs.h Fri Sep 5 21:44:32 1997 +++ defs.h Wed Jun 13 09:51:08 2001 @@@@ -21,12 +21,16 @@@@ #include #include #include d12 5 a16 4 #ifndef CRONTABS #define CRONTABS "/var/spool/cron/crontabs" +#endif d19 7 a25 5 #endif #ifndef TMPDIR #define TMPDIR "/tmp" --- main.c Mon May 2 17:28:24 1994 +++ main.c Wed Jun 13 09:53:09 2001 d42 3 a44 2 --- subs.c Wed Feb 10 07:31:46 1999 +++ subs.c Sun Feb 2 10:33:56 2003 d55 1 a55 1 log(9, "failed to get uid for %s", user); @ 1.1 log @Finally rename all foo-X.Y.patch files to foo.patch in order to allow us to preserve history in CVS for patch files. @ text @d1 2 a2 15 diff -ru3 dcron-2.3.3.orig/database.c dcron-2.3.3/database.c --- dcron-2.3.3.orig/database.c Mon May 2 17:28:08 1994 +++ dcron-2.3.3/database.c Wed Jun 13 09:49:57 2001 @@@@ -179,7 +179,7 @@@@ if (--maxEntries == 0) break; - bzero(&line, sizeof(line)); + memset(&line, 0, sizeof(line)); if (DebugOpt) log9("User %s Entry %s\n", fileName, buf); diff -ru3 dcron-2.3.3.orig/defs.h dcron-2.3.3/defs.h --- dcron-2.3.3.orig/defs.h Fri Sep 5 21:44:32 1997 +++ dcron-2.3.3/defs.h Wed Jun 13 09:51:08 2001 d20 2 a21 3 diff -ru3 dcron-2.3.3.orig/main.c dcron-2.3.3/main.c --- dcron-2.3.3.orig/main.c Mon May 2 17:28:24 1994 +++ dcron-2.3.3/main.c Wed Jun 13 09:53:09 2001 d38 3 a40 12 diff -ru3 dcron-2.3.3.orig/subs.c dcron-2.3.3/subs.c --- dcron-2.3.3.orig/subs.c Mon Feb 16 20:35:10 1998 +++ dcron-2.3.3/subs.c Wed Jun 13 09:49:57 2001 @@@@ -15,7 +15,6 @@@@ 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, size_t sz, const char *ctl, va_list va, short useDate); -Prototype char *strdup(const char *); void log9(const char *ctl, ...) @@@@ -80,7 +79,7 @@@@ d46 1 a46 1 vsnprintf(buf + strlen(buf), sz - strlen(buf), ctl, va); d49 1 a49 1 @@@@ -98,9 +97,15 @@@@ a67 16 @@@@ -129,15 +134,5 @@@@ } } return(pas->pw_uid); -} - -char * -strdup(const char *str) -{ - char *ptr = malloc(strlen(str) + 1); - - if (ptr) - strcpy(ptr, str); - return(ptr); } @