This option has valid use cases on virtual consoles. Example:
enabling screen blanking in the same way as `setterm --blank ...`
does.
Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
Danc86 wrote:
With agetty 2.32.1 and earlier, ^C at the login prompt is ignored. I
noticed when upgrading to agetty 2.34, typing ^C now causes agetty to
stop responding for 10 seconds and then it dies (and gets restarted by
system and a new login prompt is printed).
It logs this message:
agetty[46048]: ttyS0: invalid character 0x3 in login name
Previously the !isprint(ascval) condition would have caused control
characters like ^C (\x03) to be discarded, whereas now it falls
through to trying to decode it as part of a UTF-8 sequence, and then
fails.
Fixes: 5de9751997
Addresses: https://github.com/karelzak/util-linux/issues/1046
Signed-off-by: Karel Zak <kzak@redhat.com>
The current default behavior is to print the first issue file/dir and
all alternative locations are used as a backup solution only. If something
is found than the rest is ignored. The --issue-file allow to overwrite
this default behavior, but currently it supports only one file/dir.
This patch extend --issue-file to support ':' separated list of paths
and *all* the files (if exist and no empty) in the list are printed.
agetty --issue-file=/etc/issue:/etc/issue.d:/run/issue:/run/issue.d:/usr/lib/issue:/usr/lib/issue.d
Addresses: https://github.com/karelzak/util-linux/issues/1041
Signed-off-by: Karel Zak <kzak@redhat.com>
agetty cycling through the baud rates specified on command line
(triggered by BREAK). Unfortunately, the original baud rate (probably
the best one) is tried only first time on --keep-baud.
Addresses: https://github.com/karelzak/util-linux/issues/1025
Signed-off-by: Karel Zak <kzak@redhat.com>
Deprecating calls to not-thread safe asctime(), ctime(), and localtime()
calls is pretty close to pointless change. Lets do it to reduce lgtm scan
warnings with justification it's nicer to use static analysis tools when
they have very few positives.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
If agetty is compiled without support for ISSUEDIR, then it implements
a stub for `issuedir_read` that simply does nothing. In fact it does
too little, as it doesn't have a proper return statement even though the
function returns an integer.
Fix the issue by always returning `1` from `issuedir_read`. This
is the same error code that the real implementation of that function
returns in case it cannot open the directory and is thus a sensible
default to pretend that the directory doesn't exist.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Let's make life easier for admins and allow to review issue file
output on the current terminal without all full agetty execution. Use
case is pretty simple:
# $EDITOR /etc/issue
# agetty --show-issue
Addresses: https://github.com/karelzak/util-linux/issues/828
Signed-off-by: Karel Zak <kzak@redhat.com>
There is a c_isascii function that can be used.
isascii is deprecated and not available with some libcs like uClibc-ng
where it can be compile time disabled.
Aim is to make dolog() a lot more readable and understandable, with downside
of when (rarely?) USE_SYSLOG it not defined the function will use a bit more
space from stack. I think that is price well worth paying.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
eval_issue_file() contains fflush(stdout). It comes from an old code that
used fputs() to write to the console.
In the new code, we write to a temporary memstream, and
fclose(ie->output) fully replaces possible fflush(ie->output) in this
implementation.
The new print_issue_file() does not need it as well, as it uses
unbuffered write_all().
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
If the terminal is in the UTF-8 mode, get_logname() should use 8-bit
processing.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Tested-by: Lubomir Rintel <lkundrak@v3.sk>
As login supports non-ASCII characters in the logname, agetty should be
consistent.
8b58ffdd re-activated old and ASCII-only get_logname(), which restricted
the input to ASCII only. As the code does not read whole characters,
isascii(ascval) and isprint(ascval) returns nonsenses after entering a
non-ASCII character.
As keyboard maps don't contain unprintable non-control characters, it
seems to be relatively safe to remove both checks.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Tested-by: Lubomir Rintel <lkundrak@v3.sk>
c094fcd37 introduced a behavior change: When Return is entered with empty
logname, nothing happens. As it confuses users, return back the old
behavior: re-prompt.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
When user starts to enter logname, 8b58ffdd blocks issue reloads.
Reloads remain blocked even if user deletes all typed characters.
Make things visually consistent: If no characters are entered,
re-enable reloads.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Lubomir Rintel <lkundrak@v3.sk>
Tested-by: Lubomir Rintel <lkundrak@v3.sk>
The wait_for_term_input()'s select() needs to be tripped when the user
starts typing. Otherwise the reloads can abort an already in-progress login.
Coupled with \4 and \6 expansions that happen to be there on Fedora Server,
this means reload on every netlink event. With a couple of IPv6 routers
announcing their networks and temporary addresses in use can make it
sometimes virtually impossible to log in.
Seems like zero lflags do the job just fine on a Linux VT. Reset it to
canonical mode before running login.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
If netlink event arrives and related escapes are part of issue, agetty
reloads and re-display the prompt. Reload is triggered not only by IP
address change, but also by IPv6 RAs. In some environments it causes
reload several times in a minute, and even complicates the login.
To prevent this, reload only if a real change appears.
This consists of:
split print_issue_file() to several functions:
eval_issue_file() prints issue to memory. It does not affect terminal in
any way.
print_issue_file() prints issue file from memory.
cmp_issue_file() compares the issue file and returns true, if reload is
needed.
The implementation requires additional change:
do_prompt() does not evaluate the issue file. It is responsibility of
calling function.
Test suite:
Use issue that contais \4 and/or \6 escape.
After installing new instance, restart agetty by typing a letter and then
Enter 6 times.
To check whether reload happens, type a letter. When reload happens,
letter disappears.
1. Unplug network cable. Wait a while and re-plug network cable.
You should see 2 reloads on single stack and 3 reloads on dual stack.
2. Run a loop
while : ; do
sed -i '$areload_test' /etc/issue
agetty --reload
sleep 3
sed -i '/reload_test/d' /etc/issue
agetty --reload
sleep 3
done
You should see regular reload every 3 seconds.
3. Run a loop
while : ; do
agetty --reload
sleep 3
done
Before: You see regular reload every 3 seconds.
After: No reloads.
4. Run a loop
while : ; do
ifconfig lo 127.0.0.1 netmask 255.0.0.0
sleep 3
ifconfig lo 127.0.0.2 netmask 255.0.0.0
sleep 3
done
Before: You see regular reload every 3 seconds.
After: No reloads.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
changed variable name is not correct. It does not say that network
interface changed its address. It just says that the netlink message
processing was triggered.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
man utmp:
String fields are terminated by a null byte ('\0') if they are shorter
than the size of the field.
Signed-off-by: Karel Zak <kzak@redhat.com>
agetty sets c_iflags according to interaction with serial line in
get_logname(). For --autologin it does not read from the line, so we
have no clue how to set the flags.
The current behavior is to zeroize the flags. Unfortunately, it seems
like bad idea, because the line may be already properly initialized by
kernel (or systemd, etc.).
The new behavior is not touch the flags on --autologin.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1252764
Signed-off-by: Karel Zak <kzak@redhat.com>
get_logname() assumes that when it calls read() it initializes c and
errno, which isn't always true if we hit a whitelisted error or end of
file. This occasionally shows up as agetty going into an infinite
loop. Fix it by just delaying ten seconds and exiting when things go
wrong, similarly to the behavior after a non-whitelisted error.
[kzak@redhat.com: - interpret readres == 0 as c = 0
- ignore speed configurations for VCONSOLE]
Signed-off-by: Steven Smith <sos22@srcf.ucam.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
The /etc/issue file has been originally designed to inform users
about the system (version, name, etc.).
In last years is growing number of additional tools (containers,
maintenance tools and interfaces, ...) and many admins and downstream
maintainer want to add some tool specific hints to the issue file, but
it mess to share one file between more packages and/or scripts. The
solution is /etc/issue.d directory.
The directory is extension to the standard system /etc/issue. The
/etc/issue file has to exist, otherwise the directory will be ignored.
It means "rm /etc/issue" (or --onissue) is still the way how keep our
system silent independently on 3rd-party installed files in the
/etc/issue.d directory.
The content of the files in the directory are printed after content of
the /etc/issue. The files are printed in version-sort order and .issue
file extension is required (00-foo.issue 01-bar.issue ...).
The change is backwardly compatible.
Signed-off-by: Karel Zak <kzak@redhat.com>
For example /etc/os-release:
VERSION="26 (Twenty Six)"
VERSION_ID=26
agetty for \S{VERSION} returns
_ID=26
because the parser does nor check for '=' after variable name.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1498462
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
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>
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>
(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>
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>