diff options
| author | David Nugent <davidn@FreeBSD.org> | 1997-04-12 01:04:50 +0000 |
|---|---|---|
| committer | David Nugent <davidn@FreeBSD.org> | 1997-04-12 01:04:50 +0000 |
| commit | c4c1e9823380f10fb26635a6707ad441a71288bc (patch) | |
| tree | 3d8abbd334e6e55ff28129b63df997cf66ad295c /libexec | |
| parent | af9ec88589cbf5d4438e4b2c26040cff38dac0a4 (diff) | |
Notes
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/atrun/atrun.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index 64dec18890fa6..b96969d1645ad 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -29,6 +29,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#include <sys/param.h> #include <ctype.h> #include <dirent.h> #include <errno.h> @@ -42,12 +43,19 @@ #include <time.h> #include <unistd.h> #include <syslog.h> +#include <utmp.h> #ifdef __FreeBSD__ #include <paths.h> #else #include <getopt.h> #endif +#if (MAXLOGNAME-1) > UT_NAMESIZE +#define LOGNAMESIZE UT_NAMESIZE +#else +#define LOGNAMESIZE (MAXLOGNAME-1) +#endif + /* Local headers */ #include "gloadavg.h" @@ -71,7 +79,7 @@ /* File scope variables */ static char *namep; -static char rcsid[] = "$Id: atrun.c,v 1.8 1997/02/22 14:20:54 peter Exp $"; +static char rcsid[] = "$Id: atrun.c,v 1.9 1997/03/28 15:48:03 imp Exp $"; static debug = 0; void perr(const char *a); @@ -108,7 +116,7 @@ run_file(const char *filename, uid_t uid, gid_t gid) pid_t pid; int fd_out, fd_in; int queue; - char mailbuf[9]; + char mailbuf[LOGNAMESIZE + 1], fmt[49]; char *mailname = NULL; FILE *stream; int send_mail = 0; @@ -197,11 +205,10 @@ run_file(const char *filename, uid_t uid, gid_t gid) fcntl(fd_in, F_SETFD, fflags & ~FD_CLOEXEC); - if (fscanf(stream, "#!/bin/sh\n# atrun uid=%ld gid=%ld\n# mail %8s %d", - &nuid, &ngid, mailbuf, &send_mail) != 4) - { - syslog(LOG_ERR,"File %s is in wrong format - aborting", - filename); + snprintf(fmt, 49, "#!/bin/sh\n# atrun uid=%%ld gid=%%ld\n# mail %%%ds %%d", + LOGNAMESIZE); + if (fscanf(stream, fmt, &nuid, &ngid, mailbuf, &send_mail) != 4) { + syslog(LOG_ERR,"File %s is in wrong format - aborting", filename); exit(EXIT_FAILURE); } if (mailbuf[0] == '-') { |
