Commit Graph

1137 Commits

Author SHA1 Message Date
Amadeusz Sławiński
5db5fe4511 enable PAM by default, print configuration on ./configure
also add BIG warning for people trying to build without it, basically
running screen as root may make sense on some embedded linux, where you
don't have users, but everyone else should use PAM

while at it improve ./configure output to show final configuration

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2017-06-10 18:18:20 +02:00
Amadeusz Sławiński
c68a4731d4 fix crash when build without PAM support
apparently crypt and getspnam, don't need to be freed, as the buffer
gets reused by library, if we ever call them again...

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2017-05-30 23:27:06 +02:00
Neal Fultz
945ad54142 Adding status escape for window group 2017-05-30 22:23:03 +02:00
Christian Brauner
5f165d54d3 screen: do not stat("")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-05-30 22:12:07 +02:00
Amadeusz Sławiński
d97d36e695 fix typo 2017-04-18 13:20:23 +02:00
Amadeusz Sławiński
5716ed40b2 use library sleep functions 2017-04-13 09:40:11 +02:00
Amadeusz Sławiński
ec9b396fce use str(n)dup instead of reinventing the wheel 2017-04-12 14:07:40 +02:00
Amadeusz Sławiński
a48e1f96dc fix restoring cursor position after leaving altscreen
When swapping to altscreen, also swap cursor position

Bug: 49883
2017-04-06 11:27:27 +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
Christian Brauner
fbee2ab0bc handle pty device from different namespace
Various programs that deal with namespaces will use pty devices that exist in
another namespace. One obvious candiate 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. This commit will allow screen to handle this case
and behave correctly in a container.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-03-24 14:04:30 +01:00
Samuel Thibault
a58f8d7e17 fix mixing external & internal TERM
Bug: 50588
2017-03-22 09:41:01 +01:00
Alexander Naumov
556ac69de7 SYNC doc/screen.texinfo 2017-03-01 22:20:20 +01:00
Alexander Naumov
7e66a71b20 adding copyright 2017-03-01 21:46:24 +01:00
Alexander Naumov
2f725b744a SYNC man-page with screen-v4 2017-02-28 20:48:06 +01:00
Amadeusz Sławiński
4cc0a2897f merge 2 ifs into one in win_readev_fn
makes it similar to what happens in pseu_readev_fn
2017-02-16 13:49:20 +01:00
Amadeusz Sławiński
ca5179e4c6 change l_mouseevent struct types 2017-02-15 16:35:37 +01:00
Amadeusz Sławiński
e48ad763ab make parse_input_int len arg size_t 2017-02-15 12:45:02 +01:00
Amadeusz Sławiński
d17ed7a89a make MakePaster len arg size_t 2017-02-15 12:45:02 +01:00
Amadeusz Sławiński
2fab4d6f73 use size_t in ProcessInput 2017-02-15 12:45:02 +01:00
Amadeusz Sławiński
e572f21e10 cosmetic type and name changes 2017-02-15 12:45:02 +01:00
Alexander Naumov
5615353ccb adding "-Logfile" option to help 2017-02-14 22:52:28 +01:00
Alexander Naumov
59b88a8411 limits.h => PATH_MAX for SunOS
bug #50089
2017-02-13 21:21:29 +01:00
Amadeusz Sławiński
e76e2d2780 update documentation "-L logfile" -> "-Logfile" 2017-02-07 22:57:12 +01:00
Amadeusz Sławiński
edd936db20 make -L logfile into separate -Logfile parameter
Also drop file checking, as it became clear that it doesn't make much
sense for example with "-Logfile 'logfile.%n'" each window would have
it's own logfile and in theory we would need to check them all and still
someone could prevent us to open logfile at runtime due to creating
conflicting file with properly crafted permissions, before we open a
window.
2017-02-07 22:52:17 +01:00
Alexander Naumov
0995171023 Documentation (man page + info) about 'logfile' option 2017-02-03 22:17:02 +01:00
Alexander Naumov
99f39ceee7 CVE-2017-5618: secure open/close logfile
bug #50142

Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2017-02-03 21:44:52 +01:00
Amadeusz Sławiński
f84fc79470 make variable bool 2017-01-22 16:11:08 +01:00
Amadeusz Sławiński
a57f6c71ae u_plop, int len -> size_t len 2017-01-22 16:09:15 +01:00
Amadeusz Sławiński
ab026a8f0c more int len to size_t len 2017-01-22 16:05:36 +01:00
Amadeusz Sławiński
c9d0520e8d quiet down warn_unused_result warning 2017-01-18 18:45:11 +01:00
Amadeusz Sławiński
8e1fe11cee fix s->st_size being potentially garbage 2017-01-18 18:45:11 +01:00
Amadeusz Sławiński
6f03f0ea3e Value stored to 'l' is never read 2017-01-18 18:45:11 +01:00
Amadeusz Sławiński
f21bbdb9b6 Value stored to 'SocketDir' is never read 2017-01-18 18:45:11 +01:00
Amadeusz Sławiński
5f24e531bf Value stored to 'user' is never read 2017-01-18 18:45:11 +01:00
Alexander Naumov
c1c7b35e96 Help message knows about log filename (-L)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-12-06 15:25:21 +01:00
Amadeusz Sławiński
aa12c59e14 remove unneeded files
built-in braille support leftovers
2016-11-23 19:45:55 +01:00
Amadeusz Sławiński
4ce3baa5ad revvid is bool 2016-11-23 19:45:55 +01:00
Amadeusz Sławiński
b146957cea remove unused field from Window struct 2016-11-23 19:45:55 +01:00
Amadeusz Sławiński
0080a23a6f get rid of global cols & rows variables 2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
1b1dde1264 get rid of global 'curr' variable 2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
d0134af13b WChangeSize is local to ansi.c, make it static 2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
2c20f10358 fix type mismatch warning 2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
ec65b5400a remove ALLOW_SYSCREENRC
it seems like ill advised feature to me, possibility of overriding
system configuration file, looks like asking for problems to me
2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
fd327b619c quiet down warnings
bit ugly...
2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
57cfa2dba4 quiet compiler warning
we don't use pty when doing telnet connection
2016-11-16 19:14:54 +01:00
Amadeusz Sławiński
ecbcf4663d small Makefile updates 2016-11-15 22:23:38 +01: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
62e29b7b0e remove unneeded extern 2016-11-15 22:23:31 +01:00
Amadeusz Sławiński
8a8186850a More type fixes 2016-11-15 22:23:28 +01:00
Alexander Naumov
c575c40c9b adding permissions check for the logfile name
Screen shows error message and terminates if you
specify not available (permissions problem?) logfile
name (-L parameter).

bug #49491

Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-11-04 14:25:27 +01:00