changeset 13847:d79e5216dd27

3206 Long(er) username crontab setup failure Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Approved by: Garrett D'Amore <garrett@damore.org>
author Richard Lowe <richlowe@richlowe.net>
date Thu, 27 Sep 2012 16:04:13 -0400
parents e00baf913d93
children 440c93ffaf29
files usr/src/cmd/cron/cron.c usr/src/cmd/cron/cron.h usr/src/cmd/cron/funcs.c
diffstat 3 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cron/cron.c	Tue Oct 02 05:18:23 2012 +0100
+++ b/usr/src/cmd/cron/cron.c	Thu Sep 27 16:04:13 2012 -0400
@@ -3025,7 +3025,7 @@
 	if (cc == BCHAR)
 		(void) printf("%c  CMD: %s\n", cc, next_event->cmd);
 	(void) strftime(timebuf, sizeof (timebuf), FORMAT, localtime(&t));
-	(void) printf("%c  %.8s %u %c %s",
+	(void) printf("%c  %s %u %c %s",
 	    cc, (rp->rusr)->name, rp->pid, QUE(rp->que), timebuf);
 	if ((ret = TSTAT(rc)) != 0)
 		(void) printf(" ts=%d", ret);
--- a/usr/src/cmd/cron/cron.h	Tue Oct 02 05:18:23 2012 +0100
+++ b/usr/src/cmd/cron/cron.h	Thu Sep 27 16:04:13 2012 -0400
@@ -26,6 +26,8 @@
 #ifndef	_CRON_H
 #define	_CRON_H
 
+#include <unistd.h>
+
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
@@ -53,8 +55,11 @@
 #define	RCODE(x)	(((x)>>8)&0377)
 #define	TSTAT(x)	((x)&0377)
 
-#define	FLEN	15
-#define	LLEN	9
+/* This constant must be at least sysconf(_SC_LOGIN_NAME_MAX) in size */
+#define	UNAMESIZE	32	/* max chars in a user name */
+
+#define	FLEN	UNAMESIZE
+#define	LLEN	UNAMESIZE
 
 /*
  * structure used for passing messages from the at and crontab commands to cron
@@ -66,8 +71,6 @@
 	char	logname[LLEN];
 };
 
-/* anything below here can be changed */
-
 #define	CRONDIR		"/var/spool/cron/crontabs"
 #define	ATDIR		"/var/spool/cron/atjobs"
 #define	ACCTFILE	"/var/cron/log"
@@ -87,7 +90,6 @@
 #define	ENV_HOME	"HOME="
 
 #define	CTLINESIZE	1000	/* max chars in a crontab line */
-#define	UNAMESIZE	20	/* max chars in a user name */
 
 extern int	allowed(char *, char *, char *);
 extern int	days_in_mon(int, int);
--- a/usr/src/cmd/cron/funcs.c	Tue Oct 02 05:18:23 2012 +0100
+++ b/usr/src/cmd/cron/funcs.c	Thu Sep 27 16:04:13 2012 -0400
@@ -172,8 +172,8 @@
 	}
 	pmsg->etype = etype;
 	pmsg->action = action;
-	(void) strncpy(pmsg->fname, fname, FLEN);
-	(void) strncpy(pmsg->logname, login, LLEN);
+	(void) strlcpy(pmsg->fname, fname, FLEN);
+	(void) strlcpy(pmsg->logname, login, LLEN);
 	if ((i = write(msgfd, pmsg, sizeof (struct message))) < 0)
 		(void) fprintf(stderr, gettext("error in message send\n"));
 	else if (i != sizeof (struct message))