summaryrefslogtreecommitdiffstats
path: root/libssh
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-02-02 14:41:44 +0000
committerAndreas Schneider <mail@cynapses.org>2009-02-02 14:41:44 +0000
commit70aa33c041b88573b32d67d0153c6472ce41ea8b (patch)
treed6f7d17110e3b5994ec3fcdf9218c080827220c4 /libssh
parent944084964a424584efa1f3e46c8efb731e58023f (diff)
downloadlibssh-70aa33c041b88573b32d67d0153c6472ce41ea8b.tar.gz
libssh-70aa33c041b88573b32d67d0153c6472ce41ea8b.tar.xz
libssh-70aa33c041b88573b32d67d0153c6472ce41ea8b.zip
Start with ssh agent implementation.
This is work in progress. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@200 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r--libssh/Makefile.am2
-rw-r--r--libssh/auth.c12
-rw-r--r--libssh/session.c3
-rw-r--r--libssh/socket.c31
4 files changed, 47 insertions, 1 deletions
diff --git a/libssh/Makefile.am b/libssh/Makefile.am
index bc71495a..db766ee7 100644
--- a/libssh/Makefile.am
+++ b/libssh/Makefile.am
@@ -1,6 +1,6 @@
lib_LTLIBRARIES = libssh.la
-libssh_la_SOURCES = auth1.c auth.c base64.c buffer.c \
+libssh_la_SOURCES = agent.c auth1.c auth.c base64.c buffer.c \
channels1.c channels.c client.c connect.c \
crc32.c crypt.c dh.c error.c gcrypt_missing.c \
gzip.c init.c kex.c keyfiles.c \
diff --git a/libssh/auth.c b/libssh/auth.c
index eb212f75..c2fc29f8 100644
--- a/libssh/auth.c
+++ b/libssh/auth.c
@@ -432,6 +432,18 @@ int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
leave_function();
return err;
}
+
+ /* try ssh-agent keys first */
+#ifndef _WIN32
+#if 0
+ if (agent_running(session)) {
+ ssh_say(1, "SSH Agent is running\n");
+ count = agent_ident_count(session);
+ ssh_say(1, "SSH Agent has %d key(s)\n", count);
+ }
+#endif
+#endif
+
if(session->options->identity){
ssh_say(2,"Trying identity file %s\n",session->options->identity);
keys_path[0]=session->options->identity;
diff --git a/libssh/session.c b/libssh/session.c
index 877c44a1..8ac005b4 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -48,6 +48,7 @@ SSH_SESSION *ssh_new() {
session->log_indent=0;
session->out_buffer=buffer_new();
session->in_buffer=buffer_new();
+ session->agent=agent_new(session);
return session;
}
@@ -75,6 +76,8 @@ void ssh_cleanup(SSH_SESSION *session){
// delete all channels
while(session->channels)
channel_free(session->channels);
+ if (session->agent)
+ agent_free(session->agent);
if(session->client_kex.methods)
for(i=0;i<10;i++)
if(session->client_kex.methods[i])
diff --git a/libssh/socket.c b/libssh/socket.c
index 6765b36b..d4d8e800 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -27,8 +27,10 @@
#ifdef _WIN32
#include <winsock2.h>
#else
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/un.h>
#endif
#include "libssh/priv.h"
@@ -104,6 +106,35 @@ void ssh_socket_free(struct socket *s){
free(s);
}
+#ifndef _WIN32
+int ssh_socket_unix(struct socket *s, const char *path) {
+ struct sockaddr_un sunaddr;
+
+ sunaddr.sun_family = AF_UNIX;
+ snprintf(sunaddr.sun_path, sizeof(sunaddr.sun_path), "%s", path);
+
+ s->fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (s->fd < 0) {
+ return -1;
+ }
+
+ if (fcntl(s->fd, F_SETFD, 1) == -1) {
+ close(s->fd);
+ s->fd = -1;
+ return -1;
+ }
+
+ if (connect(s->fd, (struct sockaddr *) &sunaddr,
+ sizeof(sunaddr)) < 0) {
+ close(s->fd);
+ s->fd = -1;
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
/* \internal
* \brief closes a socket
*/