Also add some documentation mentioning the devices that dtach usually
needs access to on Linux.
Bug reported by David Bremner at https://bugs.debian.org/804944
Signals set to SIG_IGN (such as SIGPIPE) are not reset when execve is
called, which causes programs executed by dtach to start in a different
state than what they expect. Calling init_pty first is the simplest way
to fix this bug.
Bug reported by Robert de Bath at https://bugs.debian.org/805417
If a socket's path name would overflow sun_path, try to make it fit by
temporarily changing to the directory the socket is in and using the
path's basename in sun_path.
This should help for the case where the basename of the socket does fit
in sun_path, even if the rest of the path doesn't.
The code wasn't checking for overflow before copying the socket path
name to to the sun_path field, which is usually much smaller than
PATH_MAX.
Report and initial patch by Paul Wilkinson.
attach.c did not correctly handle a read from stdin when read returned
an error. The code assigned the return value of read to pkt.len (an
unsigned char) before checking the value. This prevented the error check
from working correctly, since an unsigned integer can never be < 0.
A packet with an invalid length was then sent to the master, which then
sent 255 bytes of garbage to the program.
Fix the bug in attach.c and the unchecked packet length bug in master.c.
Report and initial patch by Enrico Scholz.
exiting silently.
Also make sure the master process waits until the client attaches when using
the -A and -c modes, so that the error message has a chance of being seen.
the clients until at least one write worked and no error (other than EAGAIN)
occurred when writing to any of the clients. This way, complete data loss can
be avoided since at least one client must get all of the data.
Also make sure that stdin/stdout/stderr point to /dev/null instead of just
closing them, to avoid confusion.