Commit Graph

619 Commits

Author SHA1 Message Date
Amadeusz Sławiński
65aea38433 stop clobbering display variable
not sure why it was done, but it seems to serve no functional purpose at
all and breaks displaying flags in :windowlist
display is used by AddWindowFlags to check whether we should show some
of flags and they are not shown when display == 0

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2017-08-02 14:21:58 +02:00
Amadeusz Sławiński
f64cff77bd check if display exists before dereferencing it
Bug: 43054
Bug: 51500

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2017-08-02 14:18:34 +02:00
Amadeusz Sławiński
9c9bdcbcd9 Release v.4.6.1 v.4.6.1 2017-07-10 21:25:10 +02:00
Amadeusz Sławiński
ca4f7503e5 fix segfault when querying info on nonUTF screen
Bug: 51402
2017-07-10 21:06:11 +02:00
Matt Whitlock
7dad1f268f Fix parallel make install
Fixes:
https://bugs.gentoo.org/show_bug.cgi?id=611130
2017-07-01 21:44:00 +02:00
Clark Wang
0f5e9affa4 restore missing code which was wrongly removed
fixes regression introduced by migrating from pipe to sockets
http://lists.gnu.org/archive/html/screen-users/2017-06/msg00001.html
2017-07-01 21:32:43 +02:00
Amadeusz Sławiński
f8fb068b51 Release v4.6.0 v.4.6.0 2017-06-28 20:08:56 +02:00
Guo Ci
afa26c59ca begin viewing scrollback buffer at the first line of output instead of at the start of the scrollback buffer
This issue has been discussed before:
https://bbs.archlinux.org/viewtopic.php?id=108640

Copy mode and “hardcopy -h” always begin at the start of the scrollback buffer.
If a user sets a large scrollback limit with little output, then copy mode and
the file written by “hardcopy -h” will begin with many blank lines before the
first line of output.

The attached patch limits the scrollback buffer traversal to begin at the first
line of output, instead of the beginning of the scrollback buffer.

Also, code for moving to %age of buffer is changed to use float division so
that two different rep_cnt will not jump to the same location, except for
buffers less than 100 lines. Previously, the computed line number is rounded
down to the nearest 100th due to integer division.

Bug: 49377
2017-06-22 11:01:14 +02:00
Brian De Wolf
c10e997899 update unicode wide tables
Bug: 50044
2017-06-21 22:54:01 +02:00
Amadeusz Sławiński
49dd273566 Add more serial speeds
make idx unique
reorder from highest speed to lowest
2017-06-09 11:03:56 +02:00
Christian Brauner
79f755ff5c screen: don't stat("")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-05-30 22:12:25 +02:00
Amadeusz Sławiński
50b576fbeb fix typos 2017-04-18 13:19:46 +02:00
Christian Brauner
bab73f99a2 add compat layer to handle both fifos and sockets
So far screen could only support either sockets or fifos but not both. This
proved to be a blocker for any upgrade. This adds a compatibility layer to
screen v4 to support both sockets and fifos at the same time. The strategy here
is to only support fifos for legacy sessions that already exist. All new
sessions will use sockets by default.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-04-18 10:53:29 +02:00
Amadeusz Sławiński
8062db33b8 fix restoring cursor position after leaving altscreen
When swapping to altscreen, also swap cursor position

Bug: 49883
2017-04-06 11:34:04 +02:00
Christian Brauner
7e755ed62d 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:14:20 +02:00
Christian Brauner
78d2a73273 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:01:27 +01:00
Samuel Thibault
12a4b7c407 fix mixing external & internal TERM
Bug: 50588
2017-03-22 09:46:02 +01:00
Eric S. Raymond
d5ab32e1d6 Cleanup patch for man page 2017-03-01 21:37:59 +01:00
Andreas Stieger
a7d2f9e6ec [PATCH] fix texinfo syntax errors
thanks to Andreas Stieger <astieger@suse.com>
2017-02-28 19:23:01 +01:00
Alexander Naumov
bc5ea98756 Release v4.5.1 v.4.5.1 2017-02-22 21:19:14 +01:00
Alexander Naumov
5d1641acdd bugfix: Screen doesn't build on SunOS
bug #50089
2017-02-15 20:32:13 +01:00
Alexander Naumov
6994c70aa1 limits.h => PATH_MAX for SunOS
bug #50089
2017-02-13 21:28:00 +01:00
Alexander Naumov
74c5883c47 "-Logfile" set logfile only (doesn't turn on logging) 2017-02-08 22:10:48 +01:00
Alexander Naumov
24df03b670 misprint in help.c 2017-02-08 21:57:49 +01:00
Alexander Naumov
a38de4e662 adding "-Logfile" option to help 2017-02-08 21:54:20 +01:00
Amadeusz Sławiński
13183da34e update documentation "-L logfile" -> "-Logfile" 2017-02-07 22:56:43 +01:00
Amadeusz Sławiński
18193bc7b2 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:50:51 +01:00
Alexander Naumov
1c6d281792 CVE-2017-5618: secure open/close logfile
bug #50142

Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2017-02-06 22:50:03 +01:00
Axel Beckert
6e60d12bb2 Fixed some typos found by Lintian
Author: Axel Beckert <abe@debian.org>
Bug-Debian: https://bugs.debian.org/741141
2017-02-03 22:54:32 +01:00
Amadeusz Sławiński
a8c0d68f66 Z0width & Z1width are only assigned once, make them const
It's modified cherry-pick of f4e6265c8b
from master branch.

Fix: 50197
2017-02-01 15:54:21 +01:00
Alexander Naumov
d6c724ad53 Adding "-L logfile" option for setting new logfile's name
Now it's possible to set your own lofile name with
this option ONLY. It fixes also API of old versions.
2017-01-26 23:44:43 +01:00
Alexander Naumov
2141512c94 Replace screenlogfile only if it's needed 2017-01-24 23:52:21 +01:00
Alexander Naumov
9054e9fc4a Division by zero! Solution needed 2017-01-21 03:03:11 +01:00
Alexander Naumov
bd37ae4f27 Value stored to 'i' during its initialization is never read
i.e. we initialize 'i' twice (next line)
2017-01-21 02:31:50 +01:00
Alexander Naumov
5c3d9d4b20 Value stored to 'av' during its initialization is never read
i.e. we initialize 'av' twice
2017-01-21 02:18:39 +01:00
Alexander Naumov
5fd82c69bd Value stored to 'num' is never read 2017-01-21 02:12:04 +01:00
Alexander Naumov
c14e05e7c3 Ignore logfile's name that begins with the "-" symbol
This fixes API:
To enable logging we use -L option. But in case of
default logfile name (screenlog.0) we will need to
define it anyway. Because screen will try to interpret
next option as a parameter for -L option (which is
logfile name). It will fails ALWAYS, because next
parameter will always start with "-" symbol...
what is not permited for logfile name of course.

For example:
$ screen -L -D -m ./configure
In this case logfile name is screenlog.0, because "-D"
will not be interpreted by screen as a name of logfile.

Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2017-01-21 01:08:36 +01:00
Alexander Naumov
285868e0e4 variable 'oldtop' set but not used 2017-01-19 22:01:09 +01:00
Alexander Naumov
6a5f8ac1cf Refactoring + 'olddisplay' is never read (LayPause) 2017-01-19 13:10:46 +01:00
Elan Ruusamäe
0b7bcd4302 [PATCH] restore comparision not to be bitwise 2017-01-19 11:47:38 +01:00
Alexander Naumov
5c19a24dc9 Release v4.5.0
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
v.4.5.0
2016-12-07 20:27:55 +01:00
Alexander Naumov
b50e50c454 Build bugfix for AIX
bug #49149
Thanks to Tony Reix
2016-12-06 16:05:57 +01:00
Alexander Naumov
b0765867b3 Help message knows about log filename (-L)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-12-06 15:34:58 +01:00
Alexander Naumov
c3384882db Code reformating (layout.c + logfile.c)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-11-06 12:55:11 +01:00
Alexander Naumov
c8a795edf3 Code reformating (fileio.c)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-11-05 17:54:23 +01:00
Alexander Naumov
a82e1bded5 Code reformating (viewport.c)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-11-05 16:20:17 +01:00
Alexander Naumov
af78ba71b8 Code reformating (help.c)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
2016-11-05 15:56:08 +01:00
Amadeusz Sławiński
51a84088f0 fix %x improperly separating arguments
thanks to canvon from irc
2016-11-04 19:50:13 +01:00
Alexander Naumov
5460f5d28c 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:14:00 +01:00
Amadeusz Sławiński
3aa5ba0598 fix term size in reply 2016-10-28 21:01:34 +02:00