summaryrefslogtreecommitdiffstats
path: root/term-utils
Commit message (Collapse)AuthorAgeFilesLines
* write: use xstrncpy() from strutils.hSami Kerola2016-07-011-2/+2
| | | | | | | | 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>
* write: set atime value in term_chk() only when neededSami Kerola2016-07-011-4/+4
| | | | | | The search_utmp() is needs atime but main() does not, so remove the later. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* write: remove pointless fileno(3) callsSami Kerola2016-07-011-6/+6
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* write: get rid of function prototypesSami Kerola2016-07-011-141/+132Star
| | | | | | | Marking functions static and writing them in order where functions are introduced before use is enough. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* write: remove unused variableSami Kerola2016-07-011-4/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* agetty: don't modify argv[] when parse speedsKarel Zak2016-06-301-2/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-314-8/+8
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* build-sys: add --disable-plymouth-supportKarel Zak2016-05-261-2/+5
| | | | | | | | 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>
* sulogin: agetty: use the plymouth local protocol instead the plymouth binaryWerner Fink2016-05-201-42/+6Star
| | | | | | | | | | | | | 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>
* script: improve coding style and the "done" messageKarel Zak2016-05-181-7/+5Star
| | | | | | Don't print the "done" message if the file does not exist. Signed-off-by: Karel Zak <kzak@redhat.com>
* setterm: remove unnecessary translation stringSami Kerola2016-05-091-8/+8
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setterm: de-duplicate color option string parsingKarel Zak2016-05-091-44/+36Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* write: fix setuid related regressionWayne Pollock2016-05-071-7/+7
| | | | | | | | | | | | | | | | | | 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: 0233a8ea18bec17dd59cfe1fec8281 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Wayne Pollock <profwaynepollock@gmail.com>
* scriptreplay: avoid re-implementing strtod_or_err()Sami Kerola2016-05-052-13/+5Star
| | | | | | And use isnan() to detect NaN. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* scriptreplay: improve error messageSami Kerola2016-05-051-2/+2
| | | | | | | 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>
* script: check status of writes when closing outputsSami Kerola2016-04-171-2/+4
| | | | | | | This should make possible output issues more obvious, for example when a disk will get full. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: avoid trying fclose(NULL)Sami Kerola2016-04-171-1/+2
| | | | | | | | | | | | | 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>
* script: close file descriptors on execSami Kerola2016-04-171-6/+7
| | | | | | | | | 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: use empty-slave heuristic more carefullyKarel Zak2016-04-131-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | script(1) waits for empty slave FD (shell stdin) before it writes to master. This feature has been intorduiced by 54c6611d6f7b73609a5331f4d0bcf63c4af6429e 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>
* agetty: remove atoi() from argv[] parsing [clang analyze]Karel Zak2016-03-291-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: tweak spacing and wording, and restore filling in the man pageBenno Schulenberg2016-03-171-7/+9
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* agetty: tweak formatting and some wordings in the man pageBenno Schulenberg2016-03-081-52/+53
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* misc: never cast void* from malloc(3) and friendsRuediger Meier2016-03-071-1/+1
| | | | | | | | | | Such cast could hide serious compiler warnings in case we are missing includes (e.g. <stdlib.h> or "xalloc.h"). See http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: safer (and uniform) handling of return valueYuriy M. Kaminskiy2016-03-073-8/+8
| | | | | | When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: support \e{name} for issue fileKarel Zak2016-02-172-3/+18
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'compiler-warnings' of https://github.com/rudimeier/util-linuxKarel Zak2016-02-121-1/+2
|\ | | | | | | | | | | | | | | | | | | | | * '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
| * misc: fix some printf format stringsRuediger Meier2016-02-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: add support for \e in issue file to print \033Karel Zak2016-02-112-0/+6
|/ | | | | Suggested-by: Victor Ananjevsky <ananasik@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* script: fix misspellingRuediger Meier2016-02-031-3/+3
|
* docs: fix typos found by codespellRuediger Meier2016-02-031-1/+1
| | | | | | Using "codespell" from https://github.com/lucasdemarchi/codespell Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* scriptreplay/newgrp: use signed int to store return of getopt_longFilipe Brandenburger2016-01-071-1/+1
| | | | Signed-off-by: Filipe Brandenburger <filbranden@google.com>
* Merge branch 'races' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2015-12-021-8/+14
|\
| * mesg: fix multiple racesSami Kerola2015-11-221-8/+14
| | | | | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | agetty: don't ignore netlink on select()Karel Zak2015-11-241-3/+9
|/ | | | | | | | | | 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>
* script, hwclock: check file exist with access(3) rather than stat(3)Sami Kerola2015-11-091-2/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* agetty: fix chown(3), chmod(3) and open(3) raceSami Kerola2015-11-091-5/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: be pedantic and use "%"SCNi64Karel Zak2015-10-161-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: don't assume that time_t is compatible with longIsaac Dunham2015-10-161-4/+6
| | | | | | | | | | 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>
* setterm: remove dead code [coverity scan]Karel Zak2015-08-051-2/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: cleanup plymouth usage [coverity scan]Karel Zak2015-08-051-3/+9
| | | | | | | * use macros for paths * check open() return value Signed-off-by: Karel Zak <kzak@redhat.com>
* script: improve SIG{TERM,QUIT,KILL} sensitivityKarel Zak2015-07-281-3/+16
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: Reprompt once the network addresses change if address displayedStef Walter2015-07-201-18/+107
| | | | | | | | | | | | | | | 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.
* script: evaluate errno only if read() sets itRuediger Meier2015-07-031-7/+6Star
| | | | | | | | | [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>
* script: make sure errno is zeroKarel Zak2015-07-021-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* reset: deprecate the script, and remove reset.033cSami Kerola2015-06-293-12/+6Star
| | | | | | | | | 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>
* script: fix variable initialization warningSami Kerola2015-06-291-3/+3
| | | | | | | term-utils/script.c:402:19: warning: obsolete use of designated initializer without '=' [-Wpedantic] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: use REALTIME_LIBS for scriptKarel Zak2015-06-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: add note to BUGS man page sectionKarel Zak2015-06-251-0/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: fix EOF problemsKarel Zak2015-06-171-26/+88
| | | | | | | | | | | | | | | | | * 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>
* script: improve poll debuggingKarel Zak2015-06-171-5/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>