Commit Graph

21 Commits

Author SHA1 Message Date
Karel Zak 726ffb4a26 login: move generic setting to ttyutils.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 11:46:10 +01:00
Sami Loone ee978576b1 agetty: tty eol defaults to REPRINT
Adapting tty eol settings from defaults misbehaves as CTRL('r') aka
REPRINT is confused with CR. Consequently --skip-login does not set
tty CR<->NL translations and thus acts against advertised CR as eol
default.

[kzak@redhat.com:
   It seems this issue has been introduced by commit f566447 where we
   merged sulogin and agetty terminal initialization together to the file
   include/ttyutils.h.

  The original agetty has really used .eol=13 (aka CR) for the default.
  The problem is invisible for sulogin(1) because it always asks for a
  password and .eol= is set to NL/CR, the same agetty when it asks for
  username.]

Addresses: https://github.com/karelzak/util-linux/pull/1247
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-10 17:48:46 +01:00
Karel Zak a6d9d23b5f lib/ttyutils: introduce get_terminal_stdfd()
Let's use separate function to detect what is the current terminal.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-27 12:49:12 +02:00
Sevan Janiyan 671295131e include/ttyutils: define values if missing.
Upstreamed from pkgsrc.

Addresses: https://github.com/karelzak/util-linux/pull/695
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-03 15:43:45 +02:00
Karel Zak 4d9b788d64 script: add more info to script header
This patch introduces [...] to store extra information about terminal
to the typescript header. For example:

  Script started on 2018-05-14 12:52:32+02:00 [TERM="xterm-256color" TTY="/dev/pts/3" COLS="190" LINES="53"]

or

  Script started on 2018-05-14 12:54:01+02:00 [<not executed on terminal>]

if stdout is not terminal.

Addresses: https://github.com/karelzak/util-linux/issues/583
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-14 12:51:50 +02:00
Karel Zak f46a8d7e66 lib/ttyutils: return terminal lines too
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 11:38:38 +02:00
Sami Kerola 285c1f3a3e
lib: try to find tty in get_terminal_name()
Try all standard terminal input/output file descriptors when finding tty
name in get_germinal_name().  This should make all invocations of the
function as robust as they can get.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-03 23:35:10 +01:00
Boris Egorov 43b4f7ea5f lib/tty: Pass default width to get_terminal_width()
Almost any code calling get_terminal_width() checks returned width for
non-positive values and sets it to some default value (say, 80). So,
let's pass this default value directly to the function.

[kzak@redhat.com: - get_terminal_width() refactoring]

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-06 12:22:07 +01:00
Christoph Egger c32270d41f agetty: fixing FTBFS on !linux (Debian util-linux 2.20.1-1.2)
Handle vc flags missing on FreeBSD
Fix tty creation on kFreeBSD taking patch from 2.19

Addresses-Debian-Bug: #650185
2014-09-17 10:14:50 +02:00
Michael Forney 00c505d9cf include: Add missing includes
sys/types.h: For u_char typedef
sys/params.h: For MAXNAMLEN
sys/ttydefaults.h: For various tty definitions (also add configure check)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-04 11:51:21 +02:00
Karel Zak b8b8e76806 agetty: don't remove ECHOCTL from c_lflag
It's really unexpected that arrows keys move cursor when agetty/login
asks for login name or password.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=969458
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-03 14:06:18 +02:00
Karel Zak 507341f832 lib/tty: don't hardcode terminal fd in get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13 15:40:57 +02:00
Werner Fink f5664477cb include/ttyutils: add default chardata
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c.  Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.

[kzak@redhat.com: use macro rather than global variable for default
                  chardata]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:42:12 +01:00
Karel Zak 0f23ee0c85 include: cleanup copyright headers
We use the code from include/ and lib/ on many places, so use public
domain if possible or LGPL for code copied from libs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:10:17 +01:00
Karel Zak a73f59fa03 sulogin: remove consoles.c from libcommon
- move struct chardata to include/ttyutils.h
- move console.{h,c} to login-utils/sulogin-* (it's sulogin specific)
- fix sulogin and agetty includes

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:14:21 +01:00
Karel Zak 1ef28920f8 lib/ttyutils: add get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:40:14 +01:00
Karel Zak 4e76adb0e1 lib/ttyutils: create .c file
Well, now all tty stuff are incline functions in include/ttyutils.h.
It's seems more elegant to create regular lib/ttyutils.c for libcommon
and write test program.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:26:41 +01:00
Karel Zak 7e9a9af14f include/ttyutils: more robust get_terminal_width()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 11:58:20 +02:00
Petr Uzel e872e32064 include: move get_terminal_width() to ttyutils.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:53 +02:00
Dave Reisner 0b6198ec07 include/ttyutils.h: add include guards
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-20 09:53:48 +01:00
Karel Zak 879a7ab470 agetty: move vc initialization to ttyutils.h
... to make the code usable for sulogin.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-12 14:39:32 +01:00