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

View File

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