summaryrefslogtreecommitdiffstats
path: root/libssh/session.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2010-02-28 22:51:21 +0100
committerAndreas Schneider <mail@cynapses.org>2010-03-06 12:33:27 +0100
commit83c51d1c134a92df4a2bef52bcbfec42f3c8d49a (patch)
tree4548e6259247b21175d5140e259300268867cc93 /libssh/session.c
parentc712d30311221c153cf5b3778651a73992c38719 (diff)
Fixed and added support for several identity files.
Diffstat (limited to 'libssh/session.c')
-rw-r--r--libssh/session.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/libssh/session.c b/libssh/session.c
index f1c36b80..c73a2879 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -46,6 +46,8 @@
*/
ssh_session ssh_new(void) {
ssh_session session;
+ char *id;
+ int rc;
session = malloc(sizeof (struct ssh_session_struct));
if (session == NULL) {
@@ -95,6 +97,39 @@ ssh_session ssh_new(void) {
goto err;
}
#endif /* _WIN32 */
+
+ session->identity = ssh_list_new();
+ if (session->identity == NULL) {
+ goto err;
+ }
+
+ id = strdup("SSH_DIR/id_rsa");
+ if (id == NULL) {
+ goto err;
+ }
+ rc = ssh_list_append(session->identity, id);
+ if (rc == SSH_ERROR) {
+ goto err;
+ }
+
+ id = strdup("SSH_DIR/id_dsa");
+ if (id == NULL) {
+ goto err;
+ }
+ rc = ssh_list_append(session->identity, id);
+ if (rc == SSH_ERROR) {
+ goto err;
+ }
+
+ id = strdup("SSH_DIR/identity");
+ if (id == NULL) {
+ goto err;
+ }
+ rc = ssh_list_append(session->identity, id);
+ if (rc == SSH_ERROR) {
+ goto err;
+ }
+
return session;
err:
@@ -162,10 +197,20 @@ void ssh_free(ssh_session session) {
ssh_list_free(session->ssh_message_list);
}
+ if (session->identity) {
+ char *id;
+
+ for (id = ssh_list_pop_head(char *, session->identity);
+ id != NULL;
+ id = ssh_list_pop_head(char *, session->identity)) {
+ SAFE_FREE(id);
+ }
+ ssh_list_free(session->identity);
+ }
+
/* options */
SAFE_FREE(session->username);
SAFE_FREE(session->host);
- SAFE_FREE(session->identity);
SAFE_FREE(session->sshdir);
SAFE_FREE(session->knownhosts);