aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2005-08-18 10:08:20 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2005-08-18 10:08:20 +0000
commit56602ca031726a7682de3164b8f7f3da4881f7bb (patch)
treec524a0bec36899fda5c0ce90345ec8acab62a15c
parentf730d3b361f717135786bddb3c949bfae213bbff (diff)
downloadlibssh-56602ca031726a7682de3164b8f7f3da4881f7bb.tar.gz
libssh-56602ca031726a7682de3164b8f7f3da4881f7bb.tar.xz
libssh-56602ca031726a7682de3164b8f7f3da4881f7bb.zip
More work on the server side and sftp.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@9 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--Makefile.in2
-rwxr-xr-xconfigure21
-rw-r--r--configure.in3
-rw-r--r--include/libssh/priv.h3
-rw-r--r--libssh/dh.c4
-rw-r--r--libssh/messages.c7
-rw-r--r--libssh/packet.c2
-rw-r--r--libssh/server.c2
-rw-r--r--libssh/session.c6
-rw-r--r--libssh/sftp.c12
-rw-r--r--samplesshd.c1
11 files changed, 43 insertions, 20 deletions
diff --git a/Makefile.in b/Makefile.in
index e3eed95..5d38116 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
SHELL = /bin/sh
VPATH = @srcdir@
-subdirs = libssh/
+subdirs = libssh/ sftp_server/
top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
diff --git a/configure b/configure
index 18d8205..88ffa2e 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for libssh 0.11-dev .
+# Generated by GNU Autoconf 2.59 for libssh 0.2-dev .
#
# Report bugs to <aris@0xbadc0de.be>.
#
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='libssh'
PACKAGE_TARNAME='libssh'
-PACKAGE_VERSION='0.11-dev '
-PACKAGE_STRING='libssh 0.11-dev '
+PACKAGE_VERSION='0.2-dev '
+PACKAGE_STRING='libssh 0.2-dev '
PACKAGE_BUGREPORT='aris@0xbadc0de.be'
ac_unique_file="sample.c"
@@ -780,7 +780,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libssh 0.11-dev to adapt to many kinds of systems.
+\`configure' configures libssh 0.2-dev to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -841,7 +841,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libssh 0.11-dev :";;
+ short | recursive ) echo "Configuration of libssh 0.2-dev :";;
esac
cat <<\_ACEOF
@@ -953,7 +953,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-libssh configure 0.11-dev
+libssh configure 0.2-dev
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -967,7 +967,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libssh $as_me 0.11-dev , which was
+It was created by libssh $as_me 0.2-dev , which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -5060,7 +5060,7 @@ fi
done
- ac_config_files="$ac_config_files Makefile libssh/Makefile"
+ ac_config_files="$ac_config_files Makefile libssh/Makefile sftp_server/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -5424,7 +5424,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by libssh $as_me 0.11-dev , which was
+This file was extended by libssh $as_me 0.2-dev , which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5484,7 +5484,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-libssh config.status 0.11-dev
+libssh config.status 0.2-dev
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -5589,6 +5589,7 @@ do
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"libssh/Makefile" ) CONFIG_FILES="$CONFIG_FILES libssh/Makefile" ;;
+ "sftp_server/Makefile" ) CONFIG_FILES="$CONFIG_FILES sftp_server/Makefile" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
diff --git a/configure.in b/configure.in
index 59e39b5..a7e2580 100644
--- a/configure.in
+++ b/configure.in
@@ -56,5 +56,6 @@ AC_CHECK_FUNCS([endpwent gethostbyaddr gethostbyname getpass memmove memset \
select socket strchr strdup strerror strstr poll])
AC_CONFIG_FILES([Makefile
- libssh/Makefile])
+ libssh/Makefile
+ sftp_server/Makefile])
AC_OUTPUT
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index c080762..c6a4b48 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -294,6 +294,7 @@ struct ssh_session {
/* auths accepted by server */
int auth_methods;
int hostkeys; /* contains type of host key wanted by client, in server impl */
+ struct ssh_message *ssh_message; /* ssh message */
};
struct ssh_kbdint {
@@ -465,7 +466,7 @@ u64 ntohll(u64);
#define htonll(x) ntohll(x)
/* channels1.c */
-CHANNEL *channel_open_session1(SSH_SESSION *session);
+int channel_open_session1(CHANNEL *channel);
int channel_request_pty_size1(CHANNEL *channel, char *terminal,int cols,
int rows);
int channel_change_pty_size1(CHANNEL *channel, int cols, int rows);
diff --git a/libssh/dh.c b/libssh/dh.c
index 407fe97..c96c70a 100644
--- a/libssh/dh.c
+++ b/libssh/dh.c
@@ -213,14 +213,14 @@ void dh_build_k(SSH_SESSION *session){
#endif
bignum_ctx_free(ctx);
}
-
+/*
static void sha_add(STRING *str,SHACTX *ctx){
sha1_update(ctx,str,string_len(str)+4);
#ifdef DEBUG_CRYPTO
ssh_print_hexa("partial hashed sessionid",str,string_len(str)+4);
#endif
}
-
+*/
void make_sessionid(SSH_SESSION *session){
SHACTX *ctx;
STRING *num,*str;
diff --git a/libssh/messages.c b/libssh/messages.c
index 0f0aa36..66653d0 100644
--- a/libssh/messages.c
+++ b/libssh/messages.c
@@ -34,7 +34,11 @@ MA 02111-1307, USA. */
#include <string.h>
static SSH_MESSAGE *message_new(SSH_SESSION *session){
- SSH_MESSAGE *msg=malloc(sizeof(SSH_MESSAGE));
+ SSH_MESSAGE *msg=session->ssh_message;
+ if(!msg){
+ msg=malloc(sizeof(SSH_MESSAGE));
+ session->ssh_message=msg;
+ }
memset(msg,0,sizeof (*msg));
msg->session=session;
return msg;
@@ -402,5 +406,4 @@ void ssh_message_free(SSH_MESSAGE *msg){
break;
}
memset(msg,0,sizeof(*msg));
- free(msg);
}
diff --git a/libssh/packet.c b/libssh/packet.c
index 0f86f61..e717ba5 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -375,7 +375,7 @@ static int packet_send1(SSH_SESSION *session){
*/
padding=blocksize-(currentlen % blocksize);
if(session->current_crypto)
- ssh_get_random(padstring,padding);
+ ssh_get_random(padstring,padding,0);
else
memset(padstring,0,padding);
finallen=htonl(currentlen);
diff --git a/libssh/server.c b/libssh/server.c
index 336aaf5..fb67875 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -211,6 +211,8 @@ static int dh_handshake_server(SSH_SESSION *session){
case TYPE_RSA:
prv=session->rsa_key;
break;
+ default:
+ prv=NULL;
}
pub=publickey_from_privatekey(prv);
pubkey=publickey_to_string(pub);
diff --git a/libssh/session.c b/libssh/session.c
index ef23d03..731446d 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -24,7 +24,7 @@
#include <string.h>
#include "libssh/libssh.h"
#include "libssh/priv.h"
-
+#include "libssh/server.h"
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
SSH_SESSION *ssh_new() {
@@ -72,6 +72,10 @@ void ssh_cleanup(SSH_SESSION *session){
private_key_free(session->dsa_key);
if(session->rsa_key)
private_key_free(session->rsa_key);
+ if(session->ssh_message){
+ ssh_message_free(session->ssh_message);
+ free(session->ssh_message);
+ }
memset(session,'X',sizeof(SSH_SESSION)); /* burn connection, it could hangs
sensitive datas */
free(session);
diff --git a/libssh/sftp.c b/libssh/sftp.c
index 4135e5b..8e293e1 100644
--- a/libssh/sftp.c
+++ b/libssh/sftp.c
@@ -2,7 +2,7 @@
/* don't look further if you believe this is just FTP over some tunnel. It IS different */
/* This file contains code written by Nick Zitzmann */
/*
-Copyright 2003 Aris Adamantiadis
+Copyright 2003-2005 Aris Adamantiadis
This file is part of the SSH Library
@@ -60,6 +60,16 @@ SFTP_SESSION *sftp_new(SSH_SESSION *session){
return sftp;
}
+#ifndef NO_SERVER
+SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan){
+ SFTP_SESSION *sftp=malloc(sizeof(SFTP_SESSION));
+ memset(sftp,0,sizeof(SFTP_SESSION));
+ sftp->session=session;
+ sftp->channel=chan;
+ return sftp;
+}
+#endif
+
void sftp_free(SFTP_SESSION *sftp){
struct request_queue *ptr;
channel_send_eof(sftp->channel);
diff --git a/samplesshd.c b/samplesshd.c
index 7fe9328..15af29c 100644
--- a/samplesshd.c
+++ b/samplesshd.c
@@ -140,6 +140,7 @@ int main(int argc, char **argv){
if(i>0)
write(1,buffer_get(buf),buffer_get_len(buf));
} while (i>0);
+ ssh_disconnect(session);
return 0;
}