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
This commit is contained in:
Andreas Schneider
2009-02-02 14:41:44 +00:00
parent 944084964a
commit 70aa33c041
6 changed files with 89 additions and 1 deletions

View File

@@ -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
*/