Commit Graph

95 Commits

Author SHA1 Message Date
Alexander Naumov
7bd2413965 New command 'auth' for password protection
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2024-08-02 17:54:16 +02:00
François Revol
f251537616 fix mismatched types in prototype
not everyone defines pid_t as int...
2020-02-03 22:43:29 +01:00
Alexander Naumov
f66377f992 Using 'https' instead of 'http' 2019-11-09 14:40:37 +01:00
Amadeusz Sławiński
0c49b92adb Get rid of externs in telnet.c
Just include correct headers.
We need to expose af properly in screen.h for this to work.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-09-19 23:13:07 +02:00
Amadeusz Sławiński
4e545ba086 Fix -L option when passed to backend via Msg
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>
2019-04-13 16:08:36 +02:00
Amadeusz Sławiński
434b27c128 clean up after refactoring
finally we can get rid of wtab and maxwin
2018-04-11 21:42:16 +02:00
Amadeusz Sławiński
da4a425fcc create bidirectional list of windows 2018-04-11 21:42:16 +02:00
Amadeusz Sławiński
8be327be94 rename windows to mru_window and window->w_next to window->w_prev_mru
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)
2018-04-11 21:42:16 +02:00
Amadeusz Sławiński
81a2699fdd use NULL instead of 0 where applicable
found with sparse
warning: Using plain integer as NULL pointer
2018-04-06 00:18:33 +02:00
Amadeusz Sławiński
461f0ad0c4 refactor DoAction switch into calling functions
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
2018-04-06 00:18:32 +02:00
Amadeusz Sławiński
aada2d78ac use ARRAY_SIZE for SocketPath size
while at it make its size more reasonable
2018-04-06 00:18:32 +02:00
Amadeusz Sławiński
dc5661bde1 mark Finit as noreturn
fixes -Wimplicit-fallthrough warning
2018-02-07 00:16:56 +01:00
Amadeusz Sławiński
612ade8edd fix failure if compiling with TIOCKSET
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2017-07-09 23:51:09 +02:00
Amadeusz Sławiński
6724ef2529 dynamically allocate windows
Bug: 23691
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2017-07-09 23:50:53 +02:00
Christian Brauner
565b8901ca screen: handle pts devices in different namespaces
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>
2017-04-06 10:19:16 +02:00
Amadeusz Sławiński
972f5241fd header updates
remove unneeded headers from screen.h
move winmsg, so it's "sorted"
2016-11-15 22:23:35 +01:00
Amadeusz Sławiński
62370e3a2e type fixing, make *_uid uid_t 2016-06-20 19:41:00 +02:00
Amadeusz Sławiński
9d035613cd change various pid variables type to pid_t from int 2016-06-20 00:16:18 +02:00
Amadeusz Sławiński
df1c012227 rewrite configure.ac from scratch
basic support to make it build, needs to be expanded
2016-06-18 15:08:28 +02:00
Simon Ruderich
263d9c6c8d make all header files self-contained and include it in the source file
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.
2016-02-07 17:57:37 +01:00
Amadeusz Sławiński
ec2f333605 remove unneeded idx field from struct baud_values 2016-02-07 17:41:33 +01:00
Amadeusz Sławiński
63cd6e6529 move WindowDied() to proper file 2016-01-15 23:07:17 +01:00
Amadeusz Sławiński
cd6ece75aa convert aflag to bool 2015-12-22 18:35:25 +01:00
Amadeusz Sławiński
37ca949e46 Fix more hardcoded termlen 2015-12-06 13:44:53 +01:00
Amadeusz Sławiński
bdeb037e10 more type conversions to bool 2015-12-06 12:53:04 +01:00
Amadeusz Sławiński
dbc35f6dd8 struct msg -> Message 2015-09-02 16:40:23 +02:00
Alexander Naumov
d2d1c24512 fix: comparison between signed and unsigned integer expressions
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2015-07-14 23:23:24 +02:00
Amadeusz Sławiński
9668a1ab00 Add 'truecolor [on|off]' as it cannot be correctly detected
https://lists.gnu.org/archive/html/bug-ncurses/2013-10/msg00007.html

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2015-07-02 14:11:17 +02:00
Mike Gerwitz
8f8679d718 Began refactoring winmsg code into its own file
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.
2015-06-26 15:16:17 +02:00
Amadeusz Sławiński
b119f4e725 windows have unsigned numbers 2015-06-26 14:09:45 +02:00
Amadeusz Sławiński
97b2ec0ed4 move global variables declarations to corresponding headers 2015-06-26 12:30:55 +02:00
Amadeusz Sławiński
3d232f7412 use Event type instead of struct event 2015-06-26 11:37:25 +02:00
Amadeusz Sławiński
7dd44046c9 use Window type instead of struct win 2015-06-26 10:52:01 +02:00
Amadeusz Sławiński
144836c3bb more header stuff
move forward declarations of functions from extern.h to their own header
files
fix inclusion option passed in Makefile
cosmetic stuff on some structs
2015-06-25 17:22:58 +02:00
Amadeusz Sławiński
55f5f925a8 include headers once + some struct reformatting 2015-06-25 17:05:32 +02:00
Amadeusz Sławiński
272b68b2ec bye bye DEBUG 2015-06-25 17:05:31 +02:00
Amadeusz Sławiński
2494d4cd3e replace NAME_MAX with FILENAME_MAX 2015-06-25 16:39:40 +02:00
Amadeusz Sławiński
b4a4d5becf -Wall -Wextra warnings about empty else's
suggesting empty {}
2015-06-25 15:53:35 +02:00
Amadeusz Sławiński
9c1722e63b Simplify debugging macros 2015-06-25 15:52:13 +02:00
Amadeusz Sławiński
9c3a98ba64 trailing whitespace removal 2015-06-25 15:52:13 +02:00
Amadeusz Sławiński
3e398fba7b More removal, mainly SYSV SYSVSIGS
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2015-06-25 14:59:50 +02:00
Amadeusz Sławiński
0b75e83673 removal of #define NONLINUXOS etc. 2015-06-25 14:57:12 +02:00
Amadeusz Sławiński (amade)
0dc672562b replace some of strcpy with strncpy
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2015-06-25 14:35:22 +02:00
Amadeusz Sławiński (amade)
2168239005 make most features as always built in from now on
removed #define SIMPLESCREEN and it's #defines
also removed #define DETACH and RXVT_SOC
all of this options are now default
2015-06-25 14:28:20 +02:00
Amadeusz Sławiński
0c334bcf3c remove osdef
inspired by 18c44170a9

put curses stuff it term.sh, it's actually in /usr/include/term.h
but it will mess up build if included directly
2015-06-25 14:20:13 +02:00
Amadeusz Sławiński
b296029332 remove __P macro it's obsolete
inspired by a434e5d612
2015-06-25 14:19:28 +02:00
Amadeusz Sławiński
ae76b78836 Bump msg struct version
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2014-04-28 00:08:09 +02:00
Jan Christoph Nordholz
ee3ba201b7 increase size of MAXSTR and input line buffer
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>
2014-04-25 13:46:20 +02:00
Amadeusz Sławiński
fe8103cccd allow for defining term and login length if needed
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2014-04-22 18:25:46 +02:00
Amadeusz Sławiński
b62e4ef097 Allow screen to run for users with long logins
username can have up to 32 characters

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2014-04-22 14:15:32 +02:00