From 3f08c42b06c823fbd58df56b737a6040f3c341d8 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Fri, 7 Feb 2014 13:45:06 +0000 Subject: [PATCH] Make sure to report an error if chdir(/) fail. --- src/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/init.c b/src/init.c index 2569a54..a12b495 100644 --- a/src/init.c +++ b/src/init.c @@ -663,7 +663,9 @@ void coredump(void) rlim.rlim_cur = RLIM_INFINITY; rlim.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_CORE, &rlim); - chdir("/"); + if (0 != chdir("/")) + initlog(L_VB, "unable to chdir to /: %s", + strerror(errno)); signal(SIGSEGV, SIG_DFL); raise(SIGSEGV); @@ -2794,7 +2796,9 @@ int telinit(char *progname, int argc, char **argv) } /* Change to the root directory. */ - chdir("/"); + if (0 != chdir("/")) + initlog(L_VB, "unable to chdir to /: %s", + strerror(errno)); /* Open the fifo and write a command. */ /* Make sure we don't hang on opening /dev/initctl */