Skip to content

Commit

Permalink
Cygwin: devices: Make generic console devices invisible from pty.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tyan0 committed Dec 22, 2022
1 parent 25c4ad6 commit 043b608
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion winsup/cygwin/devices.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion winsup/cygwin/devices.in
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 043b608

Please sign in to comment.