Commit Graph

1242 Commits

Author SHA1 Message Date
Amadeusz Sławiński
e73df890cb Refactor condition handling to use offset instead of pointer
If wmc_else() is called after wmb_expand() it can overwrite pointer to
old value. To avoid this issue refactor condition code to use offset
into parsed string instead.

Reported-by: pippin@gimp.org
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2020-01-31 23:35:14 +01:00
Alexander Naumov
a98fd8538a Copyright update for 2020 2020-01-10 21:28:01 +01:00
Alexander Naumov
4a48bb2798 Fix return code of '--version' and '-v'
Bug #57571
2020-01-10 20:27:58 +01:00
Amadeusz Sławiński
d7bd327fdf Fix code formatting
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-31 12:03:10 +01:00
Amadeusz Sławiński
9fd08507cc Fix variable type
ParseAttrColor returns uint64_t and ApplyAttrColor takes uint64_t as
argument, int was used instead, which may cause vertical bar to not have
color applied on split.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-28 23:40:18 +01:00
David Dorfman
4dd664149c Disable exclusive mode on TTY device when closing
When opening a TTY we enable exclusive mode to prevent other tools
messing with our connection. When we are done using the TTY the
exclusive mode must be disabled so the TTY can be reconnected to
later. We remember to do this when a break is sent to the device,
but not on window close.

This change ensures we disable exclusive mode on the TTY device
whenever the window is closed.

bug #52248
2019-12-28 20:24:59 +01:00
Scott Shambarger
11a1fc82fb Create TERMCAP entries limited to 1023 bytes by default.
TERMCAP_BUF defaults to 1023 to create TERMCAP entries that work on
most systems.  To save space, TERMCAP is unwrapped, and vt220 extra
keys are skipped (unless TERMCAP_BUF > 1023); navigation keys are
still included.  Entries larger than TERMCAP_BUF are now truncated,
and no longer Panic screen.

Termcap entries are still wrapped when saved to a file.

Signed-off-by: Scott Shambarger <devel@shambarger.net>
2019-12-28 13:45:48 +01:00
Christoph Moench-Tegeder
fa4f88614d Fix coredump on xterm and rxvt
Here's the rub: with TERM=xterm (or rxvt, for that matter), Km
("key_mouse", "Mouse event has occured") is not set (and therefore
NULL), but InitTermcap() (termcap.c:230) happily tries to strdup() that,
which gets us that segfault.

As a band-aid, catch that NULL and don't strdup().

Signed-off-by: Marcin Cieślak <saper@saper.info>
2019-12-28 13:43:22 +01:00
Amadeusz Sławiński
bde659b6bf Count timeout in milliseconds instead of using struct timeval
poll() accepts timeout in milliseconds, so there is no need to keep
timeout in struct timeval.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-28 13:41:59 +01:00
Amadeusz Sławiński
8becc4d29a Convert select() to poll() in sched.c
select() limits number of file descriptors that can be used by screen.
Migrate to poll() to avoid this limitation.

As can be seen in case of scheduler it requires quite some changes, care
must be taken to count poll() events properly.

Bug: 55697

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-28 13:41:53 +01:00
Amadeusz Sławiński
88add631de Convert select() to poll() in screen.c
select() limits number of file descriptors that can be used by screen.
Migrate to poll() to avoid this limitation.

Bug: 55697

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-28 13:41:48 +01:00
Amadeusz Sławiński
f253ff920c Convert select() to poll() in display.c
select() limits number of file descriptors that can be used by screen.
Migrate to poll() to avoid this limitation.

Bug: 55697

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-28 13:41:42 +01:00
Amadeusz Sławiński
3e37405972 Make closeallfiles() faster
Optimize startup time, making closeallfiles() faster, by doing less
system calls. Instead of calling close for each possible file, use
poll() to check if file exist at all. On linux with open file limit set
to 1048576, it should do 1024 poll() calls instead of 1048576 close().

Bug: 55618

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-12-28 13:41:04 +01:00
Alexander Naumov
f66377f992 Using 'https' instead of 'http' 2019-11-09 14:40:37 +01:00
Amadeusz Sławiński
39c9aea173 Update ambiguous and wide characters tables to Unicode 12.1.0
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-10-02 00:07:08 +02: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
abc87e4879 Fix broken mouse after ncurses 6.1
ncurses 6.1 changed kmous capability from "\e[M" to "\e[<". It seems to
be done to signal that terminal supports sgr mouse mode. screen assumed
that if kmous is set to "\e[M" it is on xterm compatible terminal
anyway, so just dynamically detect which one is used and override
relevant kmapdef.

InitKeytab() is moved, so kmapdef[] can be overriden before
initialization, as InitTermcap() needs to run first, as far as I can
tell this should have no consequences.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-09-07 17:58:50 +02:00
Amadeusz Sławiński
0328c657b5 Fix some gcc-9 warning in utmp
Shouldn't have really used strncpy, for something that is effectively
binary data.

Also cleanup structs when defining instead of adding memsets everywhere.
2019-05-18 18:13:34 +02:00
Amadeusz Sławiński
854c3673bb Revert "Remove unnecessary condition check"
This reverts commit ceb9b1f6ec.

I need to look at this again, there is a report that commit in question
may cause problems and apparently logic may have failed me when I
removed this code, as it probably should stay and everything after it is
unreacheable.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-05-13 18:05:46 +02:00
Amadeusz Sławiński
50a8496eb3 Clean whole buffer if we don't want to parse it
Fixes problem when pressing arrows in some prompts causes arrows to stop
in other places.

For example pressing up arrow in 'kill --confirm' prompt stops up arrow
from working on 'windowlist'

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-04-17 20:41:22 +02:00
Amadeusz Sławiński
ceb9b1f6ec Remove unnecessary condition check
According to parent "if" condition this is never the case

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-04-14 14:25:37 +02:00
Amadeusz Sławiński
6cc0088057 Close file descriptor after query command
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-04-14 00:43:27 +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
5bbf4eddfd Define data pointer in Event as void
We don't know format of data we pass around, so we may as well define
pointer as void *. Gets rid of -Wcast-align warning with clang.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-03-31 01:07:44 +01:00
Amadeusz Sławiński
8f688079be Fix D_processinputdata type
Define d_processinputdata as struct pwdata instead of doing casts back
and forth. Removes clang warning with -Wcast-align.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-03-31 01:07:44 +01:00
Alexander Naumov
8b52d122cb Copyright update for 2019 2019-03-29 20:26:32 +01:00
Alexander Naumov
e42a8cff79 Typo in man page
bug #56027
2019-03-29 20:22:12 +01:00
Stefan Assmann
7fc842ddc6 fix UTF-8 characters with more than 2 bytes
Characters are stored as uint32 nowadays. Looking at the lower bytes
only seems to be an oversight from the fontx clean up.

Fixes: f18f5d0da1 get rid of fontx
2019-03-17 14:31:45 +01:00
Amadeusz Sławiński
d2d33f6641 drop unnecessary BEL from bracketed paste mode sequence
there is no BEL in enable/disable bracketed paste mode sequence, so we
shouldn't unnecessarily print it

Bug: #55709

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-02-14 20:30:23 +01:00
Nicolas Schodet
9b0243f7ee Fix extra characters when sending a command in one go
This closes bug #52372: Giberish printed to screen window in certain
situations.

When sending "^An", most of the time, screen first receives "^A", then
it receives the "n".  This means that in the ProcessInput2 function,
ilen == 1 after the escape character has been seen, ilen is decremented
and the ProcessInput2 function returns.

When "^An" is sent in one go, for example when pasting or when using a
special shortcut, ilen is not 1 when the escape character is seen.  In
this case, the s variable was incremented, but ilen was not decremented.
This leads the function to read an extra character which does not
exists.

This regression was introduced in 2fab4d6f73, as reported in the bug
report.

This can be tested by having a command in the selection:

echo -ne '\x01n' | xclip -i

And pasting it (in this case, you might see the closing bracketed paste
sequence, but that is another problem).

Bug: #52372
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-02-11 21:59:43 +01:00
Amadeusz Sławiński
724297c2c2 make build date reproducible
Based on https://reproducible-builds.org/docs/source-date-epoch/
They suggest "BUILD_DATE ?=", but it seems to be evaluated for each file
separately, so us "BUILD_DATE :=" to set it once.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-02-02 22:35:07 +01:00
Scott Shambarger
e99eb0d101 Fix blanker to work when screen is suid root
* Change RunBlanker to call OpenDevice so permissions on slave
  PTY are correctly set.
* Update handling of file descriptors after fork to be similar to
  ForkWindow on at pty (fixes debug and leaked descriptors)
* Allow display of error message when display blocked by blanker
  (because message is probably from blanker failing to start)

Bug: 55512

Cherry-picked form screen-v4, with some modifications

Signed-off-by: Scott Shambarger <devel@shambarger.net>
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-27 16:22:20 +01:00
Scott Shambarger
b751a22e83 Prevent Panic causing Panic, and children removing sockets
* Set eff_uid/eff_gid after setuid/setgid to prevent nested Panic
  MakeClientSocket calls xseteuid(eff_uid=0) - results in nested
  Panic and SendErrorMsg not getting sent.
* Set ServerSocket to -1 after fork so that child Panic doesn't
  remove socket in eexit.

Bug: 55511

Cherry-picked from screen-v4 with some modifications

Signed-off-by: Scott Shambarger <devel@shambarger.net>
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-27 16:06:16 +01:00
Amadeusz Sławiński
30787db417 mark AttacherFinit, AttacherFinitBye & Attacher as noreturn
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-27 14:34:54 +01:00
Amadeusz Sławiński
244e1205dd mark backticks as static
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-26 19:41:05 +01:00
Amadeusz Sławiński
62d319b8a9 fix flow of 'at' command
we just returned without freeing 's' and resetting EffectiveAclUser,
which per comment at the beginning should be reset

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-26 19:40:56 +01:00
Amadeusz Sławiński
711a354ce6 sched() can be marked as noreturn
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-26 19:40:49 +01:00
Amadeusz Sławiński
b89fcbb69f remove unneeded cast
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-26 19:40:40 +01:00
Amadeusz Sławiński
8d902468e3 RunBlanker prototype should be in display.h
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-26 19:40:34 +01:00
Amadeusz Sławiński
d212513fb5 wmb_create takes no parameters
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2019-01-26 19:40:26 +01:00
Amadeusz Sławiński
b53cf27ab2 in verbose command, we can ignore return value from ParseOnOff
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-12-06 22:20:30 +01:00
Amadeusz Sławiński
af8b3fc75a in log command toggle log only if we successfully parsed argument
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-12-06 22:20:10 +01:00
Amadeusz Sławiński
a66c5fc74b in truecolor command trigger redraw only if passed correct argument
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-12-06 22:19:53 +01:00
Amadeusz Sławiński
07512f6abf don't attempt to swap window with itself
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-12-06 22:17:32 +01:00
Amadeusz Sławiński
a86b0c40d3 get rid of Wformat-overflow warning
60 characters is plenty enough for reason string

window.c: In function ‘WindowDied’:
window.c:1941:33: warning: ‘%s’ directive writing up to 99 bytes into a region of size 86 [-Wformat-overflow=]
   sprintf(buf, "\n\r=== Command %s (%s) ===", reason, s ? s : "?");
                                 ^~            ~~~~~~
window.c:1941:16: note: assuming directive output of 1 byte
   sprintf(buf, "\n\r=== Command %s (%s) ===", reason, s ? s : "?");
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
                 from logfile.h:33,
                 from window.h:39,
                 from window.c:34:
/usr/include/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output 22 or more bytes (assuming 122) into a destination of size 100
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-11-20 23:31:54 +01:00
Amadeusz Sławiński
2c816e5bc7 fix zombie command
commit f12ada8192 (refactor SwapWindows)
accidentally changed killit variable causing code to never execute

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-11-20 23:31:54 +01:00
Amadeusz Sławiński
4818b35dde check if fseek & ftell succeeded
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-11-20 23:31:47 +01:00
Amadeusz Sławiński
fb63c184c6 w_tty is an array, so we don't need to perform NULL check on it
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-11-18 23:27:40 +01:00
Amadeusz Sławiński
98d688cfb2 fix truecolor escape
it's still a hack, because to do proper detection we would need to
migrate to terminfo functions instead of termcap

Bug: 52667
Bug: 54989

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-11-18 16:28:06 +01:00
Ethan Warth
85dd33fb4d added documentation for traversal to parent group
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2018-11-18 16:26:24 +01:00