aboutsummaryrefslogtreecommitdiff
path: root/libssh/socket.c
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/socket.c
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/socket.c')
-rw-r--r--libssh/socket.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libssh/socket.c b/libssh/socket.c
index 6765b36..d4d8e80 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
*/