Tagging the 0.74.3.4 release of the kitty project.

This commit is contained in:
cyd01
2020-12-02 19:46:26 +01:00
parent 2d0a377626
commit 1c3398cbb7
11 changed files with 201 additions and 177 deletions
+31 -15
View File
@@ -739,6 +739,8 @@ int RunSession( HWND hwnd, const char * folder_in, char * session_in ) ;
extern char ** FolderList ;
static char * selectedsession = NULL ;
extern char CurrentFolder[1024] ;
union control * ctrlSessionList = NULL ;
union control * ctrlSessionEdit = NULL ;
@@ -851,6 +853,11 @@ static bool load_selected_session(
char sessionname[1024] ;
int j;
dlg_listbox_gettext(ctrlSessionList, dlg, i, sessionname, 1024 ) ;
if( selectedsession!=NULL ) { free(selectedsession); }
selectedsession = (char*)malloc(strlen(sessionname)+1);
strcpy(selectedsession,sessionname);
for( j=0; j<ssd->sesslist.nsessions; j++ ) {
if( !strcmp( ssd->sesslist.sessions[j], sessionname ) ) i = j ;
}
@@ -1032,7 +1039,12 @@ void filter_session_portable(union control *ctrl, dlgparam *dlg, const int nb, c
tabb[i] = false ;
}
for( i=0 ; i<nb ; i++ ) { if( s[i] != NULL ) { dlg_listbox_add(ctrl, dlg, s[i]) ; } }
for( i=0 ; i<nb ; i++ ) {
if( s[i] != NULL ) {
dlg_listbox_add(ctrl, dlg, s[i]) ;
if( !strcmp(s[i],selectedsession) ) { dlg_listbox_select(ctrl, dlg, i); }
}
}
// cleaning
for( i=0 ; i<nb ; i++ ) { if( s[i] != NULL ) { free(s[i]) ; } }
free(tabb);
@@ -1051,6 +1063,7 @@ static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
if (ctrl == ssd->editbox) {
#ifdef MOD_PERSO
ctrlSessionEdit = ctrl ;
if( selectedsession==NULL ) { selectedsession=(char*)malloc(1);strcpy(selectedsession,""); }
#endif
dlg_editbox_set(ctrl, dlg, ssd->savedsession);
} else if (ctrl == ssd->listbox) {
@@ -1061,11 +1074,12 @@ static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
if( ssd->savedsession!=NULL ) strcpy( ssd->savedsession, dlg_editbox_get( ssd->editbox, dlg ) ) ;
ctrlSessionList = ctrl ;
//if(get_param("INIFILE")==SAVEMODE_DIR) CleanFolderName( CurrentFolder ) ;
int j;
if( get_param("INIFILE")==SAVEMODE_DIR ) {
filter_session_portable(ctrl, dlg, ssd->sesslist.nsessions,ssd->sesslist.sessions, ssd->savedsession, CurrentFolder ) ;
}
else
for (i = 0; i < ssd->sesslist.nsessions; i++) {
for (i = 0, j=0; i < ssd->sesslist.nsessions; i++) {
char folder[1024] ;
strcpy( folder, "" ) ;
if( (get_param("INIFILE")==SAVEMODE_REG) || ((get_param("INIFILE")==SAVEMODE_DIR) && !GetDirectoryBrowseFlag()) ) { // Registry mode
@@ -1087,14 +1101,17 @@ static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
|| ( filter_sessionname( "comment:", ssd->sesslist.sessions[i], folder, ssd->savedsession ) )
|| ( filter_sessionname( "title:", ssd->sesslist.sessions[i], folder, ssd->savedsession ) )
|| ( filter_sessionname( "class:", ssd->sesslist.sessions[i], folder, ssd->savedsession ) )
|| ( stristr(ssd->sesslist.sessions[i],ssd->savedsession)!=NULL) )
|| ( stristr(ssd->sesslist.sessions[i],ssd->savedsession)!=NULL) ) {
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]) ;
if( !strcmp(ssd->sesslist.sessions[i],selectedsession) ) { dlg_listbox_select(ctrl, dlg, j); }
j++;
}
}
}
}
dlg_update_done(ctrl, dlg);
if( get_param("INIFILE")==SAVEMODE_DIR ) { dlg_listbox_select(ctrl, dlg,1) ; }
//if( get_param("INIFILE")!=SAVEMODE_DIR ) { dlg_listbox_select(ctrl,dlg,0) ; }
#else
for (i = 0; i < ssd->sesslist.nsessions; i++)
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
@@ -1139,24 +1156,23 @@ static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
* contains a hostname.
*/
#ifdef MOD_PERSO
if (load_selected_session(ssd, dlg, conf, &mbl) &&
(mbl && ctrl == ssd->listbox && conf_launchable(conf))) {
if (load_selected_session(ssd, dlg, conf, &mbl) &&
(mbl && ctrl == ssd->listbox && conf_launchable(conf))) {
if( conf_get_int(conf, CONF_protocol) != PROT_SERIAL ) {
char buffer[1024] ;
strcpy( buffer, conf_get_str( conf, CONF_password) ) ;
MASKPASS( GetCryptSaltFlag(), buffer ) ;
conf_set_str( conf, CONF_password, buffer ) ;
memset( buffer, 0, strlen(buffer) ) ;
}
}
if( GetDblClickFlag()==1 ) {
sessionsaver_handler( ssd->startbutton, dlg, data, EVENT_ACTION ) ;
sessionsaver_handler( ssd->clearbutton, dlg, data, EVENT_ACTION ) ;
sessionsaver_handler( ctrlSessionList, dlg, data, EVENT_REFRESH ) ;
}
else
dlg_end(dlg, 1); /* it's all over, and succeeded */
}
if( conf_get_int(conf, CONF_protocol) != PROT_SERIAL ) {
sessionsaver_handler( ssd->startbutton, dlg, data, EVENT_ACTION ) ;
sessionsaver_handler( ssd->clearbutton, dlg, data, EVENT_ACTION ) ;
sessionsaver_handler( ctrlSessionList, dlg, data, EVENT_REFRESH ) ;
} else
dlg_end(dlg, 1); /* it's all over, and succeeded */
}
if( conf_get_int(conf, CONF_protocol) != PROT_SERIAL ) {
char buffer[1024] ;
strcpy( buffer, conf_get_str( conf, CONF_password) ) ;
MASKPASS( GetCryptSaltFlag(), buffer ) ;
+1 -1
View File
@@ -8,7 +8,7 @@
#ifdef MOD_PERSO
void SetUsernameInConfig( char * username ) ;
void SetUsernameInConfig( const char * username ) ;
char * ManagePassPhrase( const char * st ) ;
void SetPasswordInConfig( const char * password ) ;
void GetPasswordInConfig( char * p ) ;
+25 -11
View File
@@ -29,6 +29,7 @@ void SetSSHConnected( int flag );
size_t iso8859_1_to_utf8(char *content, size_t max_size) ; // Latin-1 = iso8859-1
size_t utf8_to_iso8859_15(char *const output, const char *const input, const size_t length) ; // Latin-9 = iso8859-15
char bufpass[1024]="";
int auth_loop_num = 0 ;
#endif
struct ssh2_userauth_state {
@@ -262,7 +263,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
PktIn *pktin;
#ifdef MOD_RECONNECT
SetSSHConnected(1);
SetSSHConnected(0);
#endif
ssh2_userauth_filter_queue(s); /* no matter why we were called */
@@ -1392,7 +1393,6 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
s->cur_prompt->name_reqd = false;
}
s->cur_prompt->name = strbuf_to_str(sb);
sb = strbuf_new();
if (inst.len) {
if (s->ki_scc) {
@@ -1412,20 +1412,24 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
s->cur_prompt->instruction = strbuf_to_str(sb);
else
strbuf_free(sb);
/*
* Our prompts_t is fully constructed now. Get the
* user's response(s).
*/
#ifdef MOD_PERSO
if( IsPasswordInConf() ) {
auth_loop_num++ ;
//char b[128];sprintf(b,"%d",auth_loop_num);MessageBox(NULL,b,"info",MB_OK);
if( debug_flag && !IsPasswordInConf() ) { debug_logevent( "No password in configuration" ) ; }
if( (auth_loop_num==1) && IsPasswordInConf() ) {
GetPasswordInConfig(bufpass) ;
while( ((bufpass[strlen(bufpass)-1]=='n')&&(bufpass[strlen(bufpass)-2]=='\\')) || ((bufpass[strlen(bufpass)-1]=='r')&&(bufpass[strlen(bufpass)-2]=='\\')) ) {
bufpass[strlen(bufpass)-2]='\0';
bufpass[strlen(bufpass)-1]='\0';
}
iso8859_1_to_utf8( bufpass, 1024 );
if( debug_flag ) { debug_logevent( "Raw password: %s", bufpass ) ; }
iso8859_1_to_utf8( bufpass, 1024 ) ;
if( debug_flag ) { debug_logevent( "UTF-8 password: %s", bufpass ) ; }
bufchain bc;
bufchain_init(&bc);
bufchain_add(&bc, bufpass, strlen(bufpass));
@@ -1450,7 +1454,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
s->userpass_ret = seat_get_userpass_input(
s->ppl.seat, s->cur_prompt, NULL);
#ifdef MOD_PERSO
if( !IsPasswordInConf() )
if( (auth_loop_num!=1) || !IsPasswordInConf() )
#endif
while (1) {
while (s->userpass_ret < 0 &&
@@ -1487,10 +1491,14 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
for (uint32_t i = 0; i < s->num_prompts; i++) {
#ifdef MOD_PERSO
ppl_logevent("Sent a password");
if(!GetUserPassSSHNoSave()) {
if( (auth_loop_num==1) && !GetUserPassSSHNoSave() ) {
if(s!=NULL)
if(s->cur_prompt->prompts!=NULL)
if(s->cur_prompt->prompts[i]->result!=NULL) {SetPasswordInConfig( (const char *) s->cur_prompt->prompts[i]->result ) ; }
if(s->cur_prompt->prompts[i]->result!=NULL) {
ppl_logevent("Save a password");
//SetPasswordInConfig( (const char *) s->cur_prompt->prompts[i]->result ) ;
SetPasswordInConfig( (const char *) prompt_get_result_ref(s->cur_prompt->prompts[i]) ) ;
}
}
#endif
put_stringz(s->pktout, prompt_get_result_ref(
@@ -1522,7 +1530,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
ssh2_userauth_antispoof_msg(
s, "End of keyboard-interactive prompts from server");
}
/*
* We should have SUCCESS or FAILURE now.
*/
@@ -1599,6 +1607,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
put_stringz(s->pktout, "password");
put_bool(s->pktout, false);
#ifdef MOD_PERSO
if( debug_flag && !IsPasswordInConf() ) { debug_logevent( "No password in configuration" ) ; }
if( IsPasswordInConf() ) {
GetPasswordInConfig(bufpass);
while( ((bufpass[strlen(bufpass)-1]=='n')&&(bufpass[strlen(bufpass)-2]=='\\')) || ((bufpass[strlen(bufpass)-1]=='r')&&(bufpass[strlen(bufpass)-2]=='\\')) ) {
@@ -1607,7 +1616,9 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
}
char bufpass2[1024];
strcpy(bufpass2,bufpass);
if( debug_flag ) { debug_logevent( "Raw password: %s", bufpass2 ) ; }
iso8859_1_to_utf8( bufpass2, 1024 );
if( debug_flag ) { debug_logevent( "UTF-8 password: %s", bufpass2 ) ; }
put_stringz(s->pktout, bufpass2);
memset(bufpass2,0,1024);
@@ -1641,11 +1652,13 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
#ifdef MOD_PERSO
if( !GetUserPassSSHNoSave() ) {
if( strlen(bufpass)>0 ) {
ppl_logevent("Save password");
SetPasswordInConfig( bufpass ) ;
memset( bufpass, 0, strlen(bufpass) ) ;
} else if( s != NULL ) {
if( s->password != NULL ) {
char bufpass2[1024] ;
ppl_logevent("Save the password");
utf8_to_iso8859_15( bufpass2, s->password, 1024 ) ;
SetPasswordInConfig( bufpass2 ) ;
memset(bufpass2,0,1024) ;
@@ -1837,7 +1850,8 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
userauth_success:
#ifdef MOD_PERSO
SetSSHConnected(1) ;
SetSSHConnected(1) ;
auth_loop_num=0;
#endif
/*
* We've just received USERAUTH_SUCCESS, and we haven't sent
+1 -1
View File
@@ -1,5 +1,5 @@
#define RELEASE 0.74
#define TEXTVER "Release 0.74"
#define SSHVER "-Release-0.74"
#define BINARY_VERSION 0,74,3,3
#define BINARY_VERSION 0,74,3,4
#define SOURCE_COMMIT "unavailable"
+1 -1
View File
@@ -1 +1 @@
3
4
+26 -17
View File
@@ -256,6 +256,7 @@ void SaveDump( void ) ;
#include "../../kitty_tools.h"
#include "../../kitty_win.h"
extern int PuttyFlag ;
extern char BuildVersionTime[256] ;
void SendStrToTerminal( const char * str, const int len ) {
char c ;
int i ;
@@ -678,15 +679,15 @@ static void close_session(void *ignored_context)
#ifdef MOD_RECONNECT
void RestartSession( void ) {
if( backend ) { queue_toplevel_callback(close_session, NULL) ; backend = NULL ; }
if( backend ) { SetSSHConnected(0) ; queue_toplevel_callback(close_session, NULL) ; backend = NULL ; }
if( GetAutoreconnectFlag() ) {
lp_eventlog(default_logpolicy, "User request session restart..." ) ;
} else {
win_seat_connection_fatal( win_seat, "User request session restart..." ) ;
SetTimer(hwnd, TIMER_RECONNECT, 10, NULL) ;
}
PostMessage(hwnd,WM_KEYDOWN,VK_RETURN ,0) ;
//is_backend_first_connected = 0 ;
PostMessage(hwnd,WM_KEYUP,VK_RETURN ,1) ;
}
#endif
@@ -743,11 +744,11 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
set_cmd_line( cmdline ) ;
SethInstIcons( hinst ) ;
InitWinMain();
if( debug_flag ) {
char * buf = (char*)malloc( strlen(cmdline)+20 ) ;
sprintf( buf, "Command-line: %s", cmdline ) ;
lp_eventlog(default_logpolicy, buf) ;
free(buf);
if( debug_flag ) {
if( IniFileFlag == SAVEMODE_REG ) { debug_logevent( "Save mode is set to registry (classic)" ) ; }
if( IniFileFlag == SAVEMODE_DIR ) { debug_logevent( "Save mode is set to directory (portable)" ) ; }
debug_logevent( "Command-line: %s", cmdline ) ;
debug_logevent( "Version: %s", BuildVersionTime ) ;
}
#endif
#ifdef MOD_NOTRANSPARENCY
@@ -1238,6 +1239,13 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
}
#ifdef MOD_PERSO
if( debug_flag ) {
if( strlen(conf_get_str(conf,CONF_sessionname))>0 ) {
debug_logevent( "Session name: %s", conf_get_str(conf,CONF_sessionname) ) ;
} else {
debug_logevent( "Session name: -" ) ;
}
}
HICON icon_m ;
if( GetIconeFlag() > 0 )
icon_m = LoadIcon( GethInstIcons(), MAKEINTRESOURCE(IDI_MAINICON_0 + GetIconeNum() ) );
@@ -1617,17 +1625,17 @@ TrayIcone.hWnd = hwnd ;
ScriptFileContent = NULL ;
ReadInitScript( NULL ) ;
// Lancement du serveur de chat
static char reg_buffer[4096];
if( ReadParameter( INIT_SECTION, "chat", reg_buffer ) )
{
// Lancement du serveur de chat
if( ReadParameter( INIT_SECTION, "chat", reg_buffer ) ) {
int chat_flag = atoi( reg_buffer ) ;
if ( chat_flag > 0 ) {
//if( chat_flag != 1 ) PORT = chat_flag ;
_beginthread( routine_server, 0, NULL ) ;
}
}
}
// Parametrage specifique a la session
if( GetSessionField( conf_get_str(conf,CONF_sessionname), conf_get_str(conf,CONF_folder), "InitDelay", reg_buffer ) ) {
if( init_delay != (int)(1000*atof( reg_buffer ) ) ) {
@@ -2135,10 +2143,8 @@ static void win_seat_connection_fatal(Seat *seat, const char *msg)
session_closed = true;
ReadInitScript(NULL);
char *title = dupprintf("%s Fatal Error: %s", appname,msg);
debug_logevent( "%s Fatal Error: %s", appname,msg ) ;
show_mouseptr(true);
lp_eventlog(default_logpolicy, title);//MessageBox(hwnd, msg, title, MB_ICONERROR | MB_OK);
sfree(title);
if( conf_get_int(conf,CONF_failure_reconnect) ) {
queue_toplevel_callback(close_session, NULL);
@@ -3338,7 +3344,9 @@ else if((UINT_PTR)wParam == TIMER_INIT) { // Initialisation
free( LoadFile ) ;
LoadFile = NULL ;
}
if( debug_flag ) { debug_logevent( "Starting post connection operations" ) ; }
if( (conf_get_int(conf,CONF_protocol) == PROT_SSH) && (!is_backend_connected) ) break ; // On sort si en SSH on n'est pas connecte
// Lancement d'une (ou plusieurs separees par \\n) commande(s) automatique(s) a l'initialisation
@@ -3390,6 +3398,7 @@ else if((UINT_PTR)wParam == TIMER_INIT) { // Initialisation
// On envoie l'autocommand
if( strlen( conf_get_str(conf,CONF_autocommand) ) > 0 ) {
lp_eventlog(default_logpolicy, "Start autocommand timer" );
SetTimer(hwnd, TIMER_AUTOCOMMAND, autocommand_delay, NULL) ;
}
if( conf_get_int(conf,CONF_logtimerotation) > 0 ) {
@@ -3536,7 +3545,7 @@ else if((UINT_PTR)wParam == TIMER_LOGROTATION) { // log rotation
{
// Initialiation
MainHwnd = hwnd ;
if( debug_flag ) lp_eventlog(default_logpolicy,"Init");
if( debug_flag ) { lp_eventlog(default_logpolicy,"Starting window creation") ; }
if( GetIconeFlag() != -1 )
SetNewIcon( hwnd, conf_get_filename(conf,CONF_iconefile)->path, conf_get_int(conf,CONF_icone), SI_INIT ) ;
+1 -1
View File
@@ -2,7 +2,7 @@
## Welcome to the KiTTY introduction web site
### What is KiTTY ?
**KiTTY** is a fork from version 0.71 of **PuTTY**, the best telnet / SSH client in the world.
**KiTTY** is a fork from version 0.74 of **PuTTY**, the best telnet / SSH client in the world.
KiTTY is only designed for the Microsoft® Windows® platform. For more information about the original software, or pre-compiled binaries on other systems, you can go to the [Simon Tatham PuTTY page](http://www.chiark.greenend.org.uk/~sgtatham/putty/ "PuTTY").
KiTTY has all the features from the original software, and adds many others as decribed in this website (see menu above).
-2
View File
@@ -22,7 +22,6 @@
* [Automatic command](pages/AutomaticCommand.md)
* [Force CR/LF on enter key](pages/ForceCRLF.md)
* [Running a locally saved script on a remote session](pages/LocalScript.md)
* [ZModem integration](pages/ZModem.md)
[Graphical]()
@@ -43,7 +42,6 @@
* [Binary compression](pages/BinaryCompression.md)
* [Clipboard printing](pages/ClipboardPrinting.md)
* [Start Cygwin or cmd.exe into KiTTY](pages/cygtermd.md)
* [Background image](pages/covidimus.md)
* [File association](pages/FileAssociation.md)
* [Other settings](pages/OtherSettings.md)
* [Menu key shortcuts definition](pages/MenuShortcuts.md)
+1 -1
View File
@@ -30,7 +30,7 @@ You can also get virus analysis from our official CDN [fosshub.com](https://www.
## Third-part softwares that work with KiTTY
* [KiTTY session manager](https://www.noobunbox.net/projects/kitty-session-manager "KiTTY session manager")
* [PuTTY tab manager](https://sites.google.com/site/macdsite/utilidades/puttytabmanager "PuTTY tab manager")
* [PuTTY tab manager](https://sites.google.com/site/macdsite/puttytabmanager "PuTTY tab manager")
## KiTTY source code
* The KiTTY source code is available from
+1 -1
View File
@@ -1 +1 @@
0.74.3.3
0.74.3.4
+113 -126
View File
@@ -1564,7 +1564,7 @@ void DelRegistryKey( void ) {
//extern int PORT ; int main_m1( void ) ;
//void routine_server( void * st ) { main_m1() ; }
typedef void (CALLBACK* LPFNDLLFUNC1)( void ) ;
void routine_server( void * st ) {
HMODULE lphDLL ; // Handle to DLL
@@ -2368,13 +2368,13 @@ void GetOneFile( HWND hwnd, char * directory, const char * filename ) {
chdir( InitialDirectory ) ;
if( debug_flag ) { debug_logevent( "Run: %s", buffer) ; }
if( debug_flag ) { debug_logevent( "Get on file: %s", buffer) ; }
if( system( buffer ) ) MessageBox( NULL, buffer, "Transfer problem", MB_OK|MB_ICONERROR ) ;
//debug_log("%s\n",buffer);//MessageBox( NULL, buffer, "Info",MB_OK );
memset(buffer,0,strlen(buffer));
}
}
// Reception d'un fichier par SCP
void GetFile( HWND hwnd ) {
@@ -2385,16 +2385,16 @@ void GetFile( HWND hwnd ) {
if( conf_get_int(conf,CONF_protocol) != PROT_SSH ) {
MessageBox( hwnd, "This function is only available with SSH connections.", "Error", MB_OK|MB_ICONERROR ) ;
return ;
}
}
if( PSCPPath==NULL ) {
if( IniFileFlag == SAVEMODE_REG ) return ;
else if( !SearchPSCP() ) return ;
}
}
if( !existfile( PSCPPath ) ) {
if( IniFileFlag == SAVEMODE_REG ) return ;
else if( !SearchPSCP() ) return ;
}
}
if( !GetShortPathName( PSCPPath, pscppath, 4095 ) ) return ;
@@ -2410,88 +2410,88 @@ void GetFile( HWND hwnd ) {
//sprintf(buffer,"#%s#%d",pst,strlen(pst));MessageBox(hwnd,buffer,"Info",MB_OK);
strcpy( buffer, "" ) ;
if( strlen( pst ) > 0 ) {
if( ReadParameter( INIT_SECTION, "downloaddir", dir ) ) {
if( !existdirectory( dir ) )
strcpy( dir, InitialDirectory ) ;
if( ReadParameter( INIT_SECTION, "downloaddir", dir ) ) {
if( !existdirectory( dir ) )
strcpy( dir, InitialDirectory ) ;
} else if( OpenDirName( hwnd, dir ) ) {
if( !existdirectory( dir ) ) { GlobalUnlock( hglb ) ; CloseClipboard(); return ; }
//strcpy( dir, InitialDirectory ) ;
} else {
return ;
}
else if( OpenDirName( hwnd, dir ) ) {
if( !existdirectory( dir ) ) { GlobalUnlock( hglb ) ; CloseClipboard(); return ; }
//strcpy( dir, InitialDirectory ) ;
}
else { return ; }
//else { strcpy( dir, InitialDirectory ) ; }
//else { strcpy( dir, InitialDirectory ) ; }
sprintf( buffer, "start %s ", pscppath ) ;
if( strlen(conf_get_str(conf, CONF_pscpoptions))>0 ) {
strcat( buffer, conf_get_str(conf, CONF_pscpoptions) ) ; strcat( buffer, " " ) ;
}
if( conf_get_int(conf, CONF_winscpprot)==0 ) { strcat( buffer, "-scp " ) ; }
else { strcat( buffer, "-sftp " ) ; }
if( conf_get_int(conf,CONF_sshprot) == 3 ) { // SSH-2 Only (voir putty.h)
strcat( buffer, "-2 " ) ;
}
if( ReadParameter( INIT_SECTION, "pscpport", pscpport ) ) {
pscpport[17]='\0';
if( !strcmp( pscpport,"*" ) ) sprintf( pscpport, "%d", conf_get_int(conf,CONF_port) ) ;
strcat( buffer, "-P " ) ;
strcat( buffer, pscpport ) ;
strcat( buffer, " " ) ;
} else {
if( (p=poss(":",conf_get_str(conf, CONF_sftpconnect) )) > 0 ) {
sprintf( b1, "-P %d ", atoi(conf_get_str(conf, CONF_sftpconnect)+p) ) ;
sprintf( buffer, "start %s ", pscppath ) ;
if( strlen(conf_get_str(conf, CONF_pscpoptions))>0 ) {
strcat( buffer, conf_get_str(conf, CONF_pscpoptions) ) ; strcat( buffer, " " ) ;
}
if( conf_get_int(conf, CONF_winscpprot)==0 ) {
strcat( buffer, "-scp " ) ;
} else {
strcat( buffer, "-sftp " ) ;
}
if( conf_get_int(conf,CONF_sshprot) == 3 ) { // SSH-2 Only (voir putty.h)
strcat( buffer, "-2 " ) ;
}
if( ReadParameter( INIT_SECTION, "pscpport", pscpport ) ) {
pscpport[17]='\0';
if( !strcmp( pscpport,"*" ) ) sprintf( pscpport, "%d", conf_get_int(conf,CONF_port) ) ;
strcat( buffer, "-P " ) ;
strcat( buffer, pscpport ) ;
strcat( buffer, " " ) ;
} else {
sprintf( b1, "-P %d ", conf_get_int(conf, CONF_port) ) ;
if( (p=poss(":",conf_get_str(conf, CONF_sftpconnect) )) > 0 ) {
sprintf( b1, "-P %d ", atoi(conf_get_str(conf, CONF_sftpconnect)+p) ) ;
} else {
sprintf( b1, "-P %d ", conf_get_int(conf, CONF_port) ) ;
}
strcat( buffer, b1 ) ;
}
strcat( buffer, b1 ) ;
}
if( strlen( conf_get_str(conf,CONF_password) ) > 0 ) {
strcat( buffer, "-pw \"" ) ;
char bufpass[1024] ;
strcpy( bufpass, conf_get_str(conf,CONF_password) ) ;
MASKPASS(GetCryptSaltFlag(),bufpass); strcat( buffer, bufpass ) ; memset(bufpass,0,strlen(bufpass));
strcat( buffer, "\" " ) ;
if( strlen( conf_get_str(conf,CONF_password) ) > 0 ) {
strcat( buffer, "-pw \"" ) ;
char bufpass[1024] ;
strcpy( bufpass, conf_get_str(conf,CONF_password) ) ;
MASKPASS(GetCryptSaltFlag(),bufpass); strcat( buffer, bufpass ) ; memset(bufpass,0,strlen(bufpass));
strcat( buffer, "\" " ) ;
}
if( strlen( conf_get_filename(conf,CONF_keyfile)->path ) > 0 ) {
strcat( buffer, "-i \"" ) ;
strcat( buffer, conf_get_filename(conf,CONF_keyfile)->path ) ;
strcat( buffer, "\" " ) ;
if( strlen( conf_get_filename(conf,CONF_keyfile)->path ) > 0 ) {
strcat( buffer, "-i \"" ) ;
strcat( buffer, conf_get_filename(conf,CONF_keyfile)->path ) ;
strcat( buffer, "\" " ) ;
}
if( strlen( conf_get_str(conf, CONF_sftpconnect) ) > 0 ) {
strcpy( b1, conf_get_str(conf, CONF_sftpconnect) ) ;
if( (p=poss(":",b1)) > 0 ) { b1[p-1]='\0'; }
strcat( buffer, b1 ) ;
} else {
strcat( buffer, conf_get_str(conf,CONF_username) ) ; strcat( buffer, "@" ) ;
if( poss( ":", conf_get_str(conf,CONF_host))>0 ) { strcat( buffer, "[" ) ; strcat( buffer, conf_get_str(conf,CONF_host) ) ; strcat( buffer, "]" ) ; }
else { strcat( buffer, conf_get_str(conf,CONF_host) ) ; }
}
strcat( buffer, ":" ) ;
strcat( buffer, pst ) ; strcat( buffer, " \"" ) ;
strcat( buffer, dir ) ; strcat( buffer, "\"" ) ;
if( strlen( conf_get_str(conf, CONF_sftpconnect) ) > 0 ) {
strcpy( b1, conf_get_str(conf, CONF_sftpconnect) ) ;
if( (p=poss(":",b1)) > 0 ) { b1[p-1]='\0'; }
strcat( buffer, b1 ) ;
} else {
strcat( buffer, conf_get_str(conf,CONF_username) ) ; strcat( buffer, "@" ) ;
if( poss( ":", conf_get_str(conf,CONF_host))>0 ) {
strcat( buffer, "[" ) ; strcat( buffer, conf_get_str(conf,CONF_host) ) ; strcat( buffer, "]" ) ;
} else {
strcat( buffer, conf_get_str(conf,CONF_host) ) ;
}
}
strcat( buffer, ":" ) ;
strcat( buffer, pst ) ; strcat( buffer, " \"" ) ;
strcat( buffer, dir ) ; strcat( buffer, "\"" ) ;
}
GlobalUnlock( hglb ) ;
}
}
CloseClipboard();
}
CloseClipboard();
}
if( strlen( buffer ) > 0 ) {
chdir( InitialDirectory ) ;
if( debug_flag ) { debug_logevent("Run: %s", buffer) ; }
if( debug_flag ) { debug_logevent("Get file: %s", buffer) ; }
if( system( buffer ) ) MessageBox( NULL, buffer, "Transfer problem", MB_OK|MB_ICONERROR ) ;
//if( !system( buffer ) ) unlink( "kitty.log" ) ;
}
}
}
// Lancement d'un commande locale (Lancement Internet Explorer par exemple)
void RunCmd( HWND hwnd ) {
char buffer[4096]="", * pst = NULL ;
if (!IsClipboardFormatAvailable(CF_TEXT)) return ;
if( OpenClipboard(NULL) ) {
HGLOBAL hglb ;
@@ -2499,12 +2499,10 @@ void RunCmd( HWND hwnd ) {
if( ( pst = GlobalLock( hglb ) ) != NULL ) {
sprintf( buffer, "%s", pst ) ;
GlobalUnlock( hglb ) ;
}
}
CloseClipboard();
}
CloseClipboard();
}
if( strlen( buffer ) > 0 ) {
chdir( InitialDirectory ) ;
//system( buffer ) ;
@@ -2515,9 +2513,9 @@ void RunCmd( HWND hwnd ) {
ZeroMemory( &pi, sizeof(pi) );
if( !CreateProcess(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) ) {
ShellExecute(hwnd, "open", buffer,0, 0, SW_SHOWDEFAULT);
}
}
}
}
// Gestion de commandes a distance
static char * RemotePath = NULL ;
@@ -2571,7 +2569,7 @@ dt() { printf "\033]0;__dt:"$(hostname)":"${USER}":"`pwd`"\007" ; }
*/
int ManageLocalCmd( HWND hwnd, const char * cmd ) {
char buffer[1024] = "", title[1024] = "" ;
if( debug_flag ) { debug_logevent( "LocalCmd: %s", cmd ) ; }
if( debug_flag ) { debug_logevent( "Local command: %s", cmd ) ; }
if( cmd == NULL ) return 0 ;
if( (cmd[2] != ':')&&(cmd[2] != '\0') ) return 0 ;
if( (cmd[2] == ':')&&( strlen( cmd ) <= 3 ) ) return 0 ;
@@ -2580,35 +2578,28 @@ int ManageLocalCmd( HWND hwnd, const char * cmd ) {
RemotePath = (char*) malloc( strlen( cmd ) - 2 ) ;
strcpy( RemotePath, cmd+3 ) ;
return 1 ;
}
else if( (cmd[0]=='r')&&(cmd[1]=='v')&&(cmd[2]==':') ) { // __rv: Reception d'un fichiers
} else if( (cmd[0]=='r')&&(cmd[1]=='v')&&(cmd[2]==':') ) { // __rv: Reception d'un fichiers
GetOneFile( hwnd, RemotePath, cmd+3 ) ;
return 1 ;
}
else if( (cmd[0]=='p')&&(cmd[1]=='l')&&(cmd[2]==':') ) { // __pl: Lance une commande plink
} else if( (cmd[0]=='p')&&(cmd[1]=='l')&&(cmd[2]==':') ) { // __pl: Lance une commande plink
RunExternPlink( hwnd, cmd+3 ) ;
return 1 ;
}
else if( (cmd[0]=='t')&&(cmd[1]=='i')&&(cmd[2]=='\0') ) { // __ti: Recuperation du titre de la fenetres
} else if( (cmd[0]=='t')&&(cmd[1]=='i')&&(cmd[2]=='\0') ) { // __ti: Recuperation du titre de la fenetres
GetWindowText( hwnd, buffer, 1024 ) ;
sprintf( title, "printf \"\\033]0;%s\\007\"\n", buffer ) ;
SendStrToTerminal( title, strlen(title) ) ;
return 1 ;
}
else if( (cmd[0]=='i')&&(cmd[1]=='n')&&(cmd[2]==':') ) { // __in: Affiche d'information dans le log
} else if( (cmd[0]=='i')&&(cmd[1]=='n')&&(cmd[2]==':') ) { // __in: Affiche d'information dans le log
debug_logevent(cmd+3) ;
return 1 ;
}
else if( (cmd[0]=='w')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ws: Lance WinSCP dans un repertoire donne
} else if( (cmd[0]=='w')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ws: Lance WinSCP dans un repertoire donne
if( RemotePath!= NULL ) free( RemotePath ) ;
RemotePath = (char*) malloc( strlen( cmd ) - 2 ) ;
strcpy( RemotePath, cmd+3 ) ;
StartWinSCP( hwnd, RemotePath, NULL, NULL ) ;
// free( RemotePath ) ; RemotePath = NULL ;
return 1 ;
}
else if( (cmd[0]=='w')&&(cmd[1]=='t')&&(cmd[2]==':') ) { // __wt: Lance WinSCP dans sur un host et un user donné et dans un repertoire donné
} else if( (cmd[0]=='w')&&(cmd[1]=='t')&&(cmd[2]==':') ) { // __wt: Lance WinSCP dans sur un host et un user donné et dans un repertoire donné
char host[1024]="";char user[256]="";
int i;
if( RemotePath!= NULL ) free( RemotePath ) ;
@@ -2622,22 +2613,19 @@ int ManageLocalCmd( HWND hwnd, const char * cmd ) {
StartWinSCP( hwnd, RemotePath, host, user ) ;
// free( RemotePath ) ; RemotePath = NULL ;
return 1 ;
}
else if( (cmd[0]=='i')&&(cmd[1]=='e')&&(cmd[2]==':') ) { // __ie: Lance un navigateur sur le lien
} else if( (cmd[0]=='i')&&(cmd[1]=='e')&&(cmd[2]==':') ) { // __ie: Lance un navigateur sur le lien
if( strlen(cmd+3)>0 ) {
urlhack_launch_url(!conf_get_int(conf,CONF_url_defbrowser)?conf_get_filename(conf,CONF_url_browser)->path:NULL, (const char *)(cmd+3));
return 1;
}
}
else if( (cmd[0]=='d')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ds: Lance une session dupliquee dans le meme repertoire ds() { printf "\033]0;__ds:`pwd`\007" ; }
} else if( (cmd[0]=='d')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ds: Lance une session dupliquee dans le meme repertoire ds() { printf "\033]0;__ds:`pwd`\007" ; }
if( RemotePath!= NULL ) free( RemotePath ) ;
RemotePath = (char*) malloc( strlen( cmd ) - 2 ) ;
strcpy( RemotePath, cmd+3 ) ;
StartNewSession( hwnd, RemotePath, NULL, NULL ) ;
// free( RemotePath ) ; RemotePath = NULL ;
return 1 ;
}
else if( (cmd[0]=='d')&&(cmd[1]=='t')&&(cmd[2]==':') ) { // __dt: Lance une session dupliquee dans le meme repertoire, meme host, meme user dt() { printf "\033]0;__dt:"$(hostname)":"${USER}":"`pwd`"\007" ; }
} else if( (cmd[0]=='d')&&(cmd[1]=='t')&&(cmd[2]==':') ) { // __dt: Lance une session dupliquee dans le meme repertoire, meme host, meme user dt() { printf "\033]0;__dt:"$(hostname)":"${USER}":"`pwd`"\007" ; }
char host[1024]="";char user[256]="";
int i;
if( RemotePath!= NULL ) free( RemotePath ) ;
@@ -2651,17 +2639,15 @@ int ManageLocalCmd( HWND hwnd, const char * cmd ) {
StartNewSession( hwnd, RemotePath, host, user ) ;
// free( RemotePath ) ; RemotePath = NULL ;
return 1 ;
}
else if( (cmd[0]=='l')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ls: envoie un script sauvegardé localement (comme fait le CTRL+F2)
} else if( (cmd[0]=='l')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ls: envoie un script sauvegardé localement (comme fait le CTRL+F2)
RunScriptFile( hwnd, cmd+3 ) ;
return 1 ;
}
else if( (cmd[0]=='c')&&(cmd[1]=='m')&&(cmd[2]==':') ) { // __cm: Execute une commande externe
} else if( (cmd[0]=='c')&&(cmd[1]=='m')&&(cmd[2]==':') ) { // __cm: Execute une commande externe
RunCommand( hwnd, cmd+3 ) ;
return 1 ;
}
return 0 ;
}
return 0 ;
}
// Recupere les coordonnees de la fenetre
void GetWindowCoord( HWND hwnd ) {
@@ -3779,7 +3765,7 @@ int SearchCtHelper( void ) {
return 1 ;
}
return 0 ;
}
}
// Recherche le chemin vers le programme WinSCP
int SearchWinSCP( void ) {
@@ -3888,7 +3874,7 @@ void StartNewSession( HWND hwnd, char * directory, char * host, char * user ) {
// set_debug_text( cmd ) ;
//MessageBox( hwnd, cmd, "Command",MB_OK);
//debug_log( cmd ) ;
if( debug_flag ) { debug_logevent( "Run: %s", cmd ) ; }
if( debug_flag ) { debug_logevent( "Start a new session: %s", cmd ) ; }
RunCommand( hwnd, cmd ) ;
memset(cmd,0,strlen(cmd));
}
@@ -4031,7 +4017,7 @@ void StartWinSCP( HWND hwnd, char * directory, char * host, char * user ) {
strcat( cmd, " " ) ; strcat( cmd, "Shell=\"" ) ; strcat( cmd, conf_get_str(conf, CONF_pscpshell) ) ; strcat( cmd, "\"" ) ;
}
if( debug_flag ) { debug_logevent( "Run: %s", cmd ) ; }
if( debug_flag ) { debug_logevent( "Start WinSCP: %s", cmd ) ; }
RunCommand( hwnd, cmd ) ;
memset(cmd,0,strlen(cmd));
}
@@ -4046,9 +4032,10 @@ int SearchPSCP( void ) {
if( ReadParameter( INIT_SECTION, "PSCPPath", buffer ) != 0 ) {
if( existfile( buffer ) ) {
PSCPPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PSCPPath, buffer ) ; return 1 ;
}
else { DelParameter( INIT_SECTION, "PSCPPath" ) ; }
} else {
DelParameter( INIT_SECTION, "PSCPPath" ) ;
}
}
// Dans le fichier ini
if( ReadParameter( INIT_SECTION, "pscpdir", buffer ) ) {
@@ -4058,8 +4045,7 @@ int SearchPSCP( void ) {
PSCPPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PSCPPath, buffer ) ;
WriteParameter( INIT_SECTION, "PSCPPath", PSCPPath ) ;
return 1 ;
}
else {
} else {
ReadParameter( INIT_SECTION, "pscpdir", buffer ) ;
buffer[4076]='\0';
strcat( buffer, "\\" ) ; strcat( buffer, pu ) ;
@@ -4067,9 +4053,9 @@ int SearchPSCP( void ) {
PSCPPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PSCPPath, buffer ) ;
WriteParameter( INIT_SECTION, "PSCPPath", PSCPPath ) ;
return 1 ;
}
}
}
}
#ifndef FLJ
// kscp dans le meme repertoire
sprintf( buffer, "%s\\%s", InitialDirectory, ki ) ;
@@ -4077,7 +4063,7 @@ int SearchPSCP( void ) {
PSCPPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PSCPPath, buffer ) ;
WriteParameter( INIT_SECTION, "PSCPPath", PSCPPath ) ;
return 1 ;
}
}
#endif
// pscp dans le repertoire normal de PuTTY
sprintf( buffer, "%s\\PuTTY\\%s", getenv("ProgramFiles"), pu ) ;
@@ -4085,7 +4071,7 @@ int SearchPSCP( void ) {
PSCPPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PSCPPath, buffer ) ;
WriteParameter( INIT_SECTION, "PSCPPath", PSCPPath ) ;
return 1 ;
}
}
// pscp dans le meme repertoire
sprintf( buffer, "%s\\%s", InitialDirectory, pu ) ;
@@ -4093,10 +4079,10 @@ int SearchPSCP( void ) {
PSCPPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PSCPPath, buffer ) ;
WriteParameter( INIT_SECTION, "PSCPPath", PSCPPath ) ;
return 1 ;
}
}
return 0 ;
}
}
// Recherche le chemin vers le programme Plink.exe
int SearchPlink( void ) {
@@ -4108,9 +4094,10 @@ int SearchPlink( void ) {
buffer[4076]='\0';
if( existfile( buffer ) ) {
PlinkPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PlinkPath, buffer ) ; return 1 ;
}
else { DelParameter( INIT_SECTION, "PlinkPath" ) ; }
} else {
DelParameter( INIT_SECTION, "PlinkPath" ) ;
}
}
#ifndef FLJ
// klink dans le meme repertoire
@@ -4119,7 +4106,7 @@ int SearchPlink( void ) {
PlinkPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PlinkPath, buffer ) ;
WriteParameter( INIT_SECTION, "PlinkPath", PlinkPath ) ;
return 1 ;
}
}
#endif
// plink dans le repertoire normal de PuTTY
@@ -4128,7 +4115,7 @@ int SearchPlink( void ) {
PlinkPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PlinkPath, buffer ) ;
WriteParameter( INIT_SECTION, "PlinkPath", PlinkPath ) ;
return 1 ;
}
}
// plink dans le meme repertoire
sprintf( buffer, "%s\\%s", InitialDirectory, pu ) ;
@@ -4136,11 +4123,11 @@ int SearchPlink( void ) {
PlinkPath = (char*) malloc( strlen(buffer) + 1 ) ; strcpy( PlinkPath, buffer ) ;
WriteParameter( INIT_SECTION, "PlinkPath", PlinkPath ) ;
return 1 ;
}
return 0 ;
}
return 0 ;
}
// Gestion du drap and drop
void recupNomFichierDragDrop(HWND hwnd, HDROP* leDrop ) {
HDROP hDropInfo = *leDrop ;
@@ -4175,9 +4162,10 @@ void OnDropFiles(HWND hwnd, HDROP hDropInfo) {
if( conf_get_int(conf,CONF_protocol) != PROT_SSH ) {
MessageBox( hwnd, "This function is only available with SSH connections.", "Error", MB_OK|MB_ICONERROR ) ;
return ;
}
if( conf_get_int( conf, CONF_scp_auto_pwd ) != 1 ) { recupNomFichierDragDrop(hwnd, &hDropInfo) ; }
else {
}
if( conf_get_int( conf, CONF_scp_auto_pwd ) != 1 ) {
recupNomFichierDragDrop(hwnd, &hDropInfo) ;
} else {
if( RemotePath != NULL ) { free( RemotePath ) ; RemotePath = NULL ; }
if( hDropInf != NULL ) { free(hDropInf) ; hDropInf = NULL ; }
char cmd[1024] = "printf \"\\033]0;__pw:%s\\007\" `pwd`\\n" ;
@@ -4187,8 +4175,8 @@ void OnDropFiles(HWND hwnd, HDROP hDropInfo) {
SetTimer(hwnd, TIMER_AUTOCOMMAND, autocommand_delay, NULL) ;
hDropInf = hDropInfo ;
SetTimer(hwnd, TIMER_DND, dnd_delay, NULL) ;
}
}
}
// Appel d'une DLL
@@ -4264,12 +4252,11 @@ void ManageInitScript( const char * input_str, const int len ) {
do {
i++ ;
ScriptFileContent[i]=ScriptFileContent[i+l] ;
}
while( (ScriptFileContent[i]!='\0')||(ScriptFileContent[i-1]!='\0') ) ;
}
} while( (ScriptFileContent[i]!='\0')||(ScriptFileContent[i-1]!='\0') ) ;
}
free( st ) ;
}
}
void ReadAutoCommandFromFile( const char * filename ) {
FILE *fp ;