Commit Graph

25 Commits

Author SHA1 Message Date
Karel Zak c0246ce059 mesg: use only stat() to get the current terminal status
open()+stat() does not work for example after su(1) (from root to
non-root). It seems better to use only stat() to get the current
terminal status.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1906157
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-12 09:39:59 +02:00
Karel Zak 2c864ba8fc mesg: avoid 'ttyname failed: Success' message
The ttyname(3) can fail to access /dev/ path, and that will cause function
to fail without setting errno value with result of rather confusing error
message.  Lets start setting stdin permission via /proc when this happens as
a go-around, with hope kernel following symlink does not fail.  Ok, noted,
that hopes of symlink follow working are pretty slim.

Based on patch from Sami Kerola <kerolasa@iki.fi>.

Reference: https://github.com/lxc/lxd/issues/1724
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-27 13:07:12 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Sami Kerola 8dd5832395 mesg: do not print 'ttyname failed' message unless --verbose requested
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>
2018-08-03 12:27:02 +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 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
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
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
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
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 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
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
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
Sami Kerola 5d324c6b94 various: fix mixing declarations and code compiler warnings [smatch]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-10-08 15:47:59 +02:00
Sami Kerola 1e6f6cdb84 mesg: sync usage() with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:07 +01:00
William Pitcock 51924a4ef0 add missing rpmatch.h everywhere it needs to be
Signed-off-by: William Pitcock <nenolod@dereferenced.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-20 13:04:02 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Sami Kerola add1b8afd0 translation: unify stat error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola cdd2a8c360 term-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:46:25 +02:00
Sami Kerola 041b8ab252 mesg: use rpmatch to yes/no question
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:04 +01:00
Karel Zak 2960a4a343 mesg: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:39:03 +02:00
Karel Zak a7a4aa9857 mesg: add \n to usage() output
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-04-14 17:16:30 +02:00
Sami Kerola 849c6ea3f7 mesg: new --verbose option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-14 17:08:00 +02:00
Sami Kerola fe16e12513 mesg: use long options, also --help and --version added
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-14 17:07:26 +02:00
Karel Zak c4571e4908 build-sys: move mesg to term-utils/
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-02 14:18:31 +01:00