some adds, now it's possible to test it correctly.
channels still need some hack so they know the message system exists. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@8 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
родитель
96a99bab78
Коммит
f730d3b361
@ -380,6 +380,26 @@ void ssh_message_free(SSH_MESSAGE *msg){
|
||||
free(msg->auth_request.password);
|
||||
}
|
||||
break;
|
||||
case SSH_CHANNEL_REQUEST_OPEN:
|
||||
if(msg->channel_request_open.originator)
|
||||
free(msg->channel_request_open.originator);
|
||||
if(msg->channel_request_open.destination)
|
||||
free(msg->channel_request_open.destination);
|
||||
break;
|
||||
case SSH_CHANNEL_REQUEST:
|
||||
if(msg->channel_request.TERM)
|
||||
free(msg->channel_request.TERM);
|
||||
if(msg->channel_request.modes)
|
||||
free(msg->channel_request.modes);
|
||||
if(msg->channel_request.var_name)
|
||||
free(msg->channel_request.var_name);
|
||||
if(msg->channel_request.var_value)
|
||||
free(msg->channel_request.var_value);
|
||||
if(msg->channel_request.command)
|
||||
free(msg->channel_request.command);
|
||||
if(msg->channel_request.subsystem)
|
||||
free(msg->channel_request.subsystem);
|
||||
break;
|
||||
}
|
||||
memset(msg,0,sizeof(*msg));
|
||||
free(msg);
|
||||
|
13
samplesshd.c
13
samplesshd.c
@ -41,6 +41,7 @@ int main(int argc, char **argv){
|
||||
CHANNEL *chan;
|
||||
int auth=0;
|
||||
int sftp=0;
|
||||
int i;
|
||||
ssh_options_getopt(options,&argc,argv);
|
||||
ssh_options_set_dsa_server_key(options,"/etc/ssh/ssh_host_dsa_key");
|
||||
ssh_options_set_rsa_server_key(options,"/etc/ssh/ssh_host_rsa_key");
|
||||
@ -116,12 +117,12 @@ int main(int argc, char **argv){
|
||||
do {
|
||||
message=ssh_message_get(session);
|
||||
if(message && ssh_message_type(message)==SSH_CHANNEL_REQUEST &&
|
||||
ssh_message_subtype(message)==SSH_CHANNEL_REQUEST_SUBSYSTEM){
|
||||
if(!strcmp(ssh_message_channel_request_subsystem(message),"sftp")){
|
||||
ssh_message_subtype(message)==SSH_CHANNEL_REQUEST_SHELL){
|
||||
// if(!strcmp(ssh_message_channel_request_subsystem(message),"sftp")){
|
||||
sftp=1;
|
||||
ssh_message_channel_request_reply_success(message);
|
||||
break;
|
||||
}
|
||||
// }
|
||||
}
|
||||
if(!sftp){
|
||||
ssh_message_reply_default(message);
|
||||
@ -133,6 +134,12 @@ int main(int argc, char **argv){
|
||||
return 1;
|
||||
}
|
||||
printf("it works !\n");
|
||||
BUFFER *buf=buffer_new();
|
||||
do{
|
||||
i=channel_read(chan,buf,0,0);
|
||||
if(i>0)
|
||||
write(1,buffer_get(buf),buffer_get_len(buf));
|
||||
} while (i>0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user