begin fixing the ssh_say everywhere

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@167 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Aris Adamantiadis 2008-06-12 20:40:43 +00:00
parent fe51f9c766
commit da3d665a13
8 changed files with 29 additions and 23 deletions

View File

@ -227,7 +227,7 @@ STRING *buffer_get_ssh_string(BUFFER *buffer){
return NULL; /* it is indeed */
str=string_new(hostlen);
if(buffer_get_data(buffer,str->string,hostlen)!=hostlen){
ssh_say(0,"buffer_get_ssh_string: oddish : second test failed when first was successful. len=%d",hostlen);
// should never happen
free(str);
return NULL;
}

View File

@ -130,7 +130,7 @@ int ssh_connect_ai_timeout(SSH_SESSION *session, const char *host, int port, str
return -1;
}
/* s is connected ? */
ssh_say(3,"socket connected with timeout\n");
ssh_log(session,SSH_LOG_PACKET,"socket connected with timeout\n");
sock_set_blocking(s);
leave_function();
return s;
@ -164,7 +164,7 @@ socket_t ssh_connect_host(SSH_SESSION *session, const char *host, const char
if(bind_addr){
struct addrinfo *bind_ai, *bind_ai2;
ssh_say(2,"resolving %s\n",bind_addr);
ssh_log(session,SSH_LOG_PACKET,"resolving %s\n",bind_addr);
my_errno=getai(host,0,&bind_ai);
if (my_errno){
ssh_set_error(session,SSH_FATAL,"Failed to resolve bind address %s (%s)",bind_addr,gai_strerror(my_errno));

View File

@ -39,14 +39,14 @@ u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
if(session->current_crypto)
packet_decrypt(session,crypted,session->current_crypto->in_cipher->blocksize);
memcpy(&decrypted,crypted,sizeof(decrypted));
ssh_say(3,"size decrypted : %lx\n",ntohl(decrypted));
ssh_log(session,SSH_LOG_PACKET,"packet size decrypted : %d (0x%lx)",ntohl(decrypted),ntohl(decrypted));
return ntohl(decrypted);
}
int packet_decrypt(SSH_SESSION *session, void *data,u32 len){
struct crypto_struct *crypto=session->current_crypto->in_cipher;
char *out=malloc(len);
ssh_say(3,"Decrypting %d bytes data\n",len);
ssh_log(session,SSH_LOG_PACKET,"Decrypting %d bytes",len);
#ifdef HAVE_LIBGCRYPT
crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey,session->current_crypto->decryptIV);
crypto->cbc_decrypt(crypto,data,out,len);
@ -69,7 +69,7 @@ unsigned char * packet_encrypt(SSH_SESSION *session,void *data,u32 len){
if(!session->current_crypto)
return NULL; /* nothing to do here */
crypto= session->current_crypto->out_cipher;
ssh_say(3,"seq num = %d, len = %d\n",session->send_seq,len);
ssh_log(session,SSH_LOG_PACKET,"encrypting packet with seq num: %d, len: %d",session->send_seq,len);
#ifdef HAVE_LIBGCRYPT
crypto->set_encrypt_key(crypto,session->current_crypto->encryptkey,session->current_crypto->encryptIV);
#elif defined HAVE_LIBCRYPTO

View File

@ -727,23 +727,23 @@ STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char
++*count;
/* are them readable ? */
snprintf(public,256,pub,home);
ssh_say(2,"Trying to open %s\n",public);
ssh_log(session,SSH_LOG_PACKET,"Trying to open public key %s",public);
if(!ssh_file_readaccess_ok(public)){
ssh_say(2,"Failed\n");
ssh_log(session,SSH_LOG_PACKET,"Failed");
return publickey_from_next_file(session,pub_keys_path,keys_path,privkeyfile,type,count);
}
snprintf(private,256,priv,home);
ssh_say(2,"Trying to open %s\n",private);
ssh_log(session,SSH_LOG_PACKET,"Trying to open private key %s",private);
if(!ssh_file_readaccess_ok(private)){
ssh_say(2,"Failed\n");
ssh_log(session,SSH_LOG_PACKET,"Failed");
return publickey_from_next_file(session,pub_keys_path,keys_path,privkeyfile,type,count);
}
ssh_say(2,"Okay both files ok\n");
ssh_log(session,SSH_LOG_PACKET,"Success reading public and private key");
/* ok, we are sure both the priv8 and public key files are readable : we return the public one as a string,
and the private filename in arguments */
pubkey=publickey_from_file(session,public,type);
if(!pubkey){
ssh_say(2,"Wasn't able to open public key file %s : %s\n",public,ssh_get_error(session));
ssh_log(session,SSH_LOG_PACKET,"Wasn't able to open public key file %s : %s",public,ssh_get_error(session));
return publickey_from_next_file(session,pub_keys_path,keys_path,privkeyfile,type,count);
}
*privkeyfile=realloc(*privkeyfile,strlen(private)+1);

View File

@ -535,7 +535,7 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,PUBLIC_
return NULL;
}
if(len<rsalen)
ssh_say(0,"Len %d < %d\n",len,rsalen);
ssh_log(session,SSH_LOG_RARE,"RSA signature len %d < %d",len,rsalen);
sign->type=TYPE_RSA;
#ifdef HAVE_LIBGCRYPT
gcry_sexp_build(&sig,NULL,"(sig-val(rsa(s %b)))",string_len(e),e->string);
@ -576,7 +576,7 @@ void signature_free(SIGNATURE *sign){
#endif
break;
default:
ssh_say(1,"freeing a signature with no type !\n");
ssh_log(NULL,SSH_LOG_RARE,"freeing a signature with no type !\n");
}
free(sign);
}

View File

@ -161,7 +161,7 @@ static int packet_read2(SSH_SESSION *session){
packet=malloc(to_be_read);
memcpy(packet,buffer_get_rest(session->in_socket_buffer),to_be_read-current_macsize);
buffer_pass_bytes(session->in_socket_buffer,to_be_read-current_macsize);
ssh_say(3,"Read a %d bytes packet\n",len);
ssh_log(session,SSH_LOG_PACKET,"Read a %d bytes packet",len);
buffer_add_data(session->in_buffer,packet,to_be_read-current_macsize);
free(packet);
}

View File

@ -80,15 +80,19 @@ SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan){
}
int sftp_server_init(SFTP_SESSION *sftp){
sftp_enter_function();
SFTP_PACKET *packet=sftp_packet_read(sftp);
u32 version;
BUFFER *reply;
if(!packet)
return -1;
if(!packet){
sftp_leave_function();
return -1;
}
if(packet->type != SSH_FXP_INIT){
ssh_set_error(sftp->session,SSH_FATAL,"Packet read of type %d instead of SSH_FXP_INIT",
packet->type);
sftp_packet_free(packet);
sftp_leave_function();
return -1;
}
ssh_say(2,"received SSH_FXP_INIT\n");
@ -101,6 +105,7 @@ int sftp_server_init(SFTP_SESSION *sftp){
buffer_add_u32(reply,ntohl(LIBSFTP_VERSION));
if(sftp_packet_write(sftp,SSH_FXP_VERSION,reply)==-1){
buffer_free(reply);
sftp_leave_function();
return -1;
}
buffer_free(reply);
@ -109,6 +114,7 @@ int sftp_server_init(SFTP_SESSION *sftp){
sftp->version=LIBSFTP_VERSION;
else
sftp->version=version;
sftp_leave_function();
return 0;
}
#endif

View File

@ -466,7 +466,7 @@ static int crypt_set_algorithms2(SSH_SESSION *session){
ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms2 : no crypto algorithm function found for %s",wanted);
return SSH_ERROR;
}
ssh_say(2,"Set output algorithm %s\n",wanted);
ssh_log(session,SSH_LOG_PACKET,"Set output algorithm %s",wanted);
session->next_crypto->out_cipher=cipher_new(i);
i=0;
/* in */
@ -477,7 +477,7 @@ static int crypt_set_algorithms2(SSH_SESSION *session){
ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",wanted);
return SSH_ERROR;
}
ssh_say(2,"Set input algorithm %s\n",wanted);
ssh_log(session,SSH_LOG_PACKET,"Set input algorithm %s",wanted);
session->next_crypto->in_cipher=cipher_new(i);
/* compression */
if(strstr(session->client_kex.methods[SSH_COMP_C_S],"zlib"))
@ -524,7 +524,7 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server : no crypto algorithm function found for %s",server);
return SSH_ERROR;
}
ssh_say(2,"Set output algorithm %s\n",match);
ssh_log(session,SSH_LOG_PACKET,"Set output algorithm %s",match);
session->next_crypto->out_cipher=cipher_new(i);
i=0;
/* in */
@ -541,14 +541,14 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server : no crypto algorithm function found for %s",server);
return SSH_ERROR;
}
ssh_say(2,"Set input algorithm %s\n",match);
ssh_log(session,SSH_LOG_PACKET,"Set input algorithm %s",match);
session->next_crypto->in_cipher=cipher_new(i);
/* compression */
client=session->client_kex.methods[SSH_CRYPT_C_S];
server=session->server_kex.methods[SSH_CRYPT_C_S];
match=ssh_find_matching(client,server);
if(match && !strcmp(match,"zlib")){
ssh_say(2,"enabling C->S compression\n");
ssh_log(session,SSH_LOG_PACKET,"enabling C->S compression");
session->next_crypto->do_compress_in=1;
}
@ -556,7 +556,7 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
server=session->server_kex.methods[SSH_CRYPT_S_C];
match=ssh_find_matching(client,server);
if(match && !strcmp(match,"zlib")){
ssh_say(2,"enabling S->C compression\n");
ssh_log(session,SSH_LOG_PACKET,"enabling S->C compression\n");
session->next_crypto->do_compress_out=1;
}