diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-07-19 00:21:02 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-07-19 00:21:02 +0200 |
commit | aa3e837123dc576967a024126bef351b68ba33e5 (patch) | |
tree | 9abd6e797c57f435ae253cbf3711c8b582925f0b /src | |
parent | b678e84c542862811059cf9c2974f7f2aed0914b (diff) | |
parent | d83e11d86a24c4dd9bf8f09de57d7c1377c15eea (diff) |
Merge branch 'master' of ssh://git.lan:/git/potd
Diffstat (limited to 'src')
-rw-r--r-- | src/jail.c | 3 | ||||
-rw-r--r-- | src/protocol_ssh.c | 18 | ||||
-rw-r--r-- | src/utils.c | 3 |
3 files changed, 16 insertions, 8 deletions
@@ -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 ); |