Port timed away from logwtmp(3). Let it use utmpx.

This commit is contained in:
ed 2010-01-13 18:15:46 +00:00
parent 7b9a82453b
commit f9e9ecaea9
2 changed files with 17 additions and 9 deletions

View File

@ -44,6 +44,7 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/times.h>
#include <setjmp.h>
#include <utmpx.h>
#include "pathnames.h"
extern int measure_delta;
@ -56,8 +57,6 @@ static int slvcount; /* slaves listening to our clock */
static void mchgdate(struct tsp *);
extern void logwtmp(char *, char *, char *);
/*
* The main function of `master' is to periodically compute the differences
* (deltas) between its clock and the clocks of the slaves, to compute the
@ -350,6 +349,7 @@ mchgdate(msg)
char tname[MAXHOSTNAMELEN];
char olddate[32];
struct timeval otime, ntime, tmptv;
struct utmpx utx;
(void)strcpy(tname, msg->tsp_name);
@ -371,9 +371,13 @@ mchgdate(msg)
dictate = 3;
synch(tvtomsround(ntime));
} else {
logwtmp("|", "date", "");
utx.ut_type = OLD_TIME;
gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
(void)settimeofday(&tmptv, 0);
logwtmp("{", "date", "");
utx.ut_type = NEW_TIME;
gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
spreadtime();
}

View File

@ -41,6 +41,7 @@ static const char rcsid[] =
#include "globals.h"
#include <setjmp.h>
#include <utmpx.h>
#include "pathnames.h"
extern jmp_buf jmpenv;
@ -57,8 +58,6 @@ static void schgdate(struct tsp *, char *);
static void setmaster(struct tsp *);
static void answerdelay(void);
extern void logwtmp(char *, char *, char *);
int
slave()
{
@ -80,6 +79,7 @@ slave()
char newdate[32];
struct netinfo *ntp;
struct hosttbl *htp;
struct utmpx utx;
old_slavenet = 0;
@ -280,9 +280,13 @@ slave()
*/
synch(tvtomsround(ntime));
} else {
logwtmp("|", "date", "");
(void)settimeofday(&tmptv, 0);
logwtmp("{", "date", "");
utx.ut_type = OLD_TIME;
gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
(void)settimeofday(&tmptv, 0);
utx.ut_type = NEW_TIME;
gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
syslog(LOG_NOTICE,
"date changed by %s from %s",
msg->tsp_name, olddate);