Commit Graph

686 Commits

Author SHA1 Message Date
Karel Zak e7f9744ef5 agetty: remove unused flag
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-06 14:47:29 +01:00
Karel Zak 949e839979 agetty: fix /etc/os-release parsing
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>
2017-10-05 11:07:41 +02:00
Karel Zak d88b739fba script: simplify stdin usage in poll()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:49:11 +02:00
Karel Zak 2e7a922701 script: support sig{stop/cont}
* 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>
2017-09-08 09:48:29 +02:00
Karel Zak 7e6f029448 agetty: keep returns in main()
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>
2017-08-07 09:48:51 +02:00
Sami Kerola 82214f45e9
agetty: fix invalid usage crash
$ agetty
agetty: not enough arguments: Success
Segmentation fault (core dumped)

Reference: 9325dbfd20
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-05 16:49:07 +01:00
Sami Kerola 63d94613a8
agetty: add compile time features to --version output
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>
2017-08-05 16:46:55 +01:00
Sami Kerola 11841430c9
agetty: add --list-speeds option
Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-05 16:04:37 +01:00
Sami Kerola 43a1709e3b
agetty: remove dead DO_DEVFS_FIDDLING code segment
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>
2017-08-05 09:58:25 +01:00
Karel Zak fe63c8a649 agetty: fix --login-pause logic
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>
2017-07-31 10:27:20 +02:00
Antonio Ospite 3cf274c9e9 script: fix ambiguity about the optional argument of the -t option
[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>
2017-07-18 14:29:07 +02:00
Sami Kerola 8e58889065
reset: remove script from the package
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>
2017-07-15 22:02:53 +01:00
Karel Zak a273d83db9 agetty: print /etc/issue on --skip-login
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>
2017-07-10 10:42:49 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
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>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Karel Zak 47ccf06b47 Merge branch 'usage-part2' of https://github.com/rudimeier/util-linux
* '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
2017-06-26 15:58:37 +02:00
Karel Zak 7fb65db124 script: rename fixtty() to enable_rawmode_tty()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 15:30:12 +02:00
Sami Kerola 8198052c9e script: ensure typescript and timing errors do not break terminal
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>
2017-06-26 15:23:31 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
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>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 9325dbfd20 misc: cleanup and fix --unknownopt issues
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>
2017-06-26 14:38:24 +02:00
Karel Zak 2a14beb4e9 agetty: fix login name DEL/CTRL^U issue
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>
2017-06-23 14:26:47 +02:00
Karel Zak 2a67d912c6 wall: don't use gid_t when allocate grounps array
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-14 21:45:56 +02:00
Sami Kerola f4d3783867 misc: remove stray semicolons
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:21:29 +02:00
Karel Zak 098a75a18b wall: fix OSX getgrouplist, gid_t* vs int*
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>
2017-06-14 11:53:43 +02:00
Sami Kerola b1557fe981 misc: fix ggc-7 fallthrough warnings
(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>
2017-06-14 11:48:22 +02:00
Karel Zak 3947ca4ca9 build-sys: ncurses headers cleanup
* 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>
2017-05-31 11:01:46 +02:00
Karel Zak 2ac1bc84d7 text-utils: use proper paths to term.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-30 17:15:37 +02:00
Karel Zak b4cb2b48f9 wall: make sure with not referencing a null pointer
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-29 13:25:36 +02:00
Karel Zak 6f3c9c3430 script: always write stat and done message to typescript file
And remove usec from timestamp.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-18 12:12:44 +02:00
Rui Zhao (renyuneyun) bdef362d5d fix the position of newline in the time output of 'script'
- move '\n' to fprintf
- use `timeutils/strtime_iso()` instead of `strtime()`

Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
2017-04-14 17:49:25 +01:00
Karel Zak d05422417e script: don't call strftime() if not necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 15:06:52 +02:00
Karel Zak 59868828e4 Merge branch 'script_quiet' of https://github.com/renyuneyun/util-linux
* 'script_quiet' of https://github.com/renyuneyun/util-linux:
  script: fix start message showing in output file when -q is on
2017-04-13 15:04:54 +02:00
J William Piggott dddbfa4e9b agetty: various man-page fixes
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 15:46:26 +02:00
Rui Zhao (renyuneyun) 493548b85d script: fix start message showing in output file when -q is on
Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
2017-04-05 21:11:13 +01:00
Karel Zak 4739b6fd3e agetty: fix login-options desc in man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-05 10:59:53 +02:00
Sami Kerola c9151874b6
docs: improve agetty.8 manual page
Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-03 22:17:52 +01:00
Sami Kerola 343cc27559
agetty: make --remote to forward --nohostname as -H to login
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>
2017-04-03 19:55:15 +01:00
Sami Kerola 650e6df62c
agetty: remove variable that is set but not read
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-01 09:24:30 +01:00
Karel Zak 9ff67eb9c8 agetty: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-27 18:02:54 +02:00
Karel Zak 790119b885 agetty: fix characters reorder in login prompt
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>
2017-03-27 14:54:39 +02:00
Sami Kerola e9f62f3881 setterm: fix bitfield warning [smatch]
term-utils/setterm.c:179:27: warning: dubious bitfield without explicit
`signed' or `unsigned'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-28 14:38:22 +01:00
Matthias Gerstner 1db2468106
agetty: fix a memory leak when parsing \S in issue files 2017-02-27 12:31:28 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
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>
2017-02-20 12:58:49 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Bert van Hall 8d6fdd2f0c
term-utils/script: fix typo leading to syntax error
Introduced in edc7e42, this typo is actually invalid C. Fix this.

Signed-off-by: Bert van Hall <bert.vanhall@avionic-design.de>
2017-01-18 16:45:56 +01:00
Karel Zak feda4342df build-sys: use -lm for scriptreplay if necessary
Reported-by: Bert van Hall <bert.vanhall@avionic-design.de>
Addresses: https://github.com/karelzak/util-linux/pull/397
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-18 13:17:21 +01:00
Karel Zak 912885d012 Merge branch 'setterm' of git://github.com/kerolasa/lelux-utiliteetit
* 'setterm' of git://github.com/kerolasa/lelux-utiliteetit:
  setterm: add --resize option
2017-01-04 12:27:27 +01:00
Sami Kerola 5d79599951
setterm: add --resize option
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>
2016-12-29 10:56:15 +00:00
Ruediger Meier c43cd8f513 agetty: fix ifdef typo
introduced in 77835be2

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-21 22:47:36 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Sébastien Helleu d673b74e9d docs: replace FTP by HTTPS in kernel.org URLs
The links to ftp://ftp.kernel.org/ are replaced by
https://www.kernel.org/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 11:22:26 +01:00
Michael Kerrisk a72fa61a77 docs: various pages: Use 'UID" and "GID", not "uid" and "gid" in man pages
Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
2016-12-09 13:45:09 +01:00
Michael Kerrisk aedd46f66e docs: various pages: Use consistent terminology (set-user-ID and set-group-ID)
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>
2016-12-09 13:45:09 +01:00
Michael Kerrisk 46f057ed37 docs: various pages: Format pathnames as italic (.I)
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>
2016-12-09 13:45:09 +01:00
Karel Zak 63d41c0ac0 wall: remove unnecessary include
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-08 16:09:15 +01:00
Ruediger Meier 77835be273 agetty: re-add utmp.h for Debian GNU/kFreeBSD
It's needed there to get login_tty(). On normal FreeBSD we would
need libutil.h.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-07 12:35:24 +01:00
Ruediger Meier b4b919fe5e login-utils: switch to utmpx.h
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>
2016-12-07 12:35:24 +01:00
Ruediger Meier 81580f79fa agetty: remove obsolete HAVE_UPDWTMP fallback
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-07 12:35:24 +01:00
Ruediger Meier a924b4004c login-utils: avoid using the defined utmp sizes.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-07 12:35:24 +01:00
Ruediger Meier 55771f5409 login-utils: remove _HAVE_UT_TV fallback
_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>
2016-12-07 12:35:24 +01:00
Karel Zak e0383e3e88 wall: check -g GID
Based on comments from Sami Kerola.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-02 14:11:20 +01:00
Jim Patterson 01544c52f8 wall: add --group option
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>
2016-12-02 13:53:03 +01:00
Ruediger Meier 223939d95b misc: spelling, always use "cannot" instead of "can not"
Just to be consistent ...

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-11-30 14:56:50 +01:00
Michael Kerrisk (man-pages) f053ff1e3a Place SEE ALSO entries in order
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>
2016-11-29 10:44:19 +01:00
Sami Kerola 984a60965a
misc: always check setenv(3) return value
At least glibc setenv(3) can fail when system runs out of memory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-08-12 21:25:36 +01:00
Sami Kerola 58c756c92d
agetty: move unreachable code to pre-processor #else segment [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola ef4d11d57e
setterm: fix declarations shadowing variables in the global scope [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Karel Zak 10e8d7a324 agetty: call uname() only when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-20 13:20:14 +02:00
Karel Zak 1132e5aad1 agetty: fix \S usage
If \S without argument used then uninitialized 'varname' compared with
ANSI_COLOR.

Addresses: https://github.com/karelzak/util-linux/issues/329
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-20 13:16:13 +02:00
Karel Zak aefd6a9d6a write: don't use strftime()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-14 13:20:58 +02:00
Sami Kerola 285c1f3a3e
lib: try to find tty in get_terminal_name()
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>
2016-07-03 23:35:10 +01:00
Sami Kerola a58b90255c
write: stop removing and adding /dev/ in front of tty string
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>
2016-07-03 23:35:10 +01:00
Sami Kerola 50e417c8ad
write: tell when effective gid and tty path group mismatch
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>
2016-07-03 23:35:09 +01:00
Sami Kerola 5592bf0d9a
write: improve coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-03 23:35:09 +01:00
Sami Kerola a8031743ea
write: remove PUTC macro
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>
2016-07-03 23:34:55 +01:00
Sami Kerola a079439266
write: make timestamp to be obviously just a clock time
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>
2016-07-01 22:07:02 +01:00
Sami Kerola c1d0a95eea
write: remove unnecessary utmp variables
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>
2016-07-01 21:17:25 +01:00
Sami Kerola d732758e65
write: improve function and variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-01 21:13:13 +01:00
Sami Kerola b5a6937961
write: add control structure to clarify what is going on
This is done purely an improve readability of the source code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-01 21:08:53 +01:00
Sami Kerola 97ebab4ea8
write: run atexit() checks at the end of execution
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>
2016-07-01 21:01:26 +01:00
Sami Kerola e4aaa0e593
write: use xstrncpy() from strutils.h
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>
2016-07-01 20:59:23 +01:00
Sami Kerola 489a0fd2f5
write: set atime value in term_chk() only when needed
The search_utmp() is needs atime but main() does not, so remove the later.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-01 20:54:02 +01:00
Sami Kerola 59f3d6ae12
write: remove pointless fileno(3) calls
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-01 20:51:47 +01:00
Sami Kerola b985f37240
write: get rid of function prototypes
Marking functions static and writing them in order where functions are
introduced before use is enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-01 20:51:47 +01:00
Sami Kerola 1baec22b08
write: remove unused variable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-01 20:51:47 +01:00
Karel Zak 3383b2f5ca agetty: don't modify argv[] when parse speeds
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-30 14:00:44 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak 1eb16fd780 build-sys: add --disable-plymouth-support
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>
2016-05-26 15:08:53 +02:00
Werner Fink fe3f7e17aa sulogin: agetty: use the plymouth local protocol instead the plymouth binary
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>
2016-05-20 11:21:10 +02:00
Karel Zak 53ca053291 script: improve coding style and the "done" message
Don't print the "done" message if the file does not exist.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-18 15:06:31 +02:00
Sami Kerola c8a6f83e85 setterm: remove unnecessary translation string
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-05-09 12:57:01 +02:00
Karel Zak 98297e65a1 setterm: de-duplicate color option string parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-09 12:35:41 +02:00
Wayne Pollock 3e90d04af9
write: fix setuid related regression
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>
2016-05-07 22:49:41 +01:00
Sami Kerola f0b3b904c7 scriptreplay: avoid re-implementing strtod_or_err()
And use isnan() to detect NaN.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-05-05 11:46:54 +02:00
Sami Kerola ba660b9911 scriptreplay: improve error message
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>
2016-05-05 11:46:54 +02:00
Sami Kerola 22d5cc87e6
script: check status of writes when closing outputs
This should make possible output issues more obvious, for example when a
disk will get full.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 4b0b416acb
script: avoid trying fclose(NULL)
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>
2016-04-16 23:09:26 +01:00
Sami Kerola 760e5e682d
script: close file descriptors on exec
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>
2016-04-16 23:09:26 +01:00
Karel Zak b2bff06661 script: use empty-slave heuristic more carefully
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>
2016-04-13 11:52:43 +02:00
Karel Zak cf5828599a agetty: remove atoi() from argv[] parsing [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-29 13:57:13 +02:00
Benno Schulenberg c8a550a178 script: tweak spacing and wording, and restore filling in the man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-17 12:18:53 +01:00
Benno Schulenberg 2da0d7c0c2 agetty: tweak formatting and some wordings in the man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-08 14:21:55 +01:00
Ruediger Meier fea1cbf748 misc: never cast void* from malloc(3) and friends
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>
2016-03-07 23:29:27 +01:00
Yuriy M. Kaminskiy 06fa581748 misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:11:06 +01:00
Karel Zak d689166b11 agetty: support \e{name} for issue file
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-17 12:53:20 +01:00
Karel Zak 173607a254 Merge branch 'compiler-warnings' of https://github.com/rudimeier/util-linux
* '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
2016-02-12 13:35:18 +01:00
Ruediger Meier 7231fb2a5b misc: fix some printf format strings
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>
2016-02-11 13:39:56 +01:00
Karel Zak 583627ef36 agetty: add support for \e in issue file to print \033
Suggested-by: Victor Ananjevsky <ananasik@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-11 12:33:57 +01:00
Ruediger Meier 23e35eca15 script: fix misspelling 2016-02-03 16:34:12 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Filipe Brandenburger 94757eceb1 scriptreplay/newgrp: use signed int to store return of getopt_long
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2016-01-07 12:47:41 +01:00
Karel Zak 4ba2a6e515 Merge branch 'races' of git://github.com/kerolasa/lelux-utiliteetit 2015-12-02 10:27:43 +01:00
Karel Zak 5184d93630 agetty: don't ignore netlink on select()
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>
2015-11-24 17:44:38 +01:00
Sami Kerola 010d5a670b
mesg: fix multiple races
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-22 20:56:39 +00:00
Sami Kerola a4aeb5bd80 script, hwclock: check file exist with access(3) rather than stat(3)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-09 09:56:14 +01:00
Sami Kerola c3a9f86fcd agetty: fix chown(3), chmod(3) and open(3) race
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-09 09:56:14 +01:00
Karel Zak c2f03da93d script: be pedantic and use "%"SCNi64
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-16 11:48:47 +02:00
Isaac Dunham 345208a5ab script: don't assume that time_t is compatible with long
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>
2015-10-16 11:31:22 +02:00
Karel Zak 2660801513 setterm: remove dead code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:51:04 +02:00
Karel Zak a359830c1a agetty: cleanup plymouth usage [coverity scan]
* use macros for paths
* check open() return value

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:48:01 +02:00
Karel Zak 5860c45eed script: improve SIG{TERM,QUIT,KILL} sensitivity
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-28 10:36:29 +02:00
Stef Walter e36deb6424 agetty: Reprompt once the network addresses change if address displayed
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.
2015-07-20 11:17:23 +02:00
Ruediger Meier 7dbcd80ee8 script: evaluate errno only if read() sets it
[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>
2015-07-03 09:53:05 +02:00
Karel Zak e831c87670 script: make sure errno is zero
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-02 10:30:10 +02:00
Sami Kerola 14867b0f72 reset: deprecate the script, and remove reset.033c
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>
2015-06-29 12:06:22 +02:00
Sami Kerola 0664d41dba script: fix variable initialization warning
term-utils/script.c:402:19: warning: obsolete use of designated
initializer without '=' [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 12:05:25 +02:00
Karel Zak a3b69ccb1c build-sys: use REALTIME_LIBS for script
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-29 10:55:37 +02:00
Karel Zak 63ddc7ba1e script: add note to BUGS man page section
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-25 11:55:42 +02:00
Karel Zak 54c6611d6f script: fix EOF problems
* 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>
2015-06-17 15:48:50 +02:00
Karel Zak 2e9418b7cc script: improve poll debugging
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-17 13:33:35 +02:00
Karel Zak d35ffe808a script: cleanup signals usage
* 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>
2015-06-17 13:25:46 +02:00
Karel Zak 1200cfbfbd script: debug poll() results
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 14:44:05 +02:00
Karel Zak a2b4dec553 script: add support for SCRIPT_DEBUG=
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 14:03:09 +02:00
Karel Zak da26af4ee1 script: remove magic constants from poll code
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 13:11:05 +02:00
Karel Zak 3f19b85f97 script: rename control struct members
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>
2015-06-16 12:34:04 +02:00
Karel Zak 7e5796c916 script: close timingfp also when -e
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 12:26:00 +02:00
Sami Kerola 9580536a7f script: move timing file opening close to use of it
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>
2015-06-08 21:53:37 +01:00
Sami Kerola 2ddadb5eda script: add noreturn function attributes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:37 +01:00
Sami Kerola 04639805e1 script: use gettime_monotonic() to get timing file timestamps
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>
2015-06-08 21:53:36 +01:00
Sami Kerola b09feab9e4 script: use correct input type, move comment, and so on
Minor corrections.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:36 +01:00
Sami Kerola 8353549e02 script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
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>
2015-06-08 21:53:36 +01:00
Sami Kerola a8896ad5b7 script: move do_io() content to small functions
The do_io() got to be a bit long with relatively deep indentation.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:34 +01:00
Sami Kerola 076ffa48f3 script: add 'Script started' line always to capture file
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>
2015-06-08 21:52:51 +01:00
Sami Kerola 89a859d433 script: remove io vs signal race
Make do_io() to run poll() until all streams are empty.  This should
remove the signal from child versus io handling race for good.

Addresses: https://github.com/karelzak/util-linux/pull/62
Addresses: https://bugs.launchpad.net/bugs/264967
Addresses: https://bugs.debian.org/305808
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:51 +01:00
Sami Kerola 6ddf53a5b4 script: merge doinput() and output() functions to do_io()
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>
2015-06-08 21:52:36 +01:00
Sami Kerola cf470183ea script: use poll() rather than select()
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>
2015-06-06 14:53:56 +01:00
Sami Kerola cc1a88fb59 script: use signalfd() to catch signals
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>
2015-06-06 14:53:55 +01:00
Sami Kerola edc7e42076 script: add struct script_control and remove global variables
Fix also couple indentation issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:50 +01:00
Sami Kerola 93af8d8bf3 script: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:36:46 +01:00
Sami Kerola 6a40c65f81 tests: check script options work as expected
Options --flush and --timing remain unchecked, as I do not have an idea
how to check them reliably.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:36:38 +01:00
Stanislav Brabec 8fdc064ac3 script: Fix mangled EOF and hang on big endian
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>
2015-05-15 12:56:46 +02:00
Karel Zak 890e103559 wall: do not use a temporary file.
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>
2015-04-03 11:44:24 +02:00
Karel Zak c2ef308bbf agetty: reload issue on --autologin --login-pause too
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>
2015-03-09 12:45:52 +01:00
Karel Zak c9f5ec0faa agetty: make sure that reload file exists
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>
2015-03-09 12:26:55 +01:00
Karel Zak b28842ae67 agetty: support /usr/lib/os-release too
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>
2015-03-05 12:25:28 +01:00
Bill Pemberton a55f60a107 docs: fix some spelling errors and typos in man pages
runuser.1: fix spelling implemenation -> implementation
scriptreplay.1: fix spelling overide -> override
unshare.1: fix spelling permamently -> permanently
last.1: fix spelling preferrable -> preferable
lslogins.1: fix spelling priviliges -> privileges
hwclock.8.in: fix spelling transfered -> transferred
prlimit.1: fix typo umlimited -> unlimited
agetty.8: fix typo unnsupported -> unsupported

Signed-off-by: Bill Pemberton <wfp5p@worldbroken.com>
2015-02-27 14:48:56 +01:00
Sami Kerola cd2a6f1cfd rpmatch: use symbolic value when evaluation return codes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-24 12:42:06 +01:00
Karel Zak 30b294c491 lib/strutils: extend parse_switch() to accept more options
* allow to specify more 0|1 pairs
* allow to specify error message

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 12:04:22 +01:00
Sami Kerola e5cf147655 lib/strutils: move parse_switch() from setterm(1) to library
To allow sharing the code with other utilities.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 11:33:31 +01:00
Stanislav Brabec ab52a8bcce script.1: Improve documentation of non-interactive behavior
- 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
2015-02-16 10:49:36 +01:00
Stanislav Brabec 8fd4a7aa81 script: no logging for non-interactive shells
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.
2015-02-12 14:31:16 +01:00
Stanislav Brabec 0b285b84b2 Fix "Script started" buffering race
script -c "echo Hallo World" </dev/null >script.log ; cat script.log

Before:
Hallo World
Script started, file is typescript
Script started, file is typescript
Script done, file is typescript

After:
Script started, file is typescript
Hallo World
Script done, file is typescript
2015-02-10 11:18:51 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
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>
2015-02-02 11:27:10 +01:00
Karel Zak 3d0b57d62c Merge branch 'opts' of https://github.com/jwpi/util-linux 2015-01-26 11:31:05 +01:00
Benno Schulenberg 54fefa078e textual: fix spellos and inconsistencies in several program messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:17:55 +01:00
J William Piggott b06c1ca6f8 docs: restore minus symbols in long opts
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-20 18:15:30 -05:00
Benno Schulenberg 3a60b1c26b docs: remove obsolete and unneeded comments from man-page files
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>
2015-01-12 11:03:26 +01:00
Sami Kerola 4ebac79f01 build-sys: fix make checkincludes warnings
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 21:57:53 +00:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
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>
2015-01-06 11:27:38 +01:00
Benno Schulenberg f49ccec212 docs: don't use bold or italics for "[option]" in synopsis of man pages
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>
2014-12-19 09:57:23 +01:00
Karel Zak 90d5285d8c agetty: use futimens, check for all in configure.ac
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>
2014-11-21 11:38:11 +01:00
Karel Zak 3c5ee57cd3 agetty: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 09:42:23 +01:00
Karel Zak 914047b498 agetty: keep the current baud before try 9600 on serial lines
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 09:03:00 +01:00
Karel Zak 14da9b1f3d agetty: don't ignore TERM
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>
2014-11-21 08:43:14 +01:00
Karel Zak 8410cdd38a aggety: always set default serial line speed
* 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>
2014-11-20 10:56:03 +01:00
Sami Kerola d8c1fc7ac4 setterm: fix dubious one-bit signed bitfield [smatch scan]
term-utils/setterm.c:165:24: error: dubious one-bit signed bitfield

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-20 14:07:19 +02:00
Andreas Henriksson 032228c9af script: may be hangs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-14 12:07:21 +02:00
Sami Kerola db433bf737 textual: use usage() text element macros
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>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Karel Zak 8026fa9bc7 build-sys: use -lutil for BSD only
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-17 10:56:46 +02:00
Christoph Egger c32270d41f agetty: fixing FTBFS on !linux (Debian util-linux 2.20.1-1.2)
Handle vc flags missing on FreeBSD
Fix tty creation on kFreeBSD taking patch from 2.19

Addresses-Debian-Bug: #650185
2014-09-17 10:14:50 +02:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Karel Zak b928bb109a Revert "wall: wrap message header when it exceeds 79 characters"
This reverts commit 93d7baf250.

Ooops... it wasn't my plan to merge this patch. Sorry.
2014-07-29 11:57:01 +02:00
Sami Kerola 93d7baf250 wall: wrap message header when it exceeds 79 characters
Header truncation started to happen more often after commit
d81c30553f that made the header to be
longer.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:18 +01:00
Stef Walter 6443dd43da agetty: Reprompt and reprint /etc/issue when asked
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>
2014-07-28 16:33:33 +02:00
Karel Zak 479912e7b3 wall: add fallback for failed sysconf()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 15:19:34 +02:00
Benno Schulenberg 6e72fa5965 docs: bring a few more man pages closer to standard formatting
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-16 12:03:25 +02:00
Sami Kerola 4636f0613d setterm: remove unnecessary variable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:27:10 +01:00
Benno Schulenberg d276d99572 setterm: improve formatting and wording of usage text
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>
2014-06-30 10:21:11 +02:00
Benno Schulenberg e73a07208e setterm: improve wording and formatting of the man page
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>
2014-06-30 10:20:09 +02:00
Karel Zak cabce4ea71 script: clean up code to genenrate Star/Done messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-23 11:41:31 +02:00
Andreas Henriksson dc47cfee48 script: silence the done message on --quiet as well
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>
2014-06-23 11:31:08 +02:00
James Hunt 1474c09ea8 script: --quiet option is not quiet.
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>
2014-06-23 11:31:07 +02:00
Samuel Thibault 88e0f3df66 build-sys: fixes for non-Linux systems
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-19 10:35:23 +02:00
Karel Zak ee312c654b docs: fix "behaviour" vs. "behavior"
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>
2014-06-06 09:49:35 +02:00
Csaba Kos 578a1691f6 script: fix spurious exit from input read loop on EINTR. 2014-06-02 10:14:30 +02:00
Csaba Kos 26ed9fb872 script: fix a rare deadlock after child termination 2014-06-02 10:14:07 +02:00
Sami Kerola 8e3bdb3468 docs: setterm.1 clean up manual page groff style
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>
2014-05-26 16:35:59 +01:00
Sami Kerola f0dcd918eb docs: setterm.1 add options compatibility note
Both --option and -option formats are accepted.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-26 16:35:59 +01:00
Sami Kerola b5700fe506 docs: setterm.1 add missing options to manual page and remove duplicate
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-26 16:35:59 +01:00
Sami Kerola 5edc8dbc33 setterm: add usage() descriptions
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-26 16:35:59 +01:00
Karel Zak 3f91b9902b build-sys: add BUILD_{SCRIPT,SCRIPTREPLAY}
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-21 13:58:03 +02:00
Karel Zak 2832032772 setterm: fix 'bright' in usage, remove unnecessary error message
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-20 11:56:43 +02:00
Sami Kerola fbb08864cb setterm: remove ulcolor and hbcolor duplicates
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:58:14 +01:00
Sami Kerola 7a20c8a188 setterm: add set_blanking() action
This make over long perform_sequence() function a little bit shorter.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:24 +01:00
Sami Kerola 11f69359fa setterm: mark some options to be exclusive with each other
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:24 +01:00
Sami Kerola 78dd23cbf5 setterm: various visual terminal effects are not console specific
Setting colors, making line not to wrap, and so on can be attempted in
other than consoles.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola cda2b5b951 setterm: improve error messages
Reuse messages to make translation work easier.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola da27df2553 setterm: tell user when options does not effect
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola 16279cc2b4 setterm: improve perform_sequence() coding style
Delete pointless braces, new lines, and add spacing between operators.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola 253e5e7161 setterm: correct usage() bright color argument
This has been wrong since commit 2dc8716.  The bright is a prefix
attribute to other colors.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:17 +01:00
Sami Kerola 917465831f setterm: make -msglevel 0 to work as is did earlier
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>
2014-05-19 22:45:39 +01:00
Sami Kerola 609d48534a setterm: remove devfs and /dev/vcsa0 support
The devfs files /dev/vcc/a* does not need to be supported, and vcsa0 has
not existed in years if ever.

Reference: http://lwn.net/Articles/65197/
Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devices.txt?id=14186fea0cb06bc43181ce239efe0df6f1af260a#n260
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola 341566ff45 setterm: clean up screendump()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola dcc2fe2903 setterm: add init_terminal() to make main() shorter
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola d87d20b0fa setterm: add option control structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola 43f68f8fea setterm: remove usage comment segment
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>
2014-05-19 22:45:38 +01:00
Sami Kerola c591be873b setterm: move show_tabs() and screendump() functions
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>
2014-05-19 22:45:37 +01:00
Sami Kerola 35b578a02a setterm: use string utils to numeric parsing
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>
2014-05-19 22:45:36 +01:00
Sami Kerola fb27f91cac setterm: recommend long options with double hyphen
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>
2014-05-19 22:21:14 +01:00
Sami Kerola 45c90b77e6 setterm: use getopt_long_only() for option parsing
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>
2014-05-19 21:58:01 +01:00
Sami Kerola 104ecc7e70 setterm: clean up includes
Use klogctl(2) from sys/klog.h just like dmesg(1).  The rest is just
reordering, and indenting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 21:56:24 +01:00
Karel Zak 0a8dacfe86 agetty: update man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-19 10:59:54 +02:00
Benjamin Robin 584c07449c agetty: Update help usage function
Signed-off-by: Benjamin Robin <dev@benjarobin.fr>
2014-05-18 02:48:14 +02:00
Benjamin Robin 6c77c7fac2 agetty: Fix implementation of option --nonewline. The flag F_NONL was never set.
Signed-off-by: Benjamin Robin <dev@benjarobin.fr>
2014-05-18 02:47:42 +02:00
Karel Zak 0f283438bf agetty: use the "best" interface for \4 and \6
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>
2014-05-13 15:23:42 +02:00
Karel Zak c6b3513942 agetty: fix odd check for chardev/tty
References: https://bugzilla.redhat.com/show_bug.cgi?id=1069902
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:28:48 +02:00
Werner Fink b9c7390948 agetty: beside virtual consoles support xvc and hvc device lines as well
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>
2014-05-13 10:40:11 +02:00
Werner Fink f2bcda5183 agetty: better support of the special system consoles on S390
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>
2014-05-13 10:39:40 +02:00
Werner Fink bb280f79f1 agetty: avoid that agetty nor sulogin are fooled by a running plymouth
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>
2014-05-13 10:36:49 +02:00
Sami Kerola 3393c136a2 setterm: convert remaining magic values to symbolic references
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-12 13:59:59 +02:00
Sami Kerola 010f219d5f setterm: convert various constant number definitions to enums
The enum strings are visible when using debugger.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-12 13:54:38 +02:00
Karel Zak 6ed37604fe setterm: cleanup printf() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-12 13:53:10 +02:00
Sami Kerola 45656c9fe1 setterm: remove unused code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-12 13:38:53 +02:00
Sami Kerola 42e296b59d wall: replace magic number by named value
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-12 13:38:25 +02:00
Sami Kerola afbdd44fe3 term-utils: avoid error message string length couting errors
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>
2014-05-12 13:37:35 +02:00
Sami Kerola 89dda67868 build-sys: remove unnecessary void casts
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-12 13:07:12 +02:00
Karel Zak 78a3b0af30 include/carefulputc: cleanup and add fputs_{quoted,nonblank}()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Wolfgang Richter a21f7ec91d scriptreplay: no need to skip first time value or last bytes fixes #58 2014-03-19 22:47:11 -04:00
Wolfgang Richter b0d6b85720 script: time from end of read() call partially fixes #58 2014-03-19 22:45:48 -04:00
Karel Zak 4368e3e687 script: clean up files usage
* 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>
2014-02-21 13:39:14 +01:00
Jesper Dahl Nyerup 5d0ce5e84f script: Also flush writes to timing file.
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>
2014-02-21 13:16:20 +01:00
Jesper Dahl Nyerup 7f1d483638 scriptreplay: Add --maxdelay option.
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>
2014-02-10 19:24:28 +01:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
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>
2014-01-24 13:04:14 +01:00
Karel Zak c6fca22e3a script: use all-io.h to make the code more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-16 14:44:37 +01:00