public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* process substitution to create a virtual file doesn't work in chroot environment
@ 2023-08-27 22:13 Cary Lewis
  2023-08-28  5:13 ` Cedric Blancher
  2023-08-28  8:50 ` Corinna Vinschen
  0 siblings, 2 replies; 4+ messages in thread
From: Cary Lewis @ 2023-08-27 22:13 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

In a cygwin process that is started either from mintty or bash directly the
following:

$ user=234

$ ./cat <(echo $user)
234
works as expected.

But after a chroot:

$ chroot . ./bash
user=234
$  ./cat <(echo $user)
./cat: /dev/fd/63: No such file or directory

In the directory I am chrooting in, I created a tmp folder, as well as
proc, proc/self, and proc/self/fd, and a dev directory.

Can someone explain why process substitution to create a virtual file
doesn't work in a chroot environment?

Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: process substitution to create a virtual file doesn't work in chroot environment
  2023-08-27 22:13 process substitution to create a virtual file doesn't work in chroot environment Cary Lewis
@ 2023-08-28  5:13 ` Cedric Blancher
  2023-08-28  8:50 ` Corinna Vinschen
  1 sibling, 0 replies; 4+ messages in thread
From: Cedric Blancher @ 2023-08-28  5:13 UTC (permalink / raw)
  To: cygwin

On Mon, 28 Aug 2023 at 00:14, Cary Lewis via Cygwin <cygwin@cygwin.com> wrote:
>
> In a cygwin process that is started either from mintty or bash directly the
> following:
>
> $ user=234
>
> $ ./cat <(echo $user)
> 234
> works as expected.
>
> But after a chroot:
>
> $ chroot . ./bash
> user=234
> $  ./cat <(echo $user)
> ./cat: /dev/fd/63: No such file or directory
>
> In the directory I am chrooting in, I created a tmp folder, as well as
> proc, proc/self, and proc/self/fd, and a dev directory.

Can you strace -f the bash process to see what happens? How does ls -l
/dev/ look like?

Ced

--
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: process substitution to create a virtual file doesn't work in chroot environment
  2023-08-27 22:13 process substitution to create a virtual file doesn't work in chroot environment Cary Lewis
  2023-08-28  5:13 ` Cedric Blancher
@ 2023-08-28  8:50 ` Corinna Vinschen
  2023-10-21 22:41   ` Cygwin |chroot()| "bad" - but what should replace it ? / was: " Roland Mainz
  1 sibling, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2023-08-28  8:50 UTC (permalink / raw)
  To: cygwin

On Aug 27 18:13, Cary Lewis via Cygwin wrote:
> In a cygwin process that is started either from mintty or bash directly the
> following:
> 
> $ user=234
> 
> $ ./cat <(echo $user)
> 234
> works as expected.
> 
> But after a chroot:

From https://cygwin.com/cygwin-ug-net/highlights.html:

  chroot is supported. Kind of. Chroot is not a concept known by
  Windows. This implies some serious restrictions. First of all, the
  chroot call isn't a privileged call. Any user may call it. Second, the
  chroot environment isn't safe against native windows processes.  Given
  that, chroot in Cygwin is only a hack which pretends security where
  there is none. For that reason the usage of chroot is discouraged.
  Don't use it unless you really, really know what you're doing.

> $ chroot . ./bash
> user=234
> $  ./cat <(echo $user)
> ./cat: /dev/fd/63: No such file or directory
> 
> In the directory I am chrooting in, I created a tmp folder, as well as
> proc, proc/self, and proc/self/fd, and a dev directory.
> 
> Can someone explain why process substitution to create a virtual file
> doesn't work in a chroot environment?

/dev/fd is a symlink pointing into nirvana after using chroot.

/dev/fd symlinks to /proc/self/fd, but in the chroot'ed environment
there's no /proc anymore.

I would like to underline what is written in the above Cygwin
documentation snippet:

The chroot implementation is old, bad, and deprecated.  I was going
to rip it out entirely for I don't know how often already, but there
was always somebody asking to keep it.  Given that it never did what
chroot is intended, don't use it.


Corinna

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Cygwin |chroot()| "bad" - but what should replace it ? / was: Re: process substitution to create a virtual file doesn't work in chroot environment
  2023-08-28  8:50 ` Corinna Vinschen
@ 2023-10-21 22:41   ` Roland Mainz
  0 siblings, 0 replies; 4+ messages in thread
From: Roland Mainz @ 2023-10-21 22:41 UTC (permalink / raw)
  To: cygwin

On Mon, Aug 28, 2023 at 10:50 AM Corinna Vinschen via Cygwin
<cygwin@cygwin.com> wrote:
> On Aug 27 18:13, Cary Lewis via Cygwin wrote:
[snip
> The chroot implementation is old, bad, and deprecated.  I was going
> to rip it out entirely for I don't know how often already, but there
> was always somebody asking to keep it.  Given that it never did what
> chroot is intended, don't use it.

What should replace it if you rip it out ? And why is the implemenation "bad" ?

----

Bye,
Roland
-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-21 22:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-27 22:13 process substitution to create a virtual file doesn't work in chroot environment Cary Lewis
2023-08-28  5:13 ` Cedric Blancher
2023-08-28  8:50 ` Corinna Vinschen
2023-10-21 22:41   ` Cygwin |chroot()| "bad" - but what should replace it ? / was: " Roland Mainz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).