summaryrefslogtreecommitdiff
path: root/master.c
AgeCommit message (Collapse)Author
2025-06-20Clean up whitespace, mixed spaces/tabs, and brace styleHEADmasterNed T. Crigler
2025-06-19Handle partial reads of the execvp error stringNed T. Crigler
It is possible that reading the entire error string requires multiple read() calls.
2025-06-19Always check the return value of the write() system callNed T. Crigler
dtach was assuming that writes with a small byte count could never fail, and was not handling partial writes for larger byte counts in a few places. This should also suppress unused result warnings from gcc on systems that define _FORTIFY_SOURCE by default.
2025-06-19Check the return value of the fchdir() system callNed T. Crigler
dtach was not checking if the fchdir back to the old directory worked when it tried to get around the sun_path length limit.
2025-06-17Make dtach -N return the exit status of the programNed T. Crigler
Also change the execvp error exit from 127 to 1 to be consistent between dtach -n and dtach -N.
2025-06-17Move umask(omask) call after bindNed T. Crigler
Just wrapping the socket system call with umask doesn't work.
2025-06-17Avoid permission race condition when dtach socket is createdRobert de Bath
Use umask(077) to avoid a race condition between the creation of the dtach socket and the chmod system call on the socket. This race condition can potentially be exploited when the dtach socket is created in a directory such as /tmp. (cherry picked from commit b71dfb2e2c02dfe14738781214a5734d63eeb772)
2017-03-05Update license header in source files.Ned T. Crigler
Use http://www.gnu.org/licenses/ instead of a postal address as suggested in PR #7.
2016-05-08Update copyrights for 2016.Ned T. Crigler
2016-05-08Improve error message when dtach can't find a pty.Ned T. Crigler
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
2015-12-01Call init_pty before signals are set up.Ned T. Crigler
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
2015-07-18Update copyrights for 2015.Ned T. Crigler
2014-08-04Try to use chdir to get around the sun_path length limit.Ned T. Crigler
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.
2014-08-04Prevent buffer overflow with a long socket path name.Ned T. Crigler
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.
2014-08-04Add dtach -N.Ned T. Crigler
dtach -N is similar to dtach -n, except dtach will not daemonize. Based on patches by Ciprian Dorin Craciun and Frank Hunleth.
2014-08-04Make socket executable when there are attached clients.Ned T. Crigler
Based on dtach-0.8-socket-exec-bit.diff by Kodest.
2012-07-26Add AIX support to openpty and forkpty.Ned T. Crigler
Patch by Ross Mohn.
2012-07-01Fix error handling for read from stdin in attach.cNed T. Crigler
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.
2012-07-01Use ssize_t for the return type of read/write instead of int.Ned T. Crigler
2008-01-29Update copyrights for 2008.Ned T. Crigler
2008-01-26If FD_CLOEXEC works, create a pipe and use it to report any errors that occurNed T. Crigler
while trying to execute the program.
2006-09-27Add a comment to the waitattach code.Ned T. Crigler
2006-06-03Print an error message if we could not execute the desired command, instead ofNed T. Crigler
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.
2005-04-10Allow the dtach -n mode to be used without a terminal. If a terminal is notNed T. Crigler
present when dtach is started, we now rely on whatever default terminal settings the kernel uses.
2004-11-03Use non-blocking mode a little better by repeatedly trying to send data out toNed T. Crigler
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.
2004-10-04Try to set non-blocking mode when accepting new clients.Ned T. Crigler
2004-06-24Allow the redraw method to be chosen by the user, and include the old Ctrl LNed T. Crigler
character method again.
2004-06-23First attempt at proper process group handling.Ned T. Crigler
2004-05-26dtach 0.6Ned T. Crigler
2001-11-28Fix fd leakage.Ned T. Crigler
Prevent atexit from being called twice on dtach -A.
2001-11-05Portability updates thanks to sourceforge's compile farm. dtach should nowNed T. Crigler
work on: FreeBSD, Debian/alpha, Debian/sparc, Debian/PPC, and Solaris. Bump version.
2001-09-28initial import to sourceforgeNed T. Crigler