From 92325dffa62df45e62407cd360262228112ea0d1 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Mon, 15 Mar 2004 11:48:05 +0000 Subject: properly check chdir success after chroot() and tweak err msgs a little, claudio ok --- usr.sbin/bgpd/rde.c | 7 ++++--- usr.sbin/bgpd/session.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'usr.sbin/bgpd') diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 75cf1572da2..c4683327e6c 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.99 2004/03/12 20:48:09 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.100 2004/03/15 11:48:04 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -119,8 +119,9 @@ rde_main(struct bgpd_config *config, struct peer *peer_l, fatal("getpwnam"); if (chroot(pw->pw_dir) == -1) - fatal("chroot failed"); - chdir("/"); + fatal("chroot"); + if (chdir("/") == -1) + fatal("chdir(\"/\")"); setproctitle("route decision engine"); bgpd_process = PROC_RDE; diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index ba46779859d..6f6d65546ae 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.135 2004/03/12 19:33:30 henning Exp $ */ +/* $OpenBSD: session.c,v 1.136 2004/03/15 11:48:04 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -170,8 +170,9 @@ session_main(struct bgpd_config *config, struct peer *cpeers, fatal(NULL); if (chroot(pw->pw_dir) == -1) - fatal("chroot failed"); - chdir("/"); + fatal("chroot"); + if (chdir("/") == -1) + fatal("chdir(\"/\")"); setproctitle("session engine"); bgpd_process = PROC_SE; -- cgit v1.2.3