aboutsummaryrefslogtreecommitdiff
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-04 20:41:17 +0100
commitf34cd24f8073e87d09159b8a6c8e2fa48cd17227 (patch)
tree58215ba6907f70b7ed7155c643b423de608a0cfd /libssh/session.c
parent9cd5e97596aa10f349e960fb3ff5ca95634a1200 (diff)
downloadlibssh-f34cd24f8073e87d09159b8a6c8e2fa48cd17227.tar.gz
libssh-f34cd24f8073e87d09159b8a6c8e2fa48cd17227.tar.xz
libssh-f34cd24f8073e87d09159b8a6c8e2fa48cd17227.zip
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 a39a68c..e6d9fc7 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -54,6 +54,8 @@
*/
ssh_session ssh_new(void) {
ssh_session session;
+ char *id;
+ int rc;
session = malloc(sizeof (struct ssh_session_struct));
if (session == NULL) {
@@ -103,6 +105,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:
@@ -173,10 +208,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);