Commit Graph

13 Commits

Author SHA1 Message Date
Egor Chelak 9203b41a4f nologin: use ul_copy_file
Suggested-by: Sami Kerola <kerolasa@iki.fi>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-11-09 07:19:24 +02:00
Sami Kerola beb61b07c2
nologin: silently ignore well known shell command-line options
nologin is typically used in /etc/passwd as a shell replacement.  Hence it
is reasonable to ignore well known command-line options silently to avoid
unwanted ugly error messages.

Addresses: https://github.com/karelzak/util-linux/issues/895
Requested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-17 08:33:04 +00:00
Stanislav Brabec a174eefb41 nologin: Prevent error from su -c
"su -c" can pass "-c" to nologin. It causes ugly error:

su -c "echo OK" - man
-nologin: invalid option -- 'c'
Try '-nologin --help' for more information.

Accept -c to prevent this error.

Signed-off-by: Josef Cejka <jcejka@suse.com>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-10-11 10:08:03 +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
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 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
Karel Zak dd732fa251 nologin: don't call fstat() after failed open() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:59:33 +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 bd299782ca
nologin: require /etc/nologin.txt to be file
This makes silly practical jokes impossible, like for example symlinking
/dev/null or dev/random to /etc/nologin.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:38 +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
Karel Zak 88407b9321 nologin: add new command
Currently it's maintained as distro specific (or people use impolite
/bin/false way).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30 13:36:26 +02:00