42
42
#undef GSSAPI
43
43
#undef KRB5
44
44
#define WIN32_USER_AUTH 1
45
+ //#define WIN32_PRAGMA_REMCON
45
46
#endif
46
47
47
48
#include <sys/types.h>
@@ -589,11 +590,20 @@ do_exec_no_pty(Session *s, const char *command)
589
590
char buf [256 ];
590
591
int prot_scr_width = 80 ;
591
592
int prot_scr_height = 25 ;
593
+ #ifdef WIN32_PRAGMA_REMCON
594
+ char exec_command_str [512 ];
595
+ #endif
592
596
593
597
if (!command )
594
598
{
599
+ #ifndef WIN32_PRAGMA_REMCON
595
600
exec_command = s -> pw -> pw_shell ;
596
- //exec_command = "c:\\tools\\echoit.exe"; // temp
601
+ #else
602
+ snprintf (exec_command_str , sizeof (exec_command_str ),
603
+ "\\program files\\pragma\\shared files\\cmdserver.exe SSHD %d %d" ,
604
+ s -> row , s -> col );
605
+ exec_command = exec_command_str ;
606
+ #endif
597
607
}
598
608
else
599
609
{
@@ -606,28 +616,42 @@ do_exec_no_pty(Session *s, const char *command)
606
616
* Create three socket pairs for stdin, stdout and stderr
607
617
*/
608
618
609
- HANDLE wfdtocmd = -1 ;
619
+ #ifdef WIN32_PRAGMA_REMCON
620
+
610
621
int retcode = -1 ;
611
622
if ( (!s -> is_subsystem ) && (s -> ttyfd != -1 ))
612
623
{
613
- //FreeConsole();
614
- //AllocConsole();
615
- MakeNewConsole ();
616
624
prot_scr_width = s -> col ;
617
625
prot_scr_height = s -> row ;
618
626
extern HANDLE hConsole ;
619
627
hConsole = GetStdHandle (STD_OUTPUT_HANDLE );
620
628
ConSetScreenSize ( s -> col , s -> row );
621
- s -> ptyfd = hConsole ; // the pty is the Windows console output handle in our Win32 port
622
-
623
- wfdtocmd = GetStdHandle (STD_INPUT_HANDLE ) ; // we use this console handle to feed input to Windows shell cmd.exe
624
- sockin [1 ] = allocate_sfd ((int )wfdtocmd ); // put the std input handle in our global general handle table
625
- //if (sockin[1] >= 0)
626
- // sfd_set_to_console(sockin[1]); // mark it as Console type
627
-
629
+ socketpair (sockin );
630
+ s -> ptyfd = sockin [1 ]; // hConsole; // the pty is the Windows console output handle in our Win32 port
628
631
}
629
632
else
630
633
socketpair (sockin );
634
+ #else
635
+ HANDLE wfdtocmd = -1 ;
636
+ int retcode = -1 ;
637
+ if ((!s -> is_subsystem ) && (s -> ttyfd != -1 ))
638
+ {
639
+ //FreeConsole();
640
+ //AllocConsole();
641
+ MakeNewConsole ();
642
+ prot_scr_width = s -> col ;
643
+ prot_scr_height = s -> row ;
644
+ extern HANDLE hConsole ;
645
+ hConsole = GetStdHandle (STD_OUTPUT_HANDLE );
646
+ ConSetScreenSize (s -> col , s -> row );
647
+ s -> ptyfd = hConsole ; // the pty is the Windows console output handle in our Win32 port
648
+
649
+ wfdtocmd = GetStdHandle (STD_INPUT_HANDLE ); // we use this console handle to feed input to Windows shell cmd.exe
650
+ sockin [1 ] = allocate_sfd ((int )wfdtocmd ); // put the std input handle in our global general handle table
651
+ }
652
+ else
653
+ socketpair (sockin );
654
+ #endif
631
655
632
656
socketpair (sockout );
633
657
socketpair (sockerr );
@@ -636,12 +660,14 @@ do_exec_no_pty(Session *s, const char *command)
636
660
debug3 ("sockout[0]: %d sockout[1]: %d" , sockout [0 ], sockout [1 ]);
637
661
debug3 ("sockerr[0]: %d sockerr[1]: %d" , sockerr [0 ], sockerr [1 ]);
638
662
663
+ #ifndef WIN32_PRAGMA_REMCON
639
664
if ( (s -> is_subsystem ) || (s -> ttyfd == -1 ))
640
665
crlf_sfd (sockin [1 ]);
641
666
642
667
crlf_sfd (sockout [1 ]);
643
668
644
669
if ( (s -> is_subsystem ) || (s -> ttyfd == -1 ))
670
+ #endif
645
671
SetHandleInformation (sfd_to_handle (sockin [1 ]), HANDLE_FLAG_INHERIT , 0 );
646
672
647
673
SetHandleInformation (sfd_to_handle (sockout [1 ]), HANDLE_FLAG_INHERIT , 0 );
@@ -668,11 +694,16 @@ do_exec_no_pty(Session *s, const char *command)
668
694
si .cbReserved2 = 0 ;
669
695
si .lpReserved2 = 0 ;
670
696
697
+ #ifdef WIN32_PRAGMA_REMCON
698
+ if (0 ) {
699
+ #else
671
700
if ( (!s -> is_subsystem ) && (s -> ttyfd != -1 ) ) {
701
+
672
702
si .hStdInput = GetStdHandle (STD_INPUT_HANDLE ) ; // shell tty interactive session gets a console input for Win32
673
703
si .hStdOutput = (HANDLE ) sfd_to_handle (sockout [0 ]);
674
704
si .hStdError = (HANDLE ) sfd_to_handle (sockerr [0 ]);
675
705
si .lpDesktop = NULL ; //winstadtname_w ;
706
+ #endif
676
707
}
677
708
else {
678
709
si .hStdInput = (HANDLE ) sfd_to_handle (sockin [0 ]);
@@ -889,13 +920,15 @@ do_exec_no_pty(Session *s, const char *command)
889
920
890
921
GetUserName (name , & size );
891
922
923
+ #ifndef WIN32_PRAGMA_REMCON
892
924
if ( (!s -> is_subsystem ) && (s -> ttyfd != -1 )) {
893
925
// Send to the remote client ANSI/VT Sequence so that they send us CRLF in place of LF
894
926
char * inittermseq = "\033[20h\033[?7h\0" ; // LFtoCRLF AUTOWRAPON
895
927
Channel * c = channel_by_id ( s -> chanid );
896
928
buffer_append (& c -> input , inittermseq , strlen (inittermseq ));
897
929
channel_output_poll ();
898
930
}
931
+ #endif
899
932
900
933
//if (s ->ttyfd != -1) {
901
934
// set the channel to tty interactive type
@@ -975,8 +1008,12 @@ do_exec_no_pty(Session *s, const char *command)
975
1008
/*
976
1009
* We are the parent. Close the child sides of the socket pairs.
977
1010
*/
1011
+ #ifndef WIN32_PRAGMA_REMCON
978
1012
if ( (s -> is_subsystem ) || (s -> ttyfd == -1 ))
979
1013
close (sockin [0 ]);
1014
+ #else
1015
+ close (sockin [0 ]);
1016
+ #endif
980
1017
981
1018
close (sockout [0 ]);
982
1019
close (sockerr [0 ]);
@@ -2734,7 +2771,9 @@ session_pty_req(Session *s)
2734
2771
/* for SSH1 the tty modes length is not given */
2735
2772
if (!compat20 )
2736
2773
n_bytes = packet_remaining ();
2774
+ #ifndef WIN32_PRAGMA_REMCON
2737
2775
tty_parse_modes (s -> ttyfd , & n_bytes );
2776
+ #endif
2738
2777
2739
2778
if (!use_privsep )
2740
2779
pty_setowner (s -> pw , s -> tty );
@@ -2744,7 +2783,9 @@ session_pty_req(Session *s)
2744
2783
pty_change_window_size (s -> ptyfd , s -> row , s -> col , s -> xpixel , s -> ypixel );
2745
2784
#endif
2746
2785
2786
+ #ifndef WIN32_PRAGMA_REMCON
2747
2787
packet_check_eom ();
2788
+ #endif
2748
2789
session_proctitle (s );
2749
2790
return 1 ;
2750
2791
}
0 commit comments