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>
This commit is contained in:
Takashi Yano 2022-12-21 10:06:10 +09:00
parent 25c4ad6ea5
commit 043b6089e2
2 changed files with 8 additions and 2 deletions

View File

@ -9,6 +9,8 @@
#include "path.h" #include "path.h"
#include "fhandler.h" #include "fhandler.h"
#include "ntdll.h" #include "ntdll.h"
#include "dtable.h"
#include "cygheap.h"
typedef const _device *KR_device_t; typedef const _device *KR_device_t;
@ -76,7 +78,8 @@ exists_console (const device& dev)
case FH_CONSOLE: case FH_CONSOLE:
case FH_CONIN: case FH_CONIN:
case FH_CONOUT: case FH_CONOUT:
return fhandler_console::exists (); return cygheap && cygheap->ctty && cygheap->ctty->is_console ()
&& fhandler_console::exists ();
default: default:
/* Only show my own console device (for now?) */ /* Only show my own console device (for now?) */
return iscons_dev (myself->ctty) && myself->ctty == devn; return iscons_dev (myself->ctty) && myself->ctty == devn;

View File

@ -8,6 +8,8 @@
#include "path.h" #include "path.h"
#include "fhandler.h" #include "fhandler.h"
#include "ntdll.h" #include "ntdll.h"
#include "dtable.h"
#include "cygheap.h"
typedef const _device *KR_device_t; typedef const _device *KR_device_t;
} }
@ -72,7 +74,8 @@ exists_console (const device& dev)
case FH_CONSOLE: case FH_CONSOLE:
case FH_CONIN: case FH_CONIN:
case FH_CONOUT: case FH_CONOUT:
return fhandler_console::exists (); return cygheap && cygheap->ctty && cygheap->ctty->is_console ()
&& fhandler_console::exists ();
default: default:
/* Only show my own console device (for now?) */ /* Only show my own console device (for now?) */
return iscons_dev (myself->ctty) && myself->ctty == devn; return iscons_dev (myself->ctty) && myself->ctty == devn;