• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Virtual machine Management Terminal User Interface


Commit MetaInfo

Révision1880db8a8c2277b507ba75fdf9b27d77b92381e6 (tree)
l'heure2022-06-25 08:32:17
AuteurKoine Yuusuke(koinec) <koinec@user...>
CommiterKoine Yuusuke(koinec)

Message de Log

Support ErrInfo for SSHCmd_Connect() function.

Change Summary

Modification

--- a/src/sshcmd.c
+++ b/src/sshcmd.c
@@ -211,25 +211,37 @@ int
211211 if( 0xffffffff == p_hvcon->ssh.t_sin.sin_addr.s_addr ) {
212212 pt_host =gethostbyname( pt_ssh->str_hostfqdn );
213213 if( NULL == pt_host ) {
214+ ErrInfo_Warn( "Can't resolve SSH server hostname.",
215+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
216+ errno, 0x00, 0x00, pt_ssh->str_hostfqdn );
214217 return -0x01;
215218 }
216219
217220 if( 4 == pt_host->h_length )
218221 { memcpy( &(p_hvcon->ssh.t_sin.sin_addr), pt_host->h_addr_list[0], pt_host->h_length ); }
219222 else {
220- return -0x01;
223+ ErrInfo_Warn( "Invalid IP addr. length",
224+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
225+ errno, (int)pt_host->h_length, 0x00, pt_ssh->str_hostfqdn );
226+ return -0x02;
221227 }
222228 }
223229
224230 i_err = connect( p_hvcon->ssh.i_sock, (struct sockaddr *)&(p_hvcon->ssh.t_sin),
225231 sizeof( struct sockaddr_in));
226232 if( 0x00 != i_err ) {
227- return -0x02;
233+ ErrInfo_Warn( "Failed connect() for SSH server",
234+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
235+ errno, i_err, 0x00, pt_ssh->str_hostfqdn );
236+ return -0x03;
228237 }
229238
230239 p_hvcon->ssh.pt_session = libssh2_session_init();
231240 if( NULL == p_hvcon->ssh.pt_session ) {
232- return -0x03;
241+ ErrInfo_Warn( "Failed libssh2_session_init() for SSH server",
242+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
243+ errno, 0x00, 0x00, pt_ssh->str_hostfqdn );
244+ return -0x04;
233245 }
234246
235247 libssh2_session_set_blocking( p_hvcon->ssh.pt_session, 0x00 );
@@ -238,7 +250,10 @@ int
238250 == (i_err = libssh2_session_handshake(
239251 p_hvcon->ssh.pt_session, p_hvcon->ssh.i_sock)));
240252 if( 0x00 != i_err ) {
241- return -0x04;
253+ ErrInfo_Warn( "Failed libssh2_session_handshake() for SSH server",
254+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
255+ errno, i_err, 0x00, pt_ssh->str_hostfqdn );
256+ return -0x05;
242257 }
243258
244259 if( pt_ssh->b_sshtype & HVISOR_SSH_AUTH_PASSWD ) {
@@ -278,11 +293,17 @@ int
278293 pt_ssh->str_hostfqdn )));
279294 }
280295 else {
281- return -0x05;
296+ ErrInfo_Warn( "Invalid SSH connection type",
297+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
298+ 0x00, (int)pt_ssh->b_sshtype, 0x00, pt_ssh->str_hostfqdn );
299+ return -0x06;
282300 }
283301
284302 if( 0x00 != i_err ) {
285- return -0x6;
303+ ErrInfo_Warn( "Failed SSH authentication",
304+ p_hvcon->i_id, GUEST_ID_NONE, REQUEST_ID_NONE,
305+ 0x00, (int)pt_ssh->b_sshtype, 0x00, pt_ssh->str_hostfqdn );
306+ return -0x7;
286307 }
287308
288309 return 0x00;