From 6e7660c801aac5d2b708d0239002dd5b7f20ed1e Mon Sep 17 00:00:00 2001 From: lns Date: Wed, 18 Jul 2018 19:53:58 +0200 Subject: ArchLinux: fixed compiler warnings (libc functions marked with warn_unused_result) Signed-off-by: lns --- src/jail.c | 3 ++- src/protocol_ssh.c | 18 ++++++++++++------ src/utils.c | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/jail.c b/src/jail.c index 5b3ed5c..627e650 100644 --- a/src/jail.c +++ b/src/jail.c @@ -444,7 +444,8 @@ static int jail_childfn(prisoner_process *ctx) caps_drop_all(); #endif - sethostname("openwrt", SIZEOF("openwrt")); + if (sethostname("openwrt", SIZEOF("openwrt"))) + exit(EXIT_FAILURE); if (execl(path_shell, path_shell, (char *) NULL)) exit(EXIT_FAILURE); break; diff --git a/src/protocol_ssh.c b/src/protocol_ssh.c index ec2664c..9ad5110 100644 --- a/src/protocol_ssh.c +++ b/src/protocol_ssh.c @@ -329,8 +329,10 @@ static int gen_default_keys(void) } if (chmod(path, S_IRUSR)) return 1; - if (pwd) - chown(path, pwd->pw_uid, pwd->pw_gid); + if (pwd) { + if (chown(path, pwd->pw_uid, pwd->pw_gid)) + return 1; + } snprintf(path, sizeof path, "%s/%s", getopt_str(OPT_SSH_RUN_DIR), dsa_key_suf); @@ -345,8 +347,10 @@ static int gen_default_keys(void) } if (chmod(path, S_IRUSR)) return 1; - if (pwd) - chown(path, pwd->pw_uid, pwd->pw_gid); + if (pwd) { + if (chown(path, pwd->pw_uid, pwd->pw_gid)) + return 1; + } snprintf(path, sizeof path, "%s/%s", getopt_str(OPT_SSH_RUN_DIR), ecdsa_key_suf); @@ -361,8 +365,10 @@ static int gen_default_keys(void) } if (chmod(path, S_IRUSR)) return 1; - if (pwd) - chown(path, pwd->pw_uid, pwd->pw_gid); + if (pwd) { + if (chown(path, pwd->pw_uid, pwd->pw_gid)) + return 1; + } return s != 0; } diff --git a/src/utils.c b/src/utils.c index 0979622..3cf88d5 100644 --- a/src/utils.c +++ b/src/utils.c @@ -297,7 +297,8 @@ pid_t daemonize(int stay_foreground) if (!stay_foreground) { /* Change the working directory to the root directory */ /* or another appropriated directory */ - chdir("/"); + if (chdir("/")) + return -1; /* Close all open file descriptors */ assert( close_fds_except(-1) == 0 ); assert( redirect_devnull_to(0, 1, 2, -1) == 0 ); -- cgit v1.2.3