Breaks backward compatibility
This fixes a problem when user runs screen with "-L" option in already
existing screen. We need to pass information about theflag to backend.
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
those variables are used to maintain most recently used list and I want
to reuse w_next to make proper list of windows instead of wtab
when we loop it doesn't make difference in which order we go, so we may
as well keep looping using mru list (and review later when we introduce
in order list)
after everything is finished goals are:
* to have table of callbacks to search from and call
* commands to have (char **argv, int argc) in declaration
refactor RC_SELECT into separate function call
refactor RC_MULTIINPUT into separate function call
also fix some logic while at it
refactor RC_DEFAUTONUKE & RC_AUTONUKE into separate function calls
refactor RC_DEFOBUFLIMIT & RC_OBUFLIMIT into separate function calls
refactor RC_DUMPTERMCAP into separate function call
refactor RC_HARDCOPY into separate function call
refactor RC_DEFLOG & RC_LOG into separate function calls
refactor RC_SUSPEND into separate function calls
refactor RC_PREV & RC_NEXT into separate function calls
refactor RC_KILL into separate function call
refactor RC_QUIT into separate function call
refactor RC_DETACH & RC_POW_DETACH into separate function calls
refactor RC_ZMODEM into separate function call
refactor RC_UNBINDALL into separate function call
refactor RC_ZOMBIE into separate function call
refactor RC_WALL into separate function call
refactor RC_AT into separate function call
refactor RC_READREG into separate function call
refactor RC_REGISTER into separate function call
refactor RC_PROCESS into separate function call
refactor RC_STUFF into separate function call
refactor RC_REDISPLAY into separate function call
refactor RC_WINDOWS inte separate function call
refactor RC_VERSION into separate function call
remove RC_TIME
should've done this when removing time and loadavg escapes
refactor RC_INFO into separate function call
refactor RC_DINFO into separate function call
refactor RC_COMMAND into separate function call
refactor RC_OTHER into separate function call
refactor RC_META into separate function call
refactor RC_XON & RC_XOFF into separate function calls
refactor RC_BREAKTYPE & RC_DEFBREAKTYPE into separate functions calls
something to check:
according to documentation they should have bit different behaviour,
but are all one single call...
refactor RC_BREAK & RC_POW_BREAK into separate function calls
refactor RC_LOCKSCREEN into separate function call
refactor RC_WIDTH & RC_HEIGHT into separate function calls
refactor RC_DEFDYNAMICTITLE & RC_DYNAMICTITLE into separate function calls
refactor RC_TITLE into separate function call
refactor RC_COLON into separate function call
refactor RC_LASTMSG into separate function call
refactor RC_SCREEN into separate function call
refactor RC_WRAP into separate function call
refactor RC_FLOW into separate function call
refactor RC_DEFWRITELOCK & RC_WRITELOCK into separate function calls
refactor RC_CLEAR into separate function call
refactor RC_RESET into separate function call
refactor RC_MONITOR into separate function call
refactor RC_DISPLAYS into separate function call
refactor RC_WINDOWLIST into separate function call
refactor RC_HELP into separate function call
refactor RC_LICENSE into separate function call
refactor RC_COPY into separate function call
refactor RC_HISTORY & RC_PASTE into separate function calls
refactor RC_READBUF & RC_WRITEBUF into separate function calls
refactor RC_REMOVEBUF into separate function call
refactor RC_IGNORECASE into separate function call
refactor RC_DEFESCAPE & RC_ESCAPE into separate function calls
refactor RC_CHDIR into separate function call
refactor RC_DEFSHELL & RC_SHELL into separate function call
refactor RC_HARDCOPYDIR into separate function call
refactor RC_LOGFILE into separate function call
refactor RC_LOGTSTAMP into separate function call
refactor RC_SHELLTITLE into separate function call
refactor RC_TERMCAP, RC_TERMCAPINFO & RC_TERMINFO into separate function call
refactor RC_SLEEP into separate function call
refactor RC_TERM into separate function call
refactor RC_ECHO into separate function call
refactor RC_BELL into separate function call
refactor RC_BUFFERFILE into separate function call
refactor RC_ACTIVITY into separate function call
refactor RC_POW_DETACH_MSG into separate function call
refactor RC_DEFLOGIN & RC_LOGIN into separate function calls
refactor RC_DEFFLOW into separate function call
refactor RC_DEFWRAP into separate function call
refactor RC_DEFC1 into separate function call
refactor RC_DEFBCE into separate function call
refactor RC_DEFGR into separate function call
refactor RC_DEFMONITOR into separate function call
refactor RC_DEFMOUSETRACK & RC_MOUSETRACK into separate function calls
refactor RC_DEFSILENCE into separate function call
refactor RC_VERBOSE into separate function call
refactor RC_HARDSTATUS into separate function call
refactor RC_STATUS into separate function call
refactor RC_CAPTION into separate function call
refactor RC_CONSOLE into separate function call
refactor RC_ALLPARTIAL & RC_PARTIAL into separate function call
refactor RC_VBELL into separate function call
refactor RC_VBELLWAIT, RC_MSGWAIT, RC_MSGMINWAIT & RC_SILENCEWAIT into separate function calls
refactor RC_BUMPRIGHT & RC_BUMPLEFT into separate function calls
refactor RC_COLLAPSE into separate function call
refactor RC_NUMBER into separate function call
refactor RC_ZOMBIE_TIMEOUT into separate function call
refactor RC_SORT into separate function call
refactor RC_SILENCE into separate function call
also fixes one bug from adding bool b
refactor RC_DEFSCROLLBACK & RC_SCROLLBACK into separate function calls
refactor RC_SESSIONNAME into separate function call
refactor RC_SETENV & RC_UNSETENV into separate function calls
refactor RC_DEFSLOWPASTE & RC_SLOWPASTE into separate function calls
refactor RC_MARKKEYS into separate function call
refactor RC_PASTEFONT into separate function call
refactor RC_CRLF into separate function call
refactor RC_COMPACTHIST into separate function call
refactor RC_HARDCOPY_APPEND into separate function call
refactor RC_VBELL_MSG into separate function call
refactor RC_DEFMODE into separate function call
refactor RC_AUTODETACH into separate function call
refactor RC_STARTUP_MESSAGE into separate function call
refactor RC_BIND into separate function call
refactor RC_BINDKEY into separate function call
refactor RC_MAPTIMEOUT into separate function call
refactor RC_MAPNOTNEXT into separate function call
refactor RC_MAPDEFAULT into separate function call
refactor RC_ACLCHG, RC_ACLADD, RC_ADDACL & CHACL into separate function call
refactor RC_ACLDEL into separate function call
refactor RC_ACLGRP into separate function call
refactor RC_ACLUMASK & RC_UMASK into separate function call
refactor RC_MULTIUSER into separate function call
refactor RC_EXEC into separate function call
refactor RC_DENONBLOCK & RC_NONBLOCK into separate function call
refactor RC_GR into separate function call
refactor RC_C1 into separate function call
refactor RC_DEFENCONDING & RC_ENCODING into separate function calls
refactor RC_DEFUTF8 & RC_UTF8 into separate function calls
refactor RC_PRINTCMD into separate function call
refactor RC_DIGRAPH into separate function call
refactor RC_DEFHSTATUS & RC_HSTATUS into separate function calls
refactor RC_DEFCHARSET & RC_CHARSET into separate function calls
refactor RC_RENDITION & RC_SORENDITION into separate function calls
refactor RC_SOURCE into separate function call
refactor RC_SU into separate function call
refactor RC_SPLIT into separate function call
refactor RC_REMOVE into separate function call
refactor RC_ONLY into separate function call
refactor RC_FIT into separate function call
refactor RC_FOCUS into separate function call
refactor RC_RESIZE into separate function call
refactor RC_SETSID into separate function call
refactor RC_EVAL into separate function call
refactor RC_ALTSCREEN into separate function call
refactor RC_BACKTICK into separate function call
refactor RC_BLANKER & RC_BLANKERPRG into separate function calls
refactor RC_IDLE into separate function call
refactor RC_FOCUSMINSIZE into separate function call
refactor RC_GROUP into separate function call
refactor RC_LAYOUT into separate function call
refactor RC_CJKWIDTH into separate function call
refactor RC_TRUECOLOR into separate function call
Various programs that deal with namespaces will use pty devices that exist in
another namespace. One obvious candidate are containers. So far ttyname() was
incorrectly handling this case because the pts device stems from the host and
thus cannot be found amongst the current namespace's /dev/pts/<n> entries.
Serge Hallyn and I recently upstreamed patches to glibc that allow
ttyname{_r}() to correctly handle this case. At a minimum, ttyname{_r}() will
set errno to ENODEV in case it finds that the /dev/pts/<n> device that the
symlink points to exists in another namespace.
(The next comment is a little longer but tries to ensure that one can still
understand what is going on after some time has passed.)
In case we detect that ttyname{_r}() returns NULL and sets errno to ENODEV we
have ample reason to assume that the pts device exists in a different
namespace. In this case, the code will set a global flag indicating this case
to true. Furthermore, all operations (e.g. chmod(), chown(), etc.) will now
need to operate on the symbolic link /proc/self/fd/0 directly. While this
sounds straightforward, it becomes difficult to handle this case correctly when
we reattach to an already existing screen session from a different pts device
than the original one. Let's look at the general reattach logic a little
closer:
Assume we are running a shell that uses a pts device from a different
namespace:
root@zest1:~# ls -al /proc/self/fd/
total 0
dr-x------ 2 root root 0 Apr 2 20:22 .
dr-xr-xr-x 9 root root 0 Apr 2 20:22 ..
lrwx------ 1 root root 64 Apr 2 20:22 0 -> /dev/pts/6
lrwx------ 1 root root 64 Apr 2 20:22 1 -> /dev/pts/6
lrwx------ 1 root root 64 Apr 2 20:22 2 -> /dev/pts/6
l-wx------ 1 root root 64 Apr 2 20:22 3 -> pipe:[3067913]
lr-x------ 1 root root 64 Apr 2 20:22 4 -> /proc/27413/fd
lrwx------ 1 root root 64 Apr 2 20:22 9 -> socket:[32944]
root@zest1:~# ls -al /dev/pts/
total 0
drwxr-xr-x 2 root root 0 Mar 30 17:55 .
drwxr-xr-x 8 root root 580 Mar 30 17:55 ..
crw--w---- 1 root tty 136, 0 Mar 30 17:55 0
crw--w---- 1 root tty 136, 1 Mar 30 17:55 1
crw--w---- 1 root tty 136, 2 Mar 30 17:55 2
crw--w---- 1 root tty 136, 3 Mar 30 17:55 3
crw--w---- 1 root tty 136, 4 Mar 30 17:55 4
crw-rw-rw- 1 root root 5, 2 Apr 2 20:22 ptmx
(As one can see /dev/pts/6 does not exist in the current namespace.)
Now, start a screen session in this shell. In this case this patch will have
screen directly operate on /proc/self/fd/0.
Let's look at the attach case. When we attach to an existing screen session
where the associated pts device lives in another namespace we need a way to
uniquely identify the pts device that is used and also need a way to get a
valid fd when we need one. This patch solves this by ensuring that a valid file
descriptor to the pts device is sent via a unix socket and SCM_RIGHTS to the
socket and display handling part of screen. However, screen also sends around
the name of the associated pts device or, in the case where the pts device
exists in another namespace, the symlink /proc/self/fd/0. But after having sent
the fd this part of the codebase cannot simply operate on /proc/self/fd/0 since
it very likely refers to a different file. So we need to operate on
/proc/self/fd/<fd-sent-via-SCM_RIGHTS> but also need to ensure that we haven't
been tricked into operating on a tampered with file or device. So we cannot
simply sent /proc/self/fd/0 via the unix socket. Instead we read the contents
of the symbolic link /proc/self/fd/0 in the main function and sent it via the
unix socket. Then in the socket and display handling part of screen, we read
the contents of the /proc/self/fd/<fd-sent-via-SCM_RIGHTS> as well and compare
the pts device names. If they match we know that everything is well. However,
now we also need to update any tty handling code to directly operate on
/proc/self/fd/<fd-sent-via-SCM_RIGHTS>.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Including the header in the source file guarantees matching signatures,
thus preventing subtle errors.
Self-contained headers document the required headers and makes using it
easier to use the header in new source files.
This is really to prepare for refactoring MakeWinMsgEv, which is rather large
and unnecessarily difficult to follow; this will make me much more confident
that I actually grok the code before proceeding with the unicode changes and
will further help others getting into the project.
Increase the MAXSTR macro to suit present-day needs.
Increase the maximum length of the input line buffer likewise.
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>