@@ -497,6 +497,10 @@ do_authenticated1(Authctxt *authctxt)
497
497
#define USE_PIPES 1
498
498
#endif
499
499
500
+ #ifdef WIN32_FIXME
501
+ extern int debug_flag ;
502
+ #endif
503
+
500
504
/*
501
505
* This is called to fork and execute a command when we have no tty. This
502
506
* will call do_child from the child, and server_loop from the parent after
@@ -548,8 +552,6 @@ do_exec_no_pty(Session *s, const char *command)
548
552
char * exec_command ;
549
553
char * laddr ;
550
554
char buf [256 ];
551
- int prot_scr_width = 80 ;
552
- int prot_scr_height = 25 ;
553
555
#ifdef WIN32_PRAGMA_REMCON
554
556
char exec_command_str [512 ];
555
557
#endif
@@ -590,8 +592,6 @@ do_exec_no_pty(Session *s, const char *command)
590
592
int retcode = -1 ;
591
593
if ( (!s -> is_subsystem ) && (s -> ttyfd != -1 ))
592
594
{
593
- prot_scr_width = s -> col ;
594
- prot_scr_height = s -> row ;
595
595
extern HANDLE hInputConsole ;
596
596
extern HANDLE hOutputConsole ;
597
597
hInputConsole = GetConsoleInputHandle ();
@@ -620,10 +620,10 @@ do_exec_no_pty(Session *s, const char *command)
620
620
si .lpTitle = NULL ; /* NULL means use exe name as title */
621
621
si .dwX = 0 ;
622
622
si .dwY = 0 ;
623
- si .dwXSize = 640 ;
624
- si .dwYSize = 480 ;
625
- si .dwXCountChars = prot_scr_width ;
626
- si .dwYCountChars = prot_scr_height ;
623
+ si .dwXSize = 5 ;
624
+ si .dwYSize = 5 ;
625
+ si .dwXCountChars = s -> col ;
626
+ si .dwYCountChars = s -> row ;
627
627
si .dwFillAttribute = 0 ;
628
628
si .dwFlags = STARTF_USESTDHANDLES | STARTF_USESIZE | STARTF_USECOUNTCHARS ;
629
629
si .wShowWindow = 0 ; // FALSE ;
@@ -794,32 +794,35 @@ do_exec_no_pty(Session *s, const char *command)
794
794
wchar_t exec_command_w [MAX_PATH ];
795
795
796
796
MultiByteToWideChar (CP_UTF8 , 0 , exec_command , -1 , exec_command_w , MAX_PATH );
797
- DWORD dwStartupFlags = 0 ;// CREATE_SUSPENDED; // 0
797
+ DWORD dwStartupFlags = DETACHED_PROCESS ;// CREATE_SUSPENDED; // 0
798
798
799
799
SetConsoleCtrlHandler (NULL , FALSE);
800
- b = CreateProcessAsUserW (hToken , NULL , exec_command_w , NULL , NULL , TRUE,
800
+ if (debug_flag )
801
+ b = CreateProcessW (NULL , exec_command_w , NULL , NULL , TRUE,
802
+ /*CREATE_NEW_PROCESS_GROUP*/ dwStartupFlags , NULL , s -> pw -> pw_dir ,
803
+ & si , & pi );
804
+ else
805
+ b = CreateProcessAsUserW (hToken , NULL , exec_command_w , NULL , NULL , TRUE,
801
806
/*CREATE_NEW_PROCESS_GROUP*/ dwStartupFlags , NULL , s -> pw -> pw_dir ,
802
807
& si , & pi );
803
- /*
804
- * If CreateProcessAsUser() fails we will try CreateProcess()
805
- * but only if current user and login user are the same.
806
- */
807
-
808
- if ((!b ) && (strcmp (name , s -> pw -> pw_name ) == 0 ))
809
- {
810
- b = CreateProcessW (NULL , exec_command_w , NULL , NULL , TRUE,
811
- /*CREATE_NEW_PROCESS_GROUP*/ dwStartupFlags , NULL , s -> pw -> pw_dir ,
812
- & si , & pi );
813
- }
814
-
815
808
if (!b )
816
809
{
817
- debug ("ERROR. Cannot create process as new user (%u).\n" , GetLastError ());
810
+ debug ("ERROR. Cannot create process (%u).\n" , GetLastError ());
818
811
819
812
CloseHandle (hToken );
820
813
821
814
exit (1 );
822
815
}
816
+ else {
817
+ FreeConsole ();
818
+ if (!debug_flag )
819
+ ImpersonateLoggedOnUser (hToken );
820
+ while (AttachConsole (pi .dwProcessId ) == FALSE) {
821
+ Sleep (200 );
822
+ }
823
+ if (!debug_flag )
824
+ RevertToSelf ();
825
+ }
823
826
824
827
/*
825
828
* Save token used for create child process. We'll need it on cleanup
0 commit comments