Commit Graph

659 Commits

Author SHA1 Message Date
Karel Zak 2ae8b75754 more: fix -e in non-interactive mode
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-05 10:53:13 +02:00
Ian Jones df6b29d3b8 more: POSIX compliance patch preventing exit on EOF without -e
[kzak@redhat.com: - merge all patches to one commit,
                  - improve prompt for non-tty stdin]

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-09-29 14:50:14 +02:00
Mario Blättermann e674323904 Man pages: Fix end extend formatting 2021-09-21 20:48:11 +02:00
ritikrajdev e5e0eac42c
more - Bug Resolve - new line separated command execution 2021-09-14 04:27:14 +05:30
Karel Zak 9714331843 column: segmentation fault on invalid unicode input passed to -s option
The function mbs_to_wcs() returns NULL on invalid UTF.

Fixes: https://github.com/karelzak/util-linux/issues/1425
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-31 12:31:15 +02:00
Vincent Smeets 9c59b604d3 Erase line before writing the filename 2021-08-20 11:00:33 +02:00
Karel Zak c67497ce66 more: Calling open without checking return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-18 10:25:14 +02:00
Karel Zak 042fbf3712 more: use snprintf() rather than sprintf() 2021-07-27 13:31:18 +02:00
Karel Zak ccedcc55e1 hexdump: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-25 11:05:21 +02:00
Karel Zak 0461279ab3 pg: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-25 10:24:35 +02:00
Karel Zak 1d5c14ae1a misc: improve string to number conversions
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-24 16:42:53 +02:00
Karel Zak 86f05d3946 more: fix null-pointer dereference
The command allows executing arbitrary shell commands while viewing a file by
entering '!' followed by the command. Entering a command that contains a '%',
'!', or '\' causes a segmentation violation.

The same more(1) function has a problem when not file is specified (cat
/etc/passwd | more) on command line.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1975153
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-23 11:37:31 +02:00
Karel Zak 1293b0f65d misc: consolidate stat() error message
Let's use the same error message everywhere to reduce number of
strings for translators.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-21 12:40:41 +02:00
Karel Zak 17fc8693cd include/c: add drop_permissions(), consolidate UID/GID reset
Fixes: https://github.com/karelzak/util-linux/issues/1354
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-21 12:25:31 +02:00
Karel Zak 2f38ae595b more: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-18 16:58:38 +02:00
Karel Zak 19f2cebd48 more: fix setuid/setgid order
The rule is pretty simple, always use setgid() before setuid().

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 12:21:04 +02:00
Samir Benmendil aa6d42f16f hexdump: correctly display signed single byte integers
When using the format string '/1 "%d"', the byte did not display as a
signed integer as expected, it was interpreted as unsigned.
2021-06-09 01:21:46 +01:00
Sami Kerola ec4153cc28
more: fix floating point exception core dump
Make the code avoid divided by zero.  This can happen when file has content
but is zero in size.  Such files can be found from procfs, possibly some
other pseudo-filesystems.  To reproduce the issue run the following.

    $ more /proc/crypto
    ...
    Floating point exception (core dumped)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2021-05-19 20:23:48 +01:00
Christian Hesse e08e3d587c fix whitespace issue in ducumentation
This removes trailing whitespaces and fixes minor issues.
2021-05-10 15:53:50 +02:00
Karel Zak 21b16433a1 column: add placeholder '0' to specify all columns
Fixes: https://github.com/karelzak/util-linux/issues/1306
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 10:46:51 +02:00
Karel Zak d8d54e4bfc build-sys: keep adoc files in dist_noinst_DATA
* rename MANPAGES_EXTRA= to ADOCFILES_COMMON=

* keep track about individual adoc files by dist_noinst_DATA=
  This variable is not effected by automake conditions, so the files
  are always distributed.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-05 13:35:30 +02:00
Karel Zak e5bde19ae2 build-sys: cleanup Makefiles
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-20 14:39:32 +02:00
Chris Hofstaedtler fdf734f7f3 hexdump: add "hd" program name to man page
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Bug-Debian: https://bugs.debian.org/978977
2021-04-13 10:20:42 +02:00
Karel Zak ae4e859f68 Merge branch 'more-fixes' of https://github.com/h-c-mueller/util-linux
* 'more-fixes' of https://github.com/h-c-mueller/util-linux:
  more: fix ARROW_DOWN and PAGE_DOWN behaviour to not skip lines
  more: fix command 'f' (screen forward) behaviour
2021-04-06 11:24:40 +02:00
Karel Zak 625e9c61e8 build-sys: make man pages location independent
We need to evaluate "include::" directive relatively to project
top-level source directory rather than to the current document
location.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-31 11:50:47 +02:00
Karel Zak 25ce8fb1ed Merge remote-tracking branch 'mariobl/topic/asciidoc'
* mariobl/topic/asciidoc: (71 commits)
  Asciidoc: Update .pot template
  Asciidoc: Reorder example command sequence
  Asciidoc: Update .pot template
  Asciidoc: Better gettext message splitting in nsenter.1.adoc
  Asciidoc: Update .pot template
  Asciidoc: Fix typo and remove invisible spaces which confuse po4a
  Asciidoc: Update .pot template
  Asciidoc: Fix typo
  Asciidoc: Fix artifact from initial import, sixth attempt
  Asciidoc: Update .pot template
  Asciidoc: Fix artifacts from initial import, fifth attempt
  Asciidoc: Fix artifacts from initial import, fourth attempt
  Asciidoc: Update .pot template
  Asciidoc: Fix artifacts from initial import, third attempt
  Asciidoc: Fix artifacts from initial import, second attempt
  Asciidoc: Fix artifacts from initial import
  Asciidoc: Add po4a config file and initial translation template for man pages
  Asciidoc: Small indentation fix in mount.8.adoc
  Asciidoc: Review sys-utils man pages, part 2
  build-sys: fix out-of-tree build
  ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-29 15:09:27 +02:00
Mario Blättermann 544e64e09e Asciidoc: Fix typo and remove invisible spaces which confuse po4a 2021-03-28 10:47:00 +02:00
Karel Zak 4f79d3032e build-sys: split man pages and man page links
The symlinks are generated by asciidoctor and current dist_man_MANS
depends on order (nan page before man link). This solutions is useless
when execute "make -j". The real solution is to keep man pages in
separate variable and use only this variable evaluate what we need to
generate.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-26 11:49:59 +01:00
Mario Blättermann bbeadfdd5b Asciidoc: Review text-utils man pages 2021-03-25 19:17:48 +01:00
Mario Blättermann 99157f44da Asciidoc: Formatting cleanup 2021-03-21 13:02:56 +01:00
Mario Blättermann 78fec3e5ba Asciidoc: Remove already imported text-utils *roff man pages 2021-03-21 12:50:16 +01:00
Mario Blättermann f42ed8190c Asciidoc: Unify spelling of »User Commands« 2021-03-21 10:00:16 +01:00
Mario Blättermann 295b3979d9 Asciidoc: Add Po4a hint to file headers 2021-03-20 16:42:47 +01:00
Mario Blättermann d315cc4d96 Asciidoc: Re-add empty lines to man pages 2021-03-19 20:52:00 +01:00
Hannes Müller e899168a1d more: fix ARROW_DOWN and PAGE_DOWN behaviour to not skip lines
Currently ARROW_DOWN and PAGE_DOWN is bound to command 's' (skip lines).
But this behaviour is not what the user expects, since at least one line
is always missing! Furthermore at the end of the file there is typically
this skipping lines message, if the remainder does not fit in a
complete screen. This conflicts also with e.g. less and man PAGE_DOWN
behaviour. The 'natural' behaviour is binding to
more_kc_jump_lines_per_screen.
If more is extended to also jump only a specific number of lines forward,
this would be even a better binding for ARROW_DOWN.
2021-03-17 20:42:11 +01:00
Hannes Müller 9f303a2bf4 more: fix command 'f' (screen forward) behaviour
Currently 'f' behaves like 's', which is not correct according to
man page.
Bug was introduced with 1f861935a7
2021-03-17 20:39:31 +01:00
Zbigniew Jędrzejewski-Szmek d4c880d5a4 meson: add second build system
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install

v2:
- Optional items are now based on the 'feature' feature in meson.
  Built libraries which are disabled turn into disabler() objects
  and also poison any executables which link to them.

What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
  man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
  ./configure settings

Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
  are all used, so that should be fine. In the build system, some
  files should be skipped, but that is probably not always done properly.
  Getting this right might require some testing of various build option
  combinations to get the details right.

Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???

Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
  autogenerated .pc file. Not sure if they should be there or not. If
  necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
  sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
  anyway, so maybe we could simplify things but not implementing it at
  all under meson?
2021-03-17 15:07:27 +01:00
Mario Blättermann aad107b6d7 Asciidoc: Import textutils man pages 2021-03-12 14:16:26 +01:00
Frantisek Sumsal c40b3cd03d text-utils: correctly detect ASan under clang
__SANITIZE_ADDRESS__ is not defined when compiling with clang, so cover
both use cases with a special set of macros
2021-02-01 11:59:47 +01:00
Sami Kerola 186946b239
man: add missing backslash to caret printing macro
Fixes: 3ea54b843c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-28 09:53:13 +00:00
Sami Kerola 14a36f96ee
col: make input to tolerate invalid wide characters
The getwchar(3) will choke and exit if invalid character is encountered.
This change will make col(1) to print broken multibyte characters as
\x{hex} string.

Reported-by: Vitaly Lipatov <lav@etersoft.ru>
Addresses: https://github.com/karelzak/util-linux/issues/1198
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-02 22:12:32 +00:00
Sami Kerola 32a4efc567
more: improve error messaging when input file is directory
Before this change the error message about directory was not informative,
and a little bit out of place.

    $ touch empty ; ./more ./empty /
    ::::::::::::::
    ./empty
    ::::::::::::::
    magic failed: cannot read fd 4 (Is a directory)
    ::::::::::::::
    /
    ::::::::::::::

After the change messaging is reverted back to what it used to be.

    $ ./more ./empty /
    ::::::::::::::
    ./empty
    ::::::::::::::

    *** /: directory ***

And while on it lets remove repeated fstat() call.

Fixes: 09070e1a65
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-14 16:07:05 +00:00
Sami Kerola 792ff9fcee
ul: make set_column() zero check more obvious
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-14 16:07:05 +00:00
Sami Kerola c7ad82209a
colrm: fix argument parsing
Short options had all sortss of characters listed, that were clearly copied
from col(1) command getopt_long() invocation.  Luckily both -V and -h were
part of the short options, but lets get rid of the unnecessary ones.

Fixes: 1647d032a7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-14 16:06:56 +00:00
Sami Kerola 3ea54b843c
man: make tilde and caret characters to render correctly
As mentioned in 'Generating optimal glyphs' title in the manual page
mentioned in reference:

    Where a proper caret (^) that renders well in both a terminal and PDF is
    required, use "\(ha".

    Using a naked "~" character results in a poor rendering in PDF.  Instead
    use "\(ti".

Reference: https://man7.org/linux/man-pages/man7/man-pages.7.html#STYLE_GUIDE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-14 15:22:34 +00:00
Samanta Navarro cb77628876 misc: fix typos [codespell]
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2020-11-04 11:42:25 +00:00
Egor Chelak 1b10fa0ef7 cast NULL to char * when using execl
When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.

The call in newgrp.c was changed for consistency.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-10-29 19:49:07 +02:00
Karel Zak 9210db64a6 ul: fix use of unsigned number
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-21 12:45:02 +02:00
Karel Zak 5064635395 ul: small coding changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-21 11:16:34 +02:00
Sami Kerola 1a3f71b292
ul: flip comparisons to lesser to greater order
1 < 2 < x < 4 is the order is the natural of values.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 21:13:25 +01:00