diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-06-21 02:43:53 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-06-21 02:43:53 +0200 |
commit | a23e7844c3f11d19deaedd4906563ed96009bdcd (patch) | |
tree | 8f7d845496a60af3cd9ff139e48a53977253eede /src | |
parent | ed24b53240010fd648b31175e771331c019f9189 (diff) |
several minor bugfixes
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/protocol_ssh.c | 11 | ||||
-rw-r--r-- | src/utils.c | 29 |
3 files changed, 21 insertions, 25 deletions
@@ -309,9 +309,6 @@ int main(int argc, char *argv[]) LOG_SET_FUNCS_VA(LOG_COLORED_FUNCS); } - ABORT_ON_FATAL( selftest_minimal_requirements(), - "Selfcheck" ); - if (getopt_used(OPT_LOGLEVEL)) { value = getopt_str(OPT_LOGLEVEL); if (!strcasecmp(value, "debug")) @@ -335,6 +332,9 @@ int main(int argc, char *argv[]) N("%s (C) 2018 Toni Uhlig <%s>", PACKAGE_STRING, PACKAGE_BUGREPORT); #endif + ABORT_ON_FATAL( selftest_minimal_requirements(), + "Selfcheck" ); + if (geteuid() != 0) { E("%s", "I was made for root!"); exit(EXIT_FAILURE); diff --git a/src/protocol_ssh.c b/src/protocol_ssh.c index eeada5d..2ae0a07 100644 --- a/src/protocol_ssh.c +++ b/src/protocol_ssh.c @@ -202,8 +202,7 @@ static int set_default_keys(ssh_bind sshbind, int rsa_already_set, E_STRERR("RSA key '%s' inaccessible", path); return 1; } - if (ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, - "./ssh_host_rsa_key")) { + if (ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, path)) { E2("Faled to set RSA key: %s", ssh_get_error(sshbind)); return 1; } @@ -215,9 +214,7 @@ static int set_default_keys(ssh_bind sshbind, int rsa_already_set, if (access(path, R_OK)) { W_STRERR("Access DSA key '%s'", path); } else - if (ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, - "./ssh_host_dsa_key")) - { + if (ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, path)) { E2("Failed to set DSA key: %s", ssh_get_error(sshbind)); return 1; } @@ -229,9 +226,7 @@ static int set_default_keys(ssh_bind sshbind, int rsa_already_set, if (access(path, R_OK)) { W_STRERR("Access ECDSA key '%s'", path); } else - if (ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_ECDSAKEY, - "./ssh_host_ecdsa_key")) - { + if (ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_ECDSAKEY, path)) { E2("Failed to set ECDSA key: %s", ssh_get_error(sshbind)); return 1; } diff --git a/src/utils.c b/src/utils.c index d8fc0fe..dc98db7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -482,11 +482,6 @@ int setup_network_namespace(const char *name) } } - if (path_is_mountpoint(netns_path)) { - W2("Network namespace '%s' already mounted, doing nothing.", netns_path); - return 1; - } - while (mount("", getopt_str(OPT_NETNS_RUN_DIR), "none", MS_SHARED|MS_REC, NULL)) { @@ -544,24 +539,30 @@ int switch_network_namespace(const char *name) netns = open(net_path, O_RDONLY | O_CLOEXEC); if (netns < 0) { E_STRERR("Open network namespace '%s'", name); - return 1; + goto error; } if (setns(netns, CLONE_NEWNET) < 0) { E_STRERR("Setting the network namespace '%s'", name); close(netns); -#ifdef HAVE_VALGRIND - /* older valgrind versions dont support the setns syscall */ - if (RUNNING_ON_VALGRIND) { - W2("%s", "Running on valgrind, using unshare instead of setns .."); - return unshare(CLONE_NEWNET) != 0; - } -#endif - return 1; + goto error; } close(netns); return 0; +error: +#ifdef HAVE_VALGRIND + /* + * Older valgrind versions dont support the setns syscall + * or the open might fail with ENOENT. + */ + if (RUNNING_ON_VALGRIND) { + W2("%s", "Running on valgrind, using unshare instead of setns and " + "ignoring erros before .."); + return unshare(CLONE_NEWNET) != 0; + } +#endif + return 1; } int create_device_file_checked(const char *mount_path, const char *device_file, |