summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-09-16 23:35:46 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-09-16 23:35:46 +0000
commit7058eb32c88e11c8ebc67cf94adfdab8eaaf9f8d (patch)
treeced800f365a39150d83784a13d258c1a0e71f8cb /sbin/dhclient
parent8c693b550dbcd7a998a47b491c04bfc698468c97 (diff)
Revert use of rdaemon() until it doesn't break install/upgrade.
Problem cause deduced by kili@, reproduced by & ok rpe@.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 9642e4e2e95..c0079374a35 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.388 2016/09/15 16:19:04 jca Exp $ */
+/* $OpenBSD: dhclient.c,v 1.389 2016/09/16 23:35:45 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -167,7 +167,6 @@ char *lease_as_string(struct interface_info *, char *, struct client_lease *);
struct client_lease *packet_to_lease(struct interface_info *, struct in_addr,
struct option_data *);
void go_daemon(void);
-int rdaemon(int);
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
@@ -2058,8 +2057,17 @@ go_daemon(void)
/* Stop logging to stderr. */
log_perror = 0;
- if (rdaemon(nullfd) == -1)
- error("rdaemon");
+ if (daemon(1, 0) == -1)
+ error("daemon");
+
+ /* we are chrooted, daemon(3) fails to open /dev/null */
+ if (nullfd != -1) {
+ dup2(nullfd, STDIN_FILENO);
+ dup2(nullfd, STDOUT_FILENO);
+ dup2(nullfd, STDERR_FILENO);
+ close(nullfd);
+ nullfd = -1;
+ }
/* Catch stuff that might be trying to terminate the program. */
signal(SIGHUP, sighdlr);
@@ -2072,31 +2080,6 @@ go_daemon(void)
}
int
-rdaemon(int devnull)
-{
-
- switch (fork()) {
- case -1:
- return (-1);
- case 0:
- break;
- default:
- _exit(0);
- }
-
- if (setsid() == -1)
- return (-1);
-
- (void)dup2(devnull, STDIN_FILENO);
- (void)dup2(devnull, STDOUT_FILENO);
- (void)dup2(devnull, STDERR_FILENO);
- if (devnull > 2)
- (void)close(devnull);
-
- return (0);
-}
-
-int
res_hnok(const char *name)
{
const char *dn = name;