@@ -1204,7 +1204,12 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
12041204 stdinPipe [1 ] = -1 ;
12051205
12061206 forcedCmd = wolfSSHD_ConfigGetForcedCmd (usrConf );
1207- ptyReq = wolfSSH_ReceivedPtyReq (ssh );
1207+
1208+ ptyReq = wolfSSH_ChannelIsPty (ssh , NULL );
1209+ if (ptyReq < 0 ) {
1210+ wolfSSH_Log (WS_LOG_ERROR , "[SSHD] Failure get channel PTY state" );
1211+ return WS_FATAL_ERROR ;
1212+ }
12081213
12091214 /* do not overwrite a forced command with 'exec' sub shell. Only set the
12101215 * 'exec' command when no forced command is set */
@@ -1227,7 +1232,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
12271232
12281233
12291234 /* create pipes for stdout and stderr */
1230- if (ptyReq == 0 || forcedCmd ) {
1235+ if (! ptyReq || forcedCmd ) {
12311236 if (pipe (stdoutPipe ) != 0 ) {
12321237 wolfSSH_Log (WS_LOG_ERROR , "[SSHD] Issue creating stdout pipe" );
12331238 return WS_FATAL_ERROR ;
@@ -1266,7 +1271,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
12661271 signal (SIGINT , SIG_DFL );
12671272 signal (SIGCHLD , SIG_DFL );
12681273
1269- if (ptyReq == 0 || forcedCmd ) {
1274+ if (! ptyReq || forcedCmd ) {
12701275 close (stdoutPipe [0 ]);
12711276 close (stderrPipe [0 ]);
12721277 close (stdinPipe [1 ]);
@@ -1393,7 +1398,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
13931398 close (stderrPipe [1 ]);
13941399 close (stdinPipe [1 ]);
13951400 }
1396- else if (ptyReq == 0 ) {
1401+ else if (! ptyReq ) {
13971402 ret = execv (cmd , (char * * )args );
13981403 close (stdoutPipe [1 ]);
13991404 close (stderrPipe [1 ]);
@@ -1452,7 +1457,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
14521457#endif
14531458
14541459 wolfSSH_SetTerminalResizeCtx (ssh , (void * )& childFd );
1455- if (ptyReq == 0 || forcedCmd ) {
1460+ if (! ptyReq || forcedCmd ) {
14561461 close (stdoutPipe [1 ]);
14571462 close (stderrPipe [1 ]);
14581463 close (stdinPipe [0 ]);
@@ -1478,7 +1483,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
14781483
14791484 if (wolfSSH_stream_peek (ssh , tmp , 1 ) <= 0 ) {
14801485 /* select on stdout/stderr pipes with forced commands */
1481- if (ptyReq == 0 || forcedCmd ) {
1486+ if (! ptyReq || forcedCmd ) {
14821487 FD_SET (stdoutPipe [0 ], & readFds );
14831488 if (stdoutPipe [0 ] > maxFd )
14841489 maxFd = stdoutPipe [0 ];
@@ -1524,7 +1529,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15241529 if (cnt_r <= 0 )
15251530 break ;
15261531
1527- if (ptyReq == 0 || forcedCmd ) {
1532+ if (! ptyReq || forcedCmd ) {
15281533 cnt_w = (int )write (stdinPipe [1 ], channelBuffer ,
15291534 cnt_r );
15301535 }
@@ -1564,7 +1569,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15641569 current = wolfSSH_ChannelFind (ssh , lastChannel ,
15651570 WS_CHANNEL_ID_SELF );
15661571 eof = wolfSSH_ChannelGetEof (current );
1567- if (eof && (ptyReq == 0 || forcedCmd )) {
1572+ if (eof && (! ptyReq || forcedCmd )) {
15681573 /* SSH is done, close stdin pipe to child process */
15691574 close (stdinPipe [1 ]);
15701575 stdinPipe [1 ] = -1 ;
@@ -1594,7 +1599,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15941599 }
15951600 }
15961601
1597- if (ptyReq == 0 || forcedCmd ) {
1602+ if (! ptyReq || forcedCmd ) {
15981603 if (FD_ISSET (stderrPipe [0 ], & readFds )) {
15991604 cnt_r = (int )read (stderrPipe [0 ], shellBuffer ,
16001605 sizeof shellBuffer );
@@ -1734,7 +1739,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
17341739 }
17351740
17361741 /* check for any left over data in pipes then close them */
1737- if (ptyReq == 0 || forcedCmd ) {
1742+ if (! ptyReq || forcedCmd ) {
17381743 int readSz ;
17391744
17401745 fcntl (stdoutPipe [0 ], F_SETFL , fcntl (stdoutPipe [0 ], F_GETFL )
0 commit comments