summaryrefslogtreecommitdiffstats
path: root/term-utils
Commit message (Collapse)AuthorAgeFilesLines
* script: be sensitive to another SIGCHLD ssi_codesKarel Zak2018-09-051-2/+8
| | | | | | | | | The current signalfd handler cares on CLD_EXITED only. It's pretty insufficient as there is more situations (and codes) when child no more running. Addresses: https://github.com/karelzak/util-linux/issues/686 Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty.8: Avoid a warning about an unbreakable lineBjarni Ingi Gislason2018-08-061-1/+2
| | | | | | Make the indent depend on the formatting command, nroff or troff. Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* mesg: do not print 'ttyname failed' message unless --verbose requestedSami Kerola2018-08-032-0/+14
| | | | | | | | | | | | | | | Lots of people are confused why mesg(1) is priting this message. Usual cause seems to be an uninteractive shell trying to turn running 'mesg n' from a /root/.profile where command invocation is by default on debian based systems. This might be rare case when failing silently is better. [kzak@redhat.com: - add note to the man page - fix if(isatty()) logic] Reference: https://www.google.com/search?q=mesg+ttyname+failed Review: https://marc.info/?l=util-linux-ng&m=153319988631233&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* setterm: fix compiler warnings [-Wcast-qual]Karel Zak2018-07-231-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: keep c_iflags unmodified on --autologinKarel Zak2018-06-062-4/+17
| | | | | | | | | | | | | | | 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>
* man: Change the only argument to two for the two-fonts macrosBjarni Ingi Gislason2018-05-231-1/+1
| | | | | | | Punctuation marks have been left in the only argument of two-fonts macros, instead of being separated from it to make the second one. Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* man: Use the correct macro for a font change of one argumentBjarni Ingi Gislason2018-05-231-1/+1
| | | | | | | | Use the correct macro (I, B) for the font change of one argument, not those that are used for alternating two fonts, like "BR", "IR", "RB", or "RI". Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* script: fix printf format specifiersRuediger Meier2018-05-161-2/+2
| | | | | | Noticed on 32bit builds. Types changed in 0da73643. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* iscript: s/COLS/COLUMNS/ in start messageKarel Zak2018-05-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: record exit codeKarel Zak2018-05-142-18/+38
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: add more info to script headerKarel Zak2018-05-141-5/+33
| | | | | | | | | | | | | | | | 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>
* script: cleanup done timestamp messageKarel Zak2018-05-141-6/+9
| | | | | | | * always save "done" timestamp to typescript (use done() for this) * use FORMAT_TIMESTAMP_MAX as buffer size Signed-off-by: Karel Zak <kzak@redhat.com>
* script: use uint64_t for file sizesKarel Zak2018-05-141-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: add the -o/--output-limit option. Fix race test.Fred Mora2018-05-142-6/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | When script is used on a host with a relatively small free disk space, it is sometimes desirable to limit the size of the captured output. This can now be enforced with the --output-limit option. The --output-limit option lets the user specify a maximum size. The program uses the size parsing from strutils and thus supports the usual multiplicative suffixes (kiB, KB, MiB, MB, etc.). After the specified number of bytes have been written to the output file, the script program will terminate the child process. Due to buffering, the size of the output file might exceed the specified limit. This limit also does not include the start and done messages. The race test was throwing an error dur to a variable being "" in some cases. Quoting the variable in the equal test took care of that test. [kzak@redhat.com: - use done() to stop script - count also timing file - remove unnamed member initialization in ctl struct - add to bash-completion] Signed-off-by: Fred Mora <fmora@datto.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typos using codespellRuediger Meier2018-02-161-1/+1
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak2018-01-171-1/+1
| | | | | | | Let's make it possible to use debug.h without environment variables. Suggested-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: Fix a use of uninitialised memory in an agetty error path.Steven Smith2017-11-211-6/+19
| | | | | | | | | | | | | | 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>
* lib/timeutils: add common ISO timestamp masksJ William Piggott2017-11-101-6/+2Star
| | | | | | | | | | | | | | | | | | | | | | * Start the ISO format flags at bit 0 instead of bit 1. * Remove unnecessary _8601 from ISO format flag names to avoid line wrapping and to ease readability. * ISO timestamps have date-time-timzone in common, so move the TIMEZONE flag to bit 2 causing all timestamp masks to have the first three bits set and the last four bits as timestamp 'options'. * Change the 'SPACE' flag to a 'T' flag, because it makes the code and comments more concise. * Add common ISO timestamp masks. * Implement the ISO timestamp masks in all applicable code using the strxxx_iso() functions. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* agetty: add support for /etc/issue.dKarel Zak2017-11-072-30/+169
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* agetty: remove unused flagKarel Zak2017-11-061-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: fix /etc/os-release parsingKarel Zak2017-10-051-0/+6
| | | | | | | | | | | | | | | | 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>
* script: simplify stdin usage in poll()Karel Zak2017-09-181-7/+4Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: support sig{stop/cont}Karel Zak2017-09-081-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * call wait() only when child exited * suspend all session (including script master process) when child get SIGSTOP and send SIGCONT to child when master process resume This allows to suspend all session and later use "fg" shell command to resume. $ ps af 14722 pts/1 Ss 0:00 bash 4870 pts/1 S+ 0:00 \_ ./script 4871 pts/6 Ss+ 0:00 \_ bash -i $ kill -SIGSTOP 4871 and script session on another terminal: $ script Script started, file is typescript $  [1]+ Stopped ./script $ fg 1 ./script ... session again usable ... ^D Script done, file is typescript Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: keep returns in main()Karel Zak2017-08-071-3/+3
| | | | | | | Don't use list_speeds() as non-return function, it seems better to keep main() code consistent. Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: fix invalid usage crashSami Kerola2017-08-051-2/+2
| | | | | | | | | $ agetty agetty: not enough arguments: Success Segmentation fault (core dumped) Reference: 9325dbfd2018b2a3b510617f4aa13777fbbe23c3 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* agetty: add compile time features to --version outputSami Kerola2017-08-051-1/+45
| | | | | | | | | 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>
* agetty: add --list-speeds optionSami Kerola2017-08-052-0/+18
| | | | | Proposed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* agetty: remove dead DO_DEVFS_FIDDLING code segmentSami Kerola2017-08-051-39/+0Star
| | | | | | | 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>
* agetty: fix --login-pause logicKarel Zak2017-07-311-2/+1Star
| | | | | | | Let's "eat" ENTER key when pressed after login pause prompt. Addresses: https://github.com/karelzak/util-linux/issues/491 Signed-off-by: Karel Zak <kzak@redhat.com>
* script: fix ambiguity about the optional argument of the -t optionAntonio Ospite2017-07-182-9/+9
| | | | | | | | [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>
* reset: remove script from the packageSami Kerola2017-07-153-70/+0Star
| | | | | | | 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>
* agetty: print /etc/issue on --skip-loginKarel Zak2017-07-101-1/+4
| | | | | | | | | | | | 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>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-297-12/+12
| | | | | | | | | 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>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-274-8/+9
| | | | | | | | 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>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-273-6/+3Star
| | | | | | | | | | | | 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>
* Merge branch 'usage-part2' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-267-31/+39
|\ | | | | | | | | | | | | | | | | | | | | * '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
| * misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-263-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * misc: never use usage(stderr)Ruediger Meier2017-06-262-10/+13
| | | | | | | | | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: cleanup and fix --unknownopt issuesRuediger Meier2017-06-262-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed checkusage.sh warnings: rtcwake: --unknownopt, non-empty stdout rtcwake: --unknownopt, stderr too long: 21 blockdev: --unknownopt, stderr too long: 28 lsipc: --unknownopt, stderr too long: 77 pg: --unknownopt, stderr too long: 23 renice: --unknownopt, stderr too long: 18 sulogin: --unknownopt, stderr too long: 17 write: --unknownopt, stderr too long: 12 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | script: rename fixtty() to enable_rawmode_tty()Karel Zak2017-06-261-13/+14
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | script: ensure typescript and timing errors do not break terminalSami Kerola2017-06-261-7/+22
|/ | | | | | | | | | | | | | | | | | 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>
* agetty: fix login name DEL/CTRL^U issueKarel Zak2017-06-231-55/+15Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 790119b8850ae13bb4254c5096a54b2aeb355b20) 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>
* wall: don't use gid_t when allocate grounps arrayKarel Zak2017-06-141-1/+1
| | | | | Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: remove stray semicolonsSami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* wall: fix OSX getgrouplist, gid_t* vs int*Karel Zak2017-06-141-1/+7
| | | | | | | | | | | | | | | | 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>
* misc: fix ggc-7 fallthrough warningsSami Kerola2017-06-141-2/+2
| | | | | | | | | | | | | | | | | | | (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>
* build-sys: ncurses headers cleanupKarel Zak2017-05-311-4/+4
| | | | | | | | | * 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>
* text-utils: use proper paths to term.hKarel Zak2017-05-301-9/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* wall: make sure with not referencing a null pointerKarel Zak2017-05-291-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: always write stat and done message to typescript fileKarel Zak2017-04-182-6/+6
| | | | | | And remove usec from timestamp. Signed-off-by: Karel Zak <kzak@redhat.com>