[PATCH -ocserv 2/5] main: Check chdir() return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux