summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/rde.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-19 11:19:03 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-19 11:19:03 +0000
commitb91a8ff757a7d0ac997addcb80bc0276a22c371c (patch)
tree5098fd45c2d44f2bce12d18d4835aa6f971915c4 /usr.sbin/bgpd/rde.c
parent40028c48cfa283bb5a4f0c8fc6c0cee861f44b3d (diff)
fix getpwnam use; noticed by claudio@
Diffstat (limited to 'usr.sbin/bgpd/rde.c')
-rw-r--r--usr.sbin/bgpd/rde.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 3f6c492d83c..fd9d9f3b8b5 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.6 2003/12/19 01:15:47 deraadt Exp $ */
+/* $OpenBSD: rde.c,v 1.7 2003/12/19 11:19:02 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -79,14 +79,6 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2])
size_t nfds;
int n;
- conf = config;
-
- if ((pw = calloc(1, sizeof(struct passwd))) == NULL)
- fatal(NULL, errno);
-
- if ((pw = getpwnam(BGPD_USER)) == NULL)
- fatal("getpwnam", errno);
-
switch (pid = fork()) {
case -1:
fatal("cannot fork", errno);
@@ -96,6 +88,11 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2])
return (pid);
}
+ conf = config;
+
+ if ((pw = getpwnam(BGPD_USER)) == NULL)
+ fatal("getpwnam", errno);
+
if (chroot(pw->pw_dir) < 0)
fatal("chroot failed", errno);
chdir("/");
@@ -107,6 +104,8 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2])
fatal("can't drop privileges", errno);
}
+ endpwent();
+
signal(SIGTERM, rde_sighdlr);
close(pipe_s2r[0]);