-1
  1. I am running an application that communicates through a real serial port e.g. /dev/ttyS0 to a remote device. I can configure this application to use /dev/ttyS0, /dev/ttyS1, etc., by passing the numeric suffix to the program, not the fully-qualified name.

  2. I would like to sniff the traffic going through this serial port using something like jpnevulator. This jpnevulator opens a pseudo-terminal to which the application to be monitored is supposed to connect.

Is there any way to re-assign the name of the ports, for example /dev/ttyS1 to an actual pseudo-terminal such as /dev/pty/23, so that the application transparently connects to /dev/pty/23 via /dev/ttyS1? Would a file link ln achieve this?

0

1 Answer 1

0

If I were you, I would just edit the binary and replace the /dev/ttyS%d or similar string with /dev/ptyX%d (taking care that the replacement have the same length as the original), then create a symlink /dev/ptyX0 to the path of the slave end of the pseudo-terminal.

There are a lot of other solutions, more or less awkward:

a) if your system is linux, temporarily mount --bind /dev/pts/<pty used by the sniffer> /dev/ttyS2 (and connect your program to the serial line 2)

b) similarly, move /dev/ttyS2 out of the way and replace it with a link to the pty

c) run it inside qemu and redirect the serial port of the vm to the pty

d) some fake paths/filesystem solution using LD_PRELOAD

e) namespaces, unionfs, chroots, etc

2
  • I actually tried the symbolic link approach and the program barfed up an error message - "incorrect parameter" or something like that. I suspect that the program is setting up serial-port specific parameters that don't map well to the pseudo-terminal.
    – AWM
    Sep 14, 2018 at 15:05
  • Thanks for the other suggestions. I will try those when I get a chance.
    – AWM
    Sep 14, 2018 at 15:10

Not the answer you're looking for? Browse other questions tagged .