Pass in both username and file to jkfprintf

This commit is contained in:
Paul Traina 1996-06-04 15:42:09 +00:00
parent 4ecb9b64f0
commit 6cde43480c

View File

@ -73,7 +73,7 @@ struct utmp *utmp = NULL;
time_t lastmsgtime; time_t lastmsgtime;
int nutmp, uf; int nutmp, uf;
void jkfprintf __P((FILE *, char[], off_t)); void jkfprintf __P((FILE *, char[], char[], off_t));
void mailfor __P((char *)); void mailfor __P((char *));
void notify __P((struct utmp *, char[], off_t, int)); void notify __P((struct utmp *, char[], off_t, int));
void onalrm __P((int)); void onalrm __P((int));
@ -238,15 +238,16 @@ notify(utp, file, offset, folder)
cr, name, (int)sizeof(hostname), hostname, cr, name, (int)sizeof(hostname), hostname,
folder ? cr : "", folder ? "to " : "", folder ? file : "", folder ? cr : "", folder ? "to " : "", folder ? file : "",
cr, cr); cr, cr);
jkfprintf(tp, file, offset); jkfprintf(tp, name, file, offset);
(void)fclose(tp); (void)fclose(tp);
_exit(0); _exit(0);
} }
void void
jkfprintf(tp, name, offset) jkfprintf(tp, user, file, offset)
register FILE *tp; register FILE *tp;
char name[]; char user[];
char file[];
off_t offset; off_t offset;
{ {
register char *cp, ch; register char *cp, ch;
@ -256,10 +257,10 @@ jkfprintf(tp, name, offset)
char line[BUFSIZ]; char line[BUFSIZ];
/* Set effective uid to user in case mail drop is on nfs */ /* Set effective uid to user in case mail drop is on nfs */
if ((p = getpwnam(name)) != NULL) if ((p = getpwnam(user)) != NULL)
(void) setuid(p->pw_uid); (void) setuid(p->pw_uid);
if ((fi = fopen(name, "r")) == NULL) if ((fi = fopen(file, "r")) == NULL)
return; return;
(void)fseek(fi, offset, L_SET); (void)fseek(fi, offset, L_SET);