On Wed, 11 Nov 2015 14:43:47 -0700, "Todd C. Miller" wrote: > There's limited backward compatibility so you can run a new crontab > with an older cron daemon.
Revised diff, I neglected to send out the cron.c changes in the first one. - todd Index: usr.sbin/cron/client.c =================================================================== RCS file: /cvs/src/usr.sbin/cron/client.c,v retrieving revision 1.6 diff -u -p -u -r1.6 client.c --- usr.sbin/cron/client.c 11 Nov 2015 17:05:23 -0000 1.6 +++ usr.sbin/cron/client.c 11 Nov 2015 21:56:18 -0000 @@ -19,9 +19,12 @@ #include <sys/types.h> #include <sys/socket.h> +#include <sys/stat.h> #include <sys/un.h> #include <bitstring.h> /* for structs.h */ +#include <err.h> +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -92,13 +95,17 @@ void poke_daemon(const char *spool_dir, unsigned char cookie) { int sock = -1; + const char *cronsock = CRONSOCK; + struct stat sb; struct sockaddr_un s_un; + if (stat(cronsock, &sb) != 0) + cronsock = CRONSOCK_OLD; /* backwards compatibility */ + bzero(&s_un, sizeof(s_un)); - if (snprintf(s_un.sun_path, sizeof s_un.sun_path, "%s/%s", - CRON_SPOOL, CRONSOCK) >= sizeof(s_un.sun_path)) { - fprintf(stderr, "%s: %s/%s: path too long\n", - __progname, CRON_SPOOL, CRONSOCK); + if (strlcpy(s_un.sun_path, cronsock, sizeof(s_un.sun_path)) >= + sizeof(s_un.sun_path)) { + warnc(ENAMETOOLONG, "%s", cronsock); return; } s_un.sun_family = AF_UNIX; @@ -106,8 +113,7 @@ poke_daemon(const char *spool_dir, unsig connect(sock, (struct sockaddr *)&s_un, sizeof(s_un)) == 0) send(sock, &cookie, 1, MSG_NOSIGNAL); else - fprintf(stderr, "%s: warning, cron does not appear to be " - "running.\n", __progname); + warnx("warning, cron does not appear to be running"); if (sock >= 0) close(sock); } Index: usr.sbin/cron/cron.c =================================================================== RCS file: /cvs/src/usr.sbin/cron/cron.c,v retrieving revision 1.68 diff -u -p -u -r1.68 cron.c --- usr.sbin/cron/cron.c 11 Nov 2015 17:19:22 -0000 1.68 +++ usr.sbin/cron/cron.c 11 Nov 2015 21:56:18 -0000 @@ -431,9 +431,9 @@ open_socket(void) exit(EXIT_FAILURE); } bzero(&s_un, sizeof(s_un)); - if (snprintf(s_un.sun_path, sizeof(s_un.sun_path), "%s/%s", - CRON_SPOOL, CRONSOCK) >= sizeof(s_un.sun_path)) { - fprintf(stderr, "%s/%s: path too long\n", CRON_SPOOL, CRONSOCK); + if (strlcpy(s_un.sun_path, CRONSOCK, sizeof(s_un.sun_path)) + >= sizeof(s_un.sun_path)) { + fprintf(stderr, "%s: path too long\n", CRONSOCK); log_it("CRON", "DEATH", "path too long"); exit(EXIT_FAILURE); } Index: usr.sbin/cron/pathnames.h =================================================================== RCS file: /cvs/src/usr.sbin/cron/pathnames.h,v retrieving revision 1.20 diff -u -p -u -r1.20 pathnames.h --- usr.sbin/cron/pathnames.h 9 Nov 2015 16:00:39 -0000 1.20 +++ usr.sbin/cron/pathnames.h 11 Nov 2015 21:56:18 -0000 @@ -50,9 +50,9 @@ /* CRONSOCK is the name of the socket used by at and * crontab to poke cron to re-read the at and cron * spool files while cron is asleep. - * It lives in the spool directory. */ -#define CRONSOCK ".sock" +#define CRONSOCK "/var/run/cron.sock" +#define CRONSOCK_OLD CRON_SPOOL "/.sock" /* cron allow/deny file. At least cron.deny must * exist for ordinary users to run crontab.