Browse Source

just call getpwnam(NTPD_USER) once; ok henning@

OPENBSD_4_3
stevesk 17 years ago
parent
commit
55917fac67
3 changed files with 9 additions and 11 deletions
  1. +2
    -6
      src/usr.sbin/ntpd/ntp.c
  2. +4
    -3
      src/usr.sbin/ntpd/ntpd.c
  3. +3
    -2
      src/usr.sbin/ntpd/ntpd.h

+ 2
- 6
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.100 2007/10/15 06:59:31 otto Exp $ */
/* $OpenBSD: ntp.c,v 1.101 2007/12/22 18:26:21 stevesk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -66,7 +66,7 @@ ntp_sighdlr(int sig)
}
pid_t
ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf, struct passwd *pw)
{
int a, b, nfds, i, j, idx_peers, timeout;
int hotplugfd, nullfd;
@ -74,7 +74,6 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
u_int listener_cnt, new_cnt, sent_cnt, trial_cnt;
pid_t pid;
struct pollfd *pfd = NULL;
struct passwd *pw;
struct servent *se;
struct listen_addr *la;
struct ntp_peer *p;
@ -104,9 +103,6 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
if ((se = getservbyname("ntp", "udp")) == NULL)
fatal("getservbyname");
if ((pw = getpwnam(NTPD_USER)) == NULL)
fatal("getpwnam");
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
fatal(NULL);
hotplugfd = sensor_hotplugfd();


+ 4
- 3
src/usr.sbin/ntpd/ntpd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.55 2007/12/04 14:52:54 fgsch Exp $ */
/* $OpenBSD: ntpd.c,v 1.56 2007/12/22 18:26:21 stevesk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -88,6 +88,7 @@ main(int argc, char *argv[])
const char *conffile;
int ch, nfds, timeout = INFTIM;
int pipe_chld[2];
struct passwd *pw;
conffile = CONFFILE;
@ -135,7 +136,7 @@ main(int argc, char *argv[])
exit(1);
}
if (getpwnam(NTPD_USER) == NULL) {
if ((pw = getpwnam(NTPD_USER)) == NULL) {
fprintf(stderr, "ntpd: unknown user %s\n", NTPD_USER);
exit(1);
}
@ -155,7 +156,7 @@ main(int argc, char *argv[])
signal(SIGCHLD, sighdlr);
/* fork child process */
chld_pid = ntp_main(pipe_chld, &lconf);
chld_pid = ntp_main(pipe_chld, &lconf, pw);
setproctitle("[priv]");
readfreq();


+ 3
- 2
src/usr.sbin/ntpd/ntpd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.88 2007/10/15 06:59:32 otto Exp $ */
/* $OpenBSD: ntpd.h,v 1.89 2007/12/22 18:26:21 stevesk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -26,6 +26,7 @@
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <pwd.h>
#include <stdarg.h>
#include "ntp.h"
@ -262,7 +263,7 @@ int imsg_close(struct imsgbuf *, struct buf *);
void imsg_free(struct imsg *);
/* ntp.c */
pid_t ntp_main(int[2], struct ntpd_conf *);
pid_t ntp_main(int[2], struct ntpd_conf *, struct passwd *);
int priv_adjtime(void);
void priv_settime(double);
void priv_host_dns(char *, u_int32_t);


Loading…
Cancel
Save