diff options
author | Kevin Steves <stevesk@cvs.openbsd.org> | 2007-12-22 18:26:22 +0000 |
---|---|---|
committer | Kevin Steves <stevesk@cvs.openbsd.org> | 2007-12-22 18:26:22 +0000 |
commit | c1623180e498b8ade605b387cedcb2117ced9523 (patch) | |
tree | 9f9b37dd1d21975591794fe4cfeedeb611a0442b /usr.sbin | |
parent | 02ece4b9764594ea97d902bc5cee6ca2fe55cd6a (diff) |
just call getpwnam(NTPD_USER) once; ok henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/ntp.c | 8 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.c | 7 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.h | 5 |
3 files changed, 9 insertions, 11 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 3673bb8d0fe..46b92d5f2fd 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -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(); diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index c9ee4b0bce8..4c7df9eae62 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -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(); diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index 73c017526b6..d408b0f5eb7 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -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); |