mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
Fix percent expand character %d to home directory
Fixes: #349 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Pavol Žáčik <pzacik@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -25,7 +25,7 @@ extern LIBSSH_THREAD int ssh_log_level;
|
||||
#define HOSTKEYALGORITHMS "ssh-ed25519,ecdsa-sha2-nistp521,ssh-rsa"
|
||||
#define PUBKEYACCEPTEDTYPES "rsa-sha2-512,ssh-rsa,ecdsa-sha2-nistp521"
|
||||
#define MACS "hmac-sha1,hmac-sha2-256,hmac-sha2-512,hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com"
|
||||
#define USER_KNOWN_HOSTS "%d/my_known_hosts"
|
||||
#define USER_KNOWN_HOSTS "%d/.ssh/my_known_hosts"
|
||||
#define GLOBAL_KNOWN_HOSTS "/etc/ssh/my_ssh_known_hosts"
|
||||
#define BIND_ADDRESS "::1"
|
||||
|
||||
|
||||
@@ -288,7 +288,8 @@ static void torture_path_expand_escape(void **state) {
|
||||
const char *s = "%d/%h/%p/by/%r";
|
||||
char *e;
|
||||
|
||||
session->opts.sshdir = strdup("guru");
|
||||
/* Set the homedir here to prevent querying the NSS DB */
|
||||
session->opts.homedir = strdup("guru");
|
||||
session->opts.host = strdup("meditation");
|
||||
session->opts.port = 0;
|
||||
session->opts.username = strdup("root");
|
||||
@@ -310,9 +311,10 @@ static void torture_path_expand_known_hosts(void **state) {
|
||||
ssh_session session = *state;
|
||||
char *tmp;
|
||||
|
||||
session->opts.sshdir = strdup("/home/guru/.ssh");
|
||||
/* Set the homedir here to prevent querying the NSS DB */
|
||||
session->opts.homedir = strdup("/home/guru");
|
||||
|
||||
tmp = ssh_path_expand_escape(session, "%d/known_hosts");
|
||||
tmp = ssh_path_expand_escape(session, "%d/.ssh/known_hosts");
|
||||
assert_non_null(tmp);
|
||||
assert_string_equal(tmp, "/home/guru/.ssh/known_hosts");
|
||||
free(tmp);
|
||||
@@ -322,9 +324,10 @@ static void torture_path_expand_percent(void **state) {
|
||||
ssh_session session = *state;
|
||||
char *tmp;
|
||||
|
||||
session->opts.sshdir = strdup("/home/guru/.ssh");
|
||||
/* Set the homedir here to prevent querying the NSS DB */
|
||||
session->opts.homedir = strdup("/home/guru");
|
||||
|
||||
tmp = ssh_path_expand_escape(session, "%d/config%%1");
|
||||
tmp = ssh_path_expand_escape(session, "%d/.ssh/config%%1");
|
||||
assert_non_null(tmp);
|
||||
assert_string_equal(tmp, "/home/guru/.ssh/config%1");
|
||||
free(tmp);
|
||||
|
||||
@@ -2067,25 +2067,25 @@ static void torture_options_apply (void **state)
|
||||
rc = ssh_list_append(awaited_list, id);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
/* append the defaults; this list is copied from ssh_new@src/session.c */
|
||||
id = ssh_path_expand_escape(session, "%d/id_ed25519");
|
||||
id = ssh_path_expand_escape(session, "%d/.ssh/id_ed25519");
|
||||
rc = ssh_list_append(awaited_list, id);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
#ifdef HAVE_ECC
|
||||
id = ssh_path_expand_escape(session, "%d/id_ecdsa");
|
||||
id = ssh_path_expand_escape(session, "%d/.ssh/id_ecdsa");
|
||||
rc = ssh_list_append(awaited_list, id);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
#endif
|
||||
id = ssh_path_expand_escape(session, "%d/id_rsa");
|
||||
id = ssh_path_expand_escape(session, "%d/.ssh/id_rsa");
|
||||
rc = ssh_list_append(awaited_list, id);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
#ifdef WITH_FIDO2
|
||||
/* Add security key identities */
|
||||
id = ssh_path_expand_escape(session, "%d/id_ed25519_sk");
|
||||
id = ssh_path_expand_escape(session, "%d/.ssh/id_ed25519_sk");
|
||||
rc = ssh_list_append(awaited_list, id);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
id = ssh_path_expand_escape(session, "%d/id_ecdsa_sk");
|
||||
id = ssh_path_expand_escape(session, "%d/.ssh/id_ecdsa_sk");
|
||||
rc = ssh_list_append(awaited_list, id);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
#endif /* HAVE_ECC */
|
||||
|
||||
Reference in New Issue
Block a user