[Toybox] netcat -f bug

Yi-Yo Chiang yochiang at google.com
Thu May 16 04:38:15 PDT 2024


The nodes under /dev/pts/ are allocated on demand, so there isn't a fixed
pts/number. When a process opens /dev/ptmx (controlling end), a
/dev/pts/<num> node would be allocated. Another process can then open the
pts end and communicate with the controlling end.

What my test is doing is to just open a tty-esque device and try to talk to
it.
It could be an actual serial port like /dev/ttyUSB0 or pseudo tty such as
/dev/pts/<num>. For the test purpose, it doesn't really matter what it is,
as long as it is a character device that behaves like a tty.

If you are asking about a regression test, I think something like this is
enough to reproduce what I'm seeing: (the pty,link= option tells socat to
make a symlink that points to the dynamically allocated pts, this gives the
pts node a somewhat predictable name)
* (shell 1) socat - pty,link=/tmp/a
* (shell 2) toybox nc -f /tmp/a
* Now anything typed in (shell 1) would also appear in (shell 2) and vice
versa.


On Thu, May 16, 2024 at 2:41 AM Rob Landley <rob at landley.net> wrote:

> On 5/11/24 02:11, Yi-Yo Chiang wrote:
> > On Sat, May 11, 2024 at 1:30 AM Rob Landley <rob at landley.net
> > <mailto:rob at landley.net>> wrote:
> >
> >     What's your use case triggering this patch? Because without that, I
> go off on
> >     various design tangents, as seen below:
> >
> > I just wanted some tool to communicate with a pty or socket node on
> android.
> > Wanted a program to be able to send/recv towards a duplex data stream.
> (more
> > precisely I want a command that does exactly what pollinate() does)
> > Since socat nor minicom is available on Android, I'm just using `stty
> raw -echo
> > && nc -f` to "talk" to my pty.
> >
> > Why didn't I use <> redirector? Because I wasn't aware of that feature
> before
> > reading this mail...
> > Let me fiddle with it a bit:
> >
> > cat <>/dev/pts/0
> >> Shows the pts output, but my input doesn't get passed back
>
> Sorry for sitting on this, my confusion here is I don't know what
> /dev/pts/0
> means in your test, and the pts man page isn't illuminating. It doesn't
> seem to
> be special, it just seems to be the first one allocated? (So who allocated
> it on
> android?)
>
> According to "tty" in a random command line tab that one's using
> /dev/pts/17,
> and ps ax | grep pts/0 says it's PID 14597 a random bash instance, so I
> don't
> think the test lines up on a debian+xfce laptop.
>
> What is your test trying to _do_? (What process are you talking to?)
>
> > yeah like you said it should had fall through and be like -l.
> > However digging the git history the fall through line got removed
> > here
> https://github.com/landley/toybox/commit/67bf48c1cb3ed55249c27e6f02f5c938b20e027d
> > which is unintentional I think?
>
> Yeah, lack of automated regression testing for this, which is why I want to
> understand and fix the test...
>
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20240516/38d97c2b/attachment.htm>


More information about the Toybox mailing list