This command has a lot of compile time #ifdef code. It is time to add
feature listing to --version output so understanding command behavior is
easier.
Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
There is no ./configure option to enable this, and it is unlikely any
distribution hot patching to enable fiddling when building package.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
[kzak@redhat.com: - merge two patches from Antonio to the one,
- update the patch]
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Antonio Ospite <ao2@ao2.it>
This script requires ncurses to work, and the ncurses provides reset so
there should not be need to keep this script hanging around.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The current --skip-login implementation disables also issue file
printing. This is unexpected behavior as /etc/issue may contains
important information and we have --noissue for admins who don't want
it.
This patch forces /etc/issue printing if --noissue no specified.
Addresses: https://github.com/karelzak/util-linux/issues/480
Signed-off-by: Karel Zak <kzak@redhat.com>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 'usage-part2' of https://github.com/rudimeier/util-linux:
misc: cosmetics, remove argument from usage(FILE*)
misc: cosmetics, remove argument from usage(int)
misc: never use usage(stderr)
misc: never use usage(ERROR)
misc: cleanup and fix --unknownopt issues
flock, getopt: write --help to stdout and return 0
tools: add checkusage.sh
Earlier when typescript file failed new line after the error did not cause
carriage return. Here is an example how prompt> travels to wrong place:
prompt> script 0500-perms/typescript
Script started, file is 0500-perms/typescript
script: cannot open 0500-perms/typescript: Permission denied
prompt>
But that wasn't quite as bad as what happen with timing file, that at
failure left terminal to state where a reset(1) run was needed.
[kzak@redhat.com: - move code to restore_tty()]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
agetty refresh prompt (/etc/issue file etc.) when requested by inotify
or netlink. For this purpose we monitor some file descriptors by
select().
The terminal input file descriptor is switched to non-canonical mode before
select(). The goal is to be informed about user activity before
new-line. The FD is immediately switched back to canonical mode when
activity is detected. The side effect is that all not-read-yet chars in
the input buffer are lost ... so we need to call read() before switch
to canonical mode to save the chars.
The original implementation has been based on TIOCSTI ioctl. It
returns already read chars back to the terminal input buffer to make
them useful for canonical mode. The problem was race (agetty writes to
input buffer in the same time as user) and result was reordered chars
in login name... so useless.
This issue has been later fixed by extra buffer (commit
790119b885) for already read data. And
TIOCSTI ioctl has been removed. Unfortunately this solution is also
wrong, because the buffer is maintained only by agetty and
inaccessible for terminal when user edit (by DEL/CTRL^U) login name in
canonical mode.
The solution is simple -- just don't try to be smart and keep terminal
in canonical mode all time (so terminal controls DEL, CTRL^U, etc) and
flush input buffer (=discard unread data) and ask user for login name
again after prompt reload.
The agetty reload is very rarely situation and for user it's pretty
obvious that he has to type login name again (as all terminal has been
clear+redraw).
Addresses: https://github.com/karelzak/util-linux/issues/454
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1464148
Signed-off-by: Karel Zak <kzak@redhat.com>
This was the compiler warning:
term-utils/wall.c:156:39: warning: passing 'gid_t *const' (aka 'unsigned int *const') to
parameter of type 'int *' converts between pointers to integer types with different sign
[-Wpointer-sign]
rc = getgrouplist(login, pw->pw_gid, buf->groups, &ngroups);
^~~~~~~~~~~
/usr/include/unistd.h:653:43: note: passing argument to parameter here
int getgrouplist(const char *, int, int *, int *);
^
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
(Original patch and commit message edited by Rudi.)
gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.
We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* assume ncursesw headers in ncursesw/ directory only
* prefer long paths, <term.h> and <ncurses.h> should be last
possibility
* fix typos
Signed-off-by: Karel Zak <kzak@redhat.com>
Without this change an attempt to remove hostname printing required following
rather clumsy agetty invocation.
/sbin/agetty --nohostname --login-options '/bin/login -H -- \u'
After the change --nohostname behaves similar way with --host option, that
is when combined with --remote the effect is passed to login(1).
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The current agetty uses TIOCSTI ioctl to return already read chars
from login name back to the terminal (without read() before
tcsetattr() we will lost data already written by user). The ioctl
based solution is fragile due to race -- we can return chars when
terminal already contains another new chars. The result is reordered
chars in login name.
The solution is to use extra buffer for already read data.
Reported-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer
Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.
Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Reset terminal size by assessing maximum row and column. This is useful
when actual geometry and kernel terminal driver are not in sync.
Addresses: http://bugs.debian.org/835636
Based-on-work-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use consistent terminology for set-user-ID and set-group-ID bits.
There's much inconsistency in the pages. "suid",
"set-user-identifier", "setuid". Stick with one terminology,
"set-user-ID" and set-grout-ID, as suggested in man-pages(7).
Signed-off-by: <mtk.man-pages@gmail.com>
In the majority of pages, pathnames are formatted as Italic,
which is the norm. However, there are several cases where they
are formatted as bold. This patch fixes a number of those
exceptions.
Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
Now the build will fail on many non-Linux systems because
utmpx.h is available everywhere but we still use non-POSIX
features. We'll fix this next commit.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
_HAVE_UT_TV is glibc only. Moreover we want to move to utmpx where
timeval is standard.
Now utmp/subsecond (1173d0a6) should work on all supported systems.
CC: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The wall command on AIX supports a "-g" option to limit the message
to a group of users by gid. Add compatibility to the Linux version.
Thanks to Sami Kerola <kerolasa@iki.fi> for an initial skeleton
implementation.
[kzak@redhat.com: - rename max to ngroups
- add free_group_workspace()
- some cosmetic changes]
Reference: http://www.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.cmds6/wall.htm
Signed-off-by: Jim Patterson <jimp@wegrok.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch does only the following:
* Order SEE ALSO entries first by section name, then alphabetically
within section
* Adds one or two missing commas in SEE ALSO lists
* Removes one or two periods that were (inconsistently) used
at the end of SEE ALSO lists.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
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>
Add both path and tty name representations of tty's to control structure,
that point to same string beginning from different depths. This way there
is no need to removing and adding /dev/ in front of tty string all the time.
Secondly this change makes it possible to use of get_terminal_name() from
ttyutils.c.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Most commonly this error happens when write(1) executable does not have
correct group ownership and setgid bit. The earlier message was unclear
what exactly was wrong.
$ mesg
is y
$ write testuser
write: you have write permission turned off
Alternatively the 'getegid() == s.st_gid' could be considered unnecessary.
Afterall if to write to destination tty is denied that does not go unnoticed
at thet time when tty is opened.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Function like macros make following the execution flow unnecessarily
difficult, and deserves to be removed.
Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
By looking the code one will had hard time knowing that a slice of ctime()
from characters 11 to 16 is HH:MM time format. Use of strftime("%H:%M")
makes this a lot less mysterious.
In same go make \007 hex printouts to be \a that is the same thing: alarm.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
glibc documentation tells getutent() calls are not thread safe, and
recommends to copy the context of the structures when information is wished
to be stored. This leads to excessive copying, that in this case is not
relevant. write(1) is single threaded program and there is no reason to
assume this would change in future.
Reference: http://www.gnu.org/software/libc/manual/html_node/Manipulating-the-Database.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier use of _exit() caused program to terminate abnormally from atexit()
perspective and standard file descriptor close checks did not run resulting
to blindness if writes were successful, or not. Easy fix is to avoid
running _exit() altogether.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier if the tty path was exactly length of the maximum ut_line then last
character of the path was overwrote by \0. This is in practise theoretical
bug, as it is unheard that a tty device path could be 32 characters long.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
The plymouth support depends on Linux specific SOCK_* flags and all
the feature is probably unnecessary in some cases (non-plymouth
distros, etc.)
Signed-off-by: Karel Zak <kzak@redhat.com>
for stopping plymouthd. That do not depend on the existence of
the plymouth binary if it e.g. becomes uninstalled or an other
service is providing plymouthd facilities.
[kzak@redhat.com: - fix compiler warnings [-Wpointer-sign]
- use sizeof() for write_all()
- cast to char* for read_all]
Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
The write(1) is commonly a setuid binary, because common users cannot by
default write to each others terminals. Since the commit in reference, that
is part of releases v2.24 to v2.28, the write(1) has used access(2) to check
capability to write to a destination terminal. The catch is that access(2)
uses real UID and GID to when performing the accessibility. The obvious
correction is to avoid access(2) when in context of setuid binaries.
As a smaller fix, but equally important fix, ensure the 'msgsok' variable is
initialized to indicate no access. Uninitialized variable will almost
certainly do wrong thing at the time of check.
Breaking-commit: 0233a8ea18
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Wayne Pollock <profwaynepollock@gmail.com>
Use human numbering for lines - that is start counting from 1. And tell in
error message what the number means.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Here is a one-liner to reproduce the issue.
$ mkdir example && cd example && chmod 0500 . && script
Script started, file is typescript
script: cannot open typescript: Permission denied
Script done, file is typescript
Segmentation fault (core dumped)
Addresses: https://bugs.launchpad.net/bugs/1537518
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commands spawned from script(1) will never need access various file
descriptors the script(1) is using.
Reviewed-by: Ruediger Meier <sweet_f_a@gmx.de>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
script(1) waits for empty slave FD (shell stdin) before it writes to
master. This feature has been intorduiced by 54c6611d6f
to avoid misbehavior when we need to send EOF to the shell.
Unfortunately, this feature has been used all time for all messages.
This is wrong because command in the session (or shell) may ignore
stdin at all and wait forever in busy loop is really bad idea. Test
case:
script /dev/null
tailf /etc/passwd
<enter>
<enter>
... script process taking 100% CPU.
This patch forces script to use empty-stave detection only when we
need to write EOF. The busy loop has been modified to use nanosleep
and it does not wait forever...
Addresses: http://bugs.debian.org/820843
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'compiler-warnings' of https://github.com/rudimeier/util-linux:
exec_shell: prevent basename from modifying env
lib/path: ifdef path_set_prefix() like in path.h
lib: fix unused parameters and variables
misc: fix some printf format strings
include: add missing includes
ipcs: ulong -> unsigned long
libcommon: don't include sysinfo.h
Fix the warnings below for OSX clang and add a few more
casts for timeval:
lib/at.c:131:27: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'off_t' (aka 'long long') [-Wformat]
printf("%16jd bytes ", st.st_size);
~~~~~ ^~~~~~~~~~
lib/strutils.c:522:52: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
snprintf(buf, sizeof(buf), "%d%s%jd%s", dec, dp, frac, suffix);
~~~ ^~~~
lib/sysfs.c:468:42: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
len = snprintf(buf, sizeof(buf), "%ju", num);
~~~ ^~~
libuuid/src/gen_uuid.c:316:34: warning: format specifies type 'unsigned long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
clock_seq, last.tv_sec, last.tv_usec, adjustment);
^~~~~~~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
agetty uses NETLINK_ROUTE to be notified about network interface
changes. Unfortunately, the code that monitor the netlink FD does not
increment number of the monitored file descriptors when call
select(2), so the netlink notifications are invisible for agetty.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1278906
Signed-off-by: Karel Zak <kzak@redhat.com>
time_t may change to 64-bit on 32-bit Linux kernels at some point;
at that point, it may be desireable to test for issues with dates
past 2038.
[kzak@redhat.com: - use %jd rather than %lld]
Signed-off-by: Karel Zak <kzak@redhat.com>
Several of the /etc/issue escape codes such as \4 and \6 depend on
the current addresses of the system that can change after the agetty
prompt is displayed. This can cause stale data to be displayed
when a user looks at a VT, especially in cases of DHCP racing with
system start up.
Similar to the --reload mechanism, if we're displaying an address
in the issue output, and the user hasn't typed anything yet: then
redisplay the prompt with the new address.
We use netlink to watch for address changes. We only open the netlink
socket if we display an address in the issue file.
[kzak@redhat.com: - be careful with errno and DBG
- add EINTR check
(both suggested by Rudi]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
Most distributions probably ship reset from ncurses, which means
util-linux reset(1) is unlikely to be in use anywhere. Assuming the
previous being true it is almost unimaginable anyone one would be using
the alternative script, so remove it and mark the script deprecated.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* remove STDIN from poll() if:
* STDIN already closed -- poll returns POLLHUP, for example:
echo "date" | script
* detect EOF as returned by read(), for example:
script -c "echo Hello" < /dev/null
* don't write to master when there is still something to read from
slave (it means shell is not initialized yet or busy)
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't call anything from assert()
* fork() block cleanup to make it more readable
* restore original signal mask in child (do_shell())
* close signal FD in child (do_shell())
Signed-off-by: Karel Zak <kzak@redhat.com>
Sorry, but it's really ugly manner to use "xflg" where "x" is a command
line option as program variable and use it in code.
Signed-off-by: Karel Zak <kzak@redhat.com>
This allows removing almost immediate closure of file handle in the
doshell() function that does not use the file.
Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This moves the previous time to script control structure, and does
timeval calculation with timersub() that is more appropriate than
making a timeval to a double.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the
warning, so that the above workaround is no longer required.
Reference: http://man7.org/linux/man-pages/man3/strftime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The scriptreplay(1) will expect capture file always to have header.
Before this change the --quiet option together with timing caused
following replay error.
$ script --quiet --timing=timing
[...]
$ scriptreplay timing typescript
[...]
scriptreplay: unexpected end of file on typescript
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
One item to poll() more is a lot less work for system than separete input
and output processes.
Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Finalize the signalfd() change by adding file descriptors to poll() loop.
Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This is incomplete change. Working command requires the subsequent
select() to poll() change as well.
Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
On s390 and other big endian machines, doinput() sends NUL instead of
EOF to the tty master. NUL does not even reach the slave, and it is
waiting for more data forever.
If STDIN is not a tty, the bug caused "^@" being into the log, and since
commit 032228c it also causes hang.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
The issue with using a temporary file in wall is that wall runs as setgid.
This means that an unprivileged user who runs wall can modify wall's
temporary files, even if those are mode 0600, so the unprivileged user can
edit and effectively suppress the banner. The fix is to simply not use
temporary files.
[kzak@redhat.com: - rewrite growing string functions
- use struct buffer
- add buf_print() function]
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author: Jann Horn <jann@thejh.net>
The current "agetty --reload" implementation does not refresh issue
file output on autologin. Let's support this use-case too.
Reported-by: Sitsofe Wheeler <sitsofe@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
agetty monitors /run/agetty.reload file, unfortunately if the file
does not exist when agetty starts up then "agetty" --reload does not
work. This patch forces agetty to create the file before inotify
is enabled.
Reported-by: Sitsofe Wheeler <sitsofe@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
http://www.freedesktop.org/software/systemd/man/os-release.html
The file /etc/os-release takes precedence over /usr/lib/os-release.
Applications should check for the former, and exclusively use its data
if it exists, and only fall back to /usr/lib/os-release if it is
missing.
Reported-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
- use exit in .profile to avoid non-logged session after typing "exit"
- document that script can read more from stdin than the command inside:
echo -e 'script -c "read a b ; echo a=\$a b=\$b >defs.sh"\n1 2\necho Done' | sh
Script started, file is typescript
1 2
echo Done
Script done, file is typescript
Karel Zak wrote:
> Would be better to learn people to fix their shell initialization
> files to not call script(1) for non-interactive sessions?
It makes sense.
From 8fff32e65399ae07f70e12568d4d5278725673a7 Mon Sep 17 00:00:00 2001
From: Stanislav Brabec <sbrabec@suse.cz>
Date: Wed, 11 Feb 2015 15:02:10 +0100
Subject: [PATCH] script.1: Document behavior in non-interactive shells
And discourage users from such use.
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed. So say so. Also make
two very similar messages equal to this one.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
This adds a concise description of a tool to its usage text.
A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
It seems better to warn about --reload in ./configure if futimens or
inotify_init1 are missing.
The patch also replaces futimes() with futimens() to make the code
compatible with Uclibc.
Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
Fix command line parsing to not ignore term setting if no baud
specified, for example:
/sbin/agetty ttyS0 vt100
Signed-off-by: Karel Zak <kzak@redhat.com>
* makes speeds table usage more robust
* don't call next_speed() for empty speeds table to avoid division by zero
* default to 9600 when port baud unspecified
Addresses: https://github.com/karelzak/util-linux/pull/131
Signed-off-by: Karel Zak <kzak@redhat.com>
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Add an 'agetty --reload' command which asks all running agetty
commands to display their prompts again.
Several of the /etc/issue escape codes such as \4 and \S depend on
variable data which can change after the agetty prompt is displayed.
This can cause stale data to be displayed when a user looks at a VT,
especially in cases of DHCP racing with system start up.
We never want this to occur once the user has started typing a
user name. So we detect when the user starts typing, after which
no further reprompting occurs after that point.
[kzak@redhat.com: - add #ifdefs to make it usable on non-inotify systems,
- use futimens() with NULL timespec
- add --reaload to usage()]
Signed-off-by: Stef Walter <stefw-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Mainly: showing that the word color is a placeholder by writing
<color>, showing some numbers as optional, and message levels
and colors as not optional.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
The main changes are: showing the arguments of boolean options
as optional, improving the alphabetization, and restoring the
--half-bright option that went missing in 2011.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Apparently James Hunts patch (which he provided a long time
ago) is no longer covering it all.
This followup patch also silences the "Script done ..." message
when --quiet is used.
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Specifying 'script --quiet ...' still produces the 'Script started'
message in the typescript file. The --quiet option implies that the
script program should not log any of its output to the typescript file.
Originally reported at:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693966
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Sometimes we use "behaviour" and "behavior" in the same text, let's
use "behavior" only everywhere.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1011068
Signed-off-by: Karel Zak <kzak@redhat.com>
Underline option arguments, and use bold for options. Avoid use of \f
font style change in paragraphs, but use them when describing options.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Commit 3393c136 caused regression. The klogctl() logging range is 1-8,
but the value 0 is special according to setterm.1 manual page. It turns
on loging, same way as '-msg on' option.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
It is enough trouble to keep usage output aligned with getopt() parsing,
manual page, and bash-completion, so get rid of the unnecessary effort
duplication.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier the function was in the middle of option parsing code segment,
and screendump() required function prototype.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Check the input numbers are numbers, which makes also the code shorter,
and user experience better as half invalid imputs will error.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>