While the -version style options will work for next unknown number of
years start moving towards user interface that has way of invoking long
options as most of the other commands.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The getopt_long_only() has advantage of allowing one and two hyphen
versions of options, for example -help and --help. Secondly the getopt
function family from libc can ensure some options requiring arguments,
while other are optional, and some should not accept argument at all.
That makes option parsing more robust.
Unfortunately retiring the old option parsing makes this change greater
than preferred. Assuming not mistakes happen the new code works
functionally exactly as the old did.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The issue file escape sequences \4 and \6 prints the host IP when no
interface is specified. That's useless on some virtual machines where
gethostname()+getaddrinfo() returns 127.0.0.1.
The seems better to print IP of the "best" interface (UP, RUNNING, non-LOOPBACK)
and use gethostname() as painful fallback only.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1090935
Signed-off-by: Karel Zak <kzak@redhat.com>
For this approach do not use the ioctl TIOCMGET anymore as this
is for real serial lines only. But switch over to use the ioctl
KDGKBMODE as this is unique to the virtual console lines only.
Signed-off-by: Werner Fink <werner@suse.de>
That is that there are several consoles, the /dev/ttyS0 which
is type of ibm3215 and a dumb terminal, then there is the device
/dev/3270/tty1 which can handle ANSI color escape sequences and is
a ibm327x terminal, and the /dev/ttyS1 which is a vt220 terminal.
The macro is_speed() in agetty.c allows to distinguish between the
terminal line (/dev)3270/tty1 and the speed options on the command
line used in
/run/systemd/generator/getty.target.wants/serial-getty@3270-tty1.service
which is a symbolic link to /usr/lib/systemd/system/serial-getty@.service
Signed-off-by: Werner Fink <werner@suse.de>
The nowadays used plymouth locks the devices used for the system
console which causes that agetty as well as sulogin can not modify
the termios settings of e.g. the serial devices of the systenm console.
Signed-off-by: Werner Fink <werner@suse.de>
Remove various magic numbers with either a string lenght count, or a
symbolic variable that is recognized by gdb.
[kzak@redhat.com: - use snprintf() everywhere,
- check snprintf() return code rather than mess up
the code with strlens]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't initialize timingfd (to stderr) when -t not specified
* care about timingfd dooutput() rather in main()
* make timingdf gloval like fscript FILE
* close all in done()
* close irrelevant things in subshell and input processes
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
If both -f and -t are given, flush the timing fd on each write, similar
to the behavior on the script fd. This allows playback of still-running
sessions, and reduces the risk of ending up with empty timing files when
script(1) exits abnormally.
Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
This option caps the delay between updates, to avoid long pauses in
transcript playback.
Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.
The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.
The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.
Signed-off-by: Karel Zak <kzak@redhat.com>
- don't suppress "Script done" message in typescript file by -q
(note that -q has no effect to "Script started" message)
- simplify the code by poll()
Signed-off-by: Karel Zak <kzak@redhat.com>
The current code waits for empty file master and slave descriptors,
but it makes sense only if there is child process that cares (read)
about data in the descriptors.
Signed-off-by: Karel Zak <kzak@redhat.com>
echo "ps uf" | script
does not work because script assume that stdin is terminal and
it does not forward EOF to the pty.
This patch:
* make non-tty use-case more robust (don't call tty ioclts to
non-tty file descriptors.
* send EOF (CTL('D') control char) to the master channel when
detected eof by read() on stdin
* wait for empty master and slave file descriptors to be sure that
we don't miss date for typescript. This is also necessary to be
sure that slave channel (shell) is completely initialized otherwise
EOF is ignored.
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
It seems that setterm -dump does not dump terminal attributes, but
the man page says -dump includes the attributes. Let's fix the man
page.
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
which is due legacy reasons a block terminal of type 3270 or higher.
Whereas the second serial line on a S/390(x) is a real character
terminal which is compatible with VT220.
Signed-off-by: Werner Fink <werner@suse.de>
* it seems that we don't have to link the utils with ncurses, tinfo is enough.
This change saves one unnecessary dependence.
* libtinfo is also distributed with pkg-config files, so we can use
PKG_CHECK_MODULES() as a primary source for LIBS and CFLAGS.
* add TINFO_CFLAGS (although it's probably always empty)
Signed-off-by: Karel Zak <kzak@redhat.com>
If we are not on glibc, __GNU_LIBRARY__ will not exist causing the check
to always fail and try to use syscalls directly.
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
The ncurses package has been providing pkg-config files for a while now.
So let's start using them to get the proper linker & compiler flags. It
can make a difference when ncurses is configured in a way that requires
extra link time flags but util-linux doesn't provide them, or when the
headers live in a weird place and util-linux can't find them.
Since the NCURSES_LIBS is always defined for the Makefile, there's no need
to gate on the HAVE_NCURSES conditional. When it's disabled, the var will
simply be empty.
With a minor tweak to how tinfo is handled, we can do the same thing -- we
just always use TINFO_LIBS in the Makefile's.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The ncurses term.h header has logic in it to detect if nucrses.h has
already been included and void defining things when it has. But since
setterm includes term.h and the ncurses.h, it doesn't work and we can
get fun build-time warnings like:
CC term-utils/setterm-setterm.o
In file included from term-utils/setterm.c:109:0:
/usr/include/ncursesw/ncurses.h:827:12: warning: redundant redeclaration of 'tigetflag' [-Wredundant-decls]
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *); /* implemented */
^
In file included from term-utils/setterm.c:106:0:
/usr/include/ncursesw/term.h:775:12: note: previous declaration of 'tigetflag' was here
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
^
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This patch allows to use a new \S or \S{VARNAME} sequence in the
/etc/issue file. The sequence prints data from /etc/os-release. The
reason is to keep /etc/issue file distribution and release
independent.
The \S{ANSI_COLOR} is converted to the real terminal escape seq.
For example:
\S
Kernel \r on an \m (\l)
or more complex example:
Welcome to \S{ANSI_COLOR}\S{NAME}0m \S{VERSION}
Report bugs at \S{BUG_REPORT_URL}.
See http://www.freedesktop.org/software/systemd/man/os-release.html
fr more details about /etc/issue.
Based on patch from Bill Nottingham <notting@redhat.com>.
Signed-off-by: Karel Zak <kzak@redhat.com>