Cygwin: implement /proc/PID/fd/DESCRIPTOR reopening by handle

Allows expressions along the lines of `cat /proc/self/fd/0 <<EOF'.
The problem here is that the temporary file used for the here script
has already been deleted by the shell.  Opening by filename, as
implemented so far, doesn't work because the file has been moved
to the bin.

Allow reopening files by handle the same way from another process
as long as we have sufficient permissions on the foreign process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2019-01-05 22:13:42 +01:00
parent c76468182b
commit 732613f30a
6 changed files with 108 additions and 5 deletions

View File

@ -844,6 +844,10 @@ path_conv::check (const char *src, unsigned opt,
fileattr = 0;
break;
case virt_fdsymlink:
/* Allow open/linkat to do the right thing. */
if (opt & PC_SYM_NOFOLLOW_PROCFD)
opt &= ~PC_SYM_FOLLOW;
/*FALLTHRU*/
case virt_symlink:
goto is_virtual_symlink;
case virt_pipe: