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>