Sanitize libssh namespace + legacy wrappers

This commit is contained in:
Aris Adamantiadis
2010-05-14 00:51:08 +02:00
parent 46b249f5ce
commit b23b3f1d99
40 changed files with 1636 additions and 1311 deletions

View File

@@ -26,26 +26,26 @@ void do_connect(SSH_SESSION *session) {
return;
}
printf("Authenticated\n");
channel = channel_new(session);
channel_open_session(channel);
channel = ssh_channel_new(session);
ssh_channel_open_session(channel);
printf("Execute 'ls' on the channel\n");
error = channel_request_exec(channel, "ls");
error = ssh_channel_request_exec(channel, "ls");
if(error != SSH_OK){
fprintf(stderr, "Error executing command: %s\n", ssh_get_error(session));
return;
}
printf("--------------------output----------------------\n");
while (channel_read(channel, buf, sizeof(buf), 0)) {
while (ssh_channel_read(channel, buf, sizeof(buf), 0)) {
printf("%s", buf);
}
printf("\n");
printf("---------------------end------------------------\n");
channel_send_eof(channel);
fprintf(stderr, "Exit status: %d\n", channel_get_exit_status(channel));
ssh_channel_send_eof(channel);
fprintf(stderr, "Exit status: %d\n", ssh_channel_get_exit_status(channel));
printf("\nChannel test finished\n");
channel_close(channel);
channel_free(channel);
ssh_channel_close(channel);
ssh_channel_free(channel);
}
int main(int argc, char **argv){

View File

@@ -32,7 +32,7 @@
int main(int argc, char **argv){
ssh_pcap_file pcap;
ssh_pcap_context ctx;
ssh_buffer buffer=buffer_new();
ssh_buffer buffer=ssh_buffer_new();
char *str="Hello, this is a test string to test the capabilities of the"
"pcap file writer.";
printf("Simple pcap tester\n");

View File

@@ -22,8 +22,8 @@ void do_connect(SSH_SESSION *session){
return;
}
printf("Authenticated\n");
CHANNEL *channel=channel_new(session);
error=channel_open_forward(channel,"localhost",ECHO_PORT,"localhost",42);
CHANNEL *channel=ssh_channel_new(session);
error=ssh_channel_open_forward(channel,"localhost",ECHO_PORT,"localhost",42);
if(error!=SSH_OK){
fprintf(stderr,"Error when opening forward:%s\n",ssh_get_error(session));
return;
@@ -34,14 +34,14 @@ void do_connect(SSH_SESSION *session){
char buffer[20];
for(i=0;i<2000;++i){
sprintf(string,"%d\n",i);
channel_write(channel,string,strlen(string));
ssh_channel_write(channel,string,strlen(string));
do {
error=channel_poll(channel,0);
error=ssh_channel_poll(channel,0);
//if(error < strlen(string))
//usleep(10);
} while(error < strlen(string) && error >= 0);
if(error>0){
error=channel_read_nonblocking(channel,buffer,strlen(string),0);
error=ssh_channel_read_nonblocking(channel,buffer,strlen(string),0);
if(error>=0){
if(memcmp(buffer,string,strlen(string))!=0){
fprintf(stderr,"Problem with answer: wanted %s got %s\n",string,buffer);
@@ -58,8 +58,8 @@ void do_connect(SSH_SESSION *session){
}
}
printf("\nChannel test finished\n");
channel_close(channel);
channel_free(channel);
ssh_channel_close(channel);
ssh_channel_free(channel);
}
int main(int argc, char **argv){

View File

@@ -64,7 +64,7 @@ START_TEST (torture_pubkey_from_file)
ck_assert_msg(rc == 0,ssh_get_error(session));
string_free(pubkey);
ssh_string_free(pubkey);
/* test if it returns 1 if pubkey doesn't exist */
unlink(LIBSSH_RSA_TESTKEY ".pub");
@@ -138,9 +138,9 @@ START_TEST (torture_pubkey_generate_from_privkey)
ck_assert_msg(pubkey_new != NULL,ssh_get_error(session));
ck_assert(string_len(pubkey_orig) == string_len(pubkey_new));
ck_assert(memcmp(string_data(pubkey_orig), string_data(pubkey_new),
string_len(pubkey_orig)) == 0);
ck_assert(ssh_string_len(pubkey_orig) == ssh_string_len(pubkey_new));
ck_assert(memcmp(ssh_string_data(pubkey_orig), ssh_string_data(pubkey_new),
ssh_string_len(pubkey_orig)) == 0);
rc = ssh_publickey_to_file(session, LIBSSH_RSA_TESTKEY ".pub", pubkey_new, type_new);
ck_assert_msg(rc == 0,ssh_get_error(session));
@@ -150,8 +150,8 @@ START_TEST (torture_pubkey_generate_from_privkey)
ck_assert_str_eq(pubkey_line_orig, pubkey_line_new);
string_free(pubkey_orig);
string_free(pubkey_new);
ssh_string_free(pubkey_orig);
ssh_string_free(pubkey_new);
}
END_TEST