Well, redirect them to /dev/null anyway.
Also tidy a few things in common whilst here.
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
-#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include "if-options.h"
#include "logerr.h"
-/* Most route(4) messages are less than 256 bytes. */
-#define IOVEC_BUFSIZ 256
-
-int
-close_std(void)
-{
- int fd, error = 0;
-
- if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
- return -1;
-
- if (dup2(fd, STDIN_FILENO) == -1)
- error = -1;
- if (dup2(fd, STDOUT_FILENO) == -1)
- error = -1;
- if (dup2(fd, STDERR_FILENO) == -1)
- error = -1;
- close(fd);
- return error;
-}
-
const char *
hwaddr_ntoa(const void *hwaddr, size_t hwlen, char *buf, size_t buflen)
{
# endif
#endif
-int close_std(void);
-void get_line_free(void);
-extern int clock_monotonic;
-int get_monotonic(struct timespec *);
-
const char *hwaddr_ntoa(const void *, size_t, char *, size_t);
size_t hwaddr_aton(uint8_t *, const char *);
size_t read_hwaddr_aton(uint8_t **, const char *);
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
+#include <paths.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
eloop_event_delete(ctx->eloop, ctx->fork_fd);
close(ctx->fork_fd);
ctx->fork_fd = -1;
- close_std();
+ freopen(_PATH_DEVNULL, "w", stdout);
+ freopen(_PATH_DEVNULL, "w", stderr);
#endif
}
/* If the mtime has changed drop any old lease */
if (old != 0 && ifp->options->mtime != old) {
- logwarnx("%s: confile file changed, expiring leases",
+ logwarnx("%s: config file changed, expiring leases",
ifp->name);
dhcpcd_drop(ifp, 0);
}
#endif
logdebugx(PACKAGE "-" VERSION " starting");
+ freopen(_PATH_DEVNULL, "r", stdin);
#ifdef PRIVSEP
if (ps_init(&ctx) == -1 && errno != 0) {
#include <pwd.h>
#include <errno.h>
#include <fcntl.h>
-#include <grp.h>
+#include <paths.h>
#include <stddef.h> /* For offsetof, struct padding debug */
#include <signal.h>
#include <stdlib.h>
if (callback(recv_ctx) == -1)
goto errexit;
-#if 0
- /* XXX Why does this cause processes to exit? */
- close_std();
-#endif
+ freopen(_PATH_DEVNULL, "w", stdout);
+ freopen(_PATH_DEVNULL, "w", stderr);
if (pw == NULL)
return 0;
dropprivs:
if (setgroups(1, &pw->pw_gid) == -1 ||
- setgid(pw->pw_gid) == -1 ||
- setuid(pw->pw_uid) == -1)
+ setgid(pw->pw_gid) == -1 ||
+ setuid(pw->pw_uid) == -1)
logerr("failed to drop privileges");
return 0;