1
1

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
Этот коммит содержится в:
Aris Adamantiadis 2005-08-18 10:08:20 +00:00
родитель f730d3b361
Коммит 56602ca031
11 изменённых файлов: 43 добавлений и 20 удалений

Просмотреть файл

@ -1,7 +1,7 @@
SHELL = /bin/sh
VPATH = @srcdir@
subdirs = libssh/
subdirs = libssh/ sftp_server/
top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@

21
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;}

Просмотреть файл

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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;
}