main: Check chdir() return value

This fixes:

    main.c: In function ‘main’:
    main.c:1025:8: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
       chdir(s->config->chroot_dir);
            ^
This commit is contained in:
Kevin Cernekee
2015-02-08 17:26:37 -08:00
committed by Nikos Mavrogiannopoulos
parent fbe55c23ef
commit 1545130237

View File

@@ -1019,8 +1019,13 @@ int main(int argc, char** argv)
/* chdir to our chroot directory, to allow opening the sec-mod
* socket if necessary. */
if (s->config->chroot_dir)
chdir(s->config->chroot_dir);
if (s->config->chroot_dir) {
if (chdir(s->config->chroot_dir) != 0) {
e = errno;
mslog(s, NULL, LOG_ERR, "cannot chdir to %s: %s", s->config->chroot_dir, strerror(e));
exit(1);
}
}
ms_sleep(100); /* give some time for sec-mod to initialize */
/* Initialize certificates */