Make sure to report an error if chdir(/) fail.
authorPetter Reinholdtsen <pere@hungry.com>
Fri, 7 Feb 2014 13:45:06 +0000 (13:45 +0000)
committerPetter Reinholdtsen <pere@hungry.com>
Fri, 7 Feb 2014 13:45:06 +0000 (13:45 +0000)
git-svn-id: svn://svn.sv.gnu.org/sysvinit/sysvinit/trunk@149 456724a4-4300-0410-8514-c89748c515a2

src/init.c

index 2569a54018565b514b169ebbde3228cc70fa0b53..a12b495906cbc36735f807ceb891bb462b390cef 100644 (file)
@@ -663,7 +663,9 @@ void coredump(void)
        rlim.rlim_cur = RLIM_INFINITY;
        rlim.rlim_max = RLIM_INFINITY;
        setrlimit(RLIMIT_CORE, &rlim);
        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);
 
        signal(SIGSEGV, SIG_DFL);
        raise(SIGSEGV);
@@ -2794,7 +2796,9 @@ int telinit(char *progname, int argc, char **argv)
        }
 
        /* Change to the root directory. */
        }
 
        /* 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 */
 
        /* Open the fifo and write a command. */
        /* Make sure we don't hang on opening /dev/initctl */