[PATCH -ocserv 2/5] main: Check chdir() return value
Kevin Cernekee
cernekee at gmail.com
Sun Feb 8 17:26:37 PST 2015
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);
^
---
src/main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
index 147e280..60758fa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1024,8 +1024,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 */
--
1.9.1
More information about the openconnect-devel
mailing list