Skip to content

Commit

Permalink
ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterTea committed May 1, 2024
1 parent 69a8e62 commit a2bee60
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/linux_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ jobs:
cmake -DSANITIZE_ADDRESS=ON ../
make -j`nproc`
popd
./test/system_tests/connect_with_jumphost.sh
TSAN_OPTIONS="suppressions=../test/test_tsan.suppression" ./build/et-test
rm -Rf build
msan_linux:
Expand Down
1 change: 1 addition & 0 deletions src/terminal/ParseConfigFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,7 @@ int parse_ssh_config_file(const char *targethost, struct Options *options,
}

ifstream infile(expandedFilename);
free(expandedFilename);
if (!infile.good()) {
LOG(INFO) << filename << " not found";
return 0;
Expand Down
78 changes: 47 additions & 31 deletions src/terminal/TerminalClientMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ int main(int argc, char** argv) {
// Override easylogging handler for sigint
::signal(SIGINT, et::InterruptSignalHandler);

Options sshConfigOptions = {
NULL, // username
NULL, // host
NULL, // sshdir
NULL, // knownhosts
NULL, // ProxyCommand
NULL, // ProxyJump
0, // timeout
0, // port
0, // StrictHostKeyChecking
0, // ssh2
0, // ssh1
NULL, // gss_server_identity
NULL, // gss_client_identity
0, // gss_delegate_creds
0, // forward_agent
NULL // identity_agent
};

// Parse command line arguments
cxxopts::Options options("et", "Remote shell for the busy and impatient");
try {
Expand Down Expand Up @@ -216,37 +235,23 @@ int main(int argc, char** argv) {
exit(0);
}

Options sshConfigOptions = {
NULL, // username
NULL, // host
NULL, // sshdir
NULL, // knownhosts
NULL, // ProxyCommand
NULL, // ProxyJump
0, // timeout
0, // port
0, // StrictHostKeyChecking
0, // ssh2
0, // ssh1
NULL, // gss_server_identity
NULL, // gss_client_identity
0, // gss_delegate_creds
0, // forward_agent
NULL // identity_agent
};

char* home_dir = ssh_get_user_home_dir();
const char* host_from_command = destinationHost.c_str();
ssh_options_set(&sshConfigOptions, SSH_OPTIONS_HOST,
destinationHost.c_str());
// First parse user-specific ssh config, then system-wide config.
parse_ssh_config_file(host_from_command, &sshConfigOptions,
string(home_dir) + USER_SSH_CONFIG_PATH);
parse_ssh_config_file(host_from_command, &sshConfigOptions,
SYSTEM_SSH_CONFIG_PATH);
LOG(INFO) << "Parsed ssh config file, connecting to "
<< sshConfigOptions.host;
destinationHost = string(sshConfigOptions.host);
{
char* home_dir = ssh_get_user_home_dir();
const char* host_from_command = destinationHost.c_str();
ssh_options_set(&sshConfigOptions, SSH_OPTIONS_HOST,
destinationHost.c_str());
// First parse user-specific ssh config, then system-wide config.
parse_ssh_config_file(host_from_command, &sshConfigOptions,
string(home_dir) + USER_SSH_CONFIG_PATH);
parse_ssh_config_file(host_from_command, &sshConfigOptions,
SYSTEM_SSH_CONFIG_PATH);
if (sshConfigOptions.host) {
LOG(INFO) << "Parsed ssh config file, connecting to "
<< sshConfigOptions.host;
destinationHost = string(sshConfigOptions.host);
}
free(home_dir);
}

// Parse username: cmdline > sshconfig > localuser
if (username.empty()) {
Expand Down Expand Up @@ -372,6 +377,17 @@ int main(int argc, char** argv) {
handleParseException(oe, options);
}

// Clean up ssh config options
SAFE_FREE(sshConfigOptions.username);
SAFE_FREE(sshConfigOptions.host);
SAFE_FREE(sshConfigOptions.sshdir);
SAFE_FREE(sshConfigOptions.knownhosts);
SAFE_FREE(sshConfigOptions.ProxyCommand);
SAFE_FREE(sshConfigOptions.ProxyJump);
SAFE_FREE(sshConfigOptions.gss_server_identity);
SAFE_FREE(sshConfigOptions.gss_client_identity);
SAFE_FREE(sshConfigOptions.identity_agent);

#ifdef WIN32
WSACleanup();
#endif
Expand Down

0 comments on commit a2bee60

Please sign in to comment.