[newlib-cygwin/cygwin-3_4-branch] Cygwin: devices: Make generic console devices invisible from pty.

Takashi Yano tyan0@sourceware.org
Thu Dec 22 13:33:03 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=74f5aa9c473959b63a18a05579581b575a5117ce

commit 74f5aa9c473959b63a18a05579581b575a5117ce
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Wed Dec 21 10:06:10 2022 +0900

    Cygwin: devices: Make generic console devices invisible from pty.
    
    The devices /dev/conin,conout,console were wrongly visible from ptys,
    though they are inaccessible. This is because fhandler_console::exists()
    returns true due to existing invisible console. This patch makes these
    devices invisible from ptys.
    
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/devices.cc | 5 ++++-
 winsup/cygwin/devices.in | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc
index a0762f292..9f6e80acb 100644
--- a/winsup/cygwin/devices.cc
+++ b/winsup/cygwin/devices.cc
@@ -9,6 +9,8 @@
 #include "path.h"
 #include "fhandler.h"
 #include "ntdll.h"
+#include "dtable.h"
+#include "cygheap.h"
 
 typedef const _device *KR_device_t;
 
@@ -76,7 +78,8 @@ exists_console (const device& dev)
     case FH_CONSOLE:
     case FH_CONIN:
     case FH_CONOUT:
-      return fhandler_console::exists ();
+      return cygheap && cygheap->ctty && cygheap->ctty->is_console ()
+	&& fhandler_console::exists ();
     default:
       /* Only show my own console device (for now?) */
       return iscons_dev (myself->ctty) && myself->ctty == devn;
diff --git a/winsup/cygwin/devices.in b/winsup/cygwin/devices.in
index 7506dfe9c..48199f46c 100644
--- a/winsup/cygwin/devices.in
+++ b/winsup/cygwin/devices.in
@@ -8,6 +8,8 @@
 #include "path.h"
 #include "fhandler.h"
 #include "ntdll.h"
+#include "dtable.h"
+#include "cygheap.h"
 
 typedef const _device *KR_device_t;
 }
@@ -72,7 +74,8 @@ exists_console (const device& dev)
     case FH_CONSOLE:
     case FH_CONIN:
     case FH_CONOUT:
-      return fhandler_console::exists ();
+      return cygheap && cygheap->ctty && cygheap->ctty->is_console ()
+	&& fhandler_console::exists ();
     default:
       /* Only show my own console device (for now?) */
       return iscons_dev (myself->ctty) && myself->ctty == devn;


More information about the Cygwin-cvs mailing list