Commit Graph

650 Commits

Author SHA1 Message Date
Karel Zak 2db4c7f0b3 hexdump: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:51:44 +02:00
Karel Zak 45f40a1ed8 pg: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:51:44 +02:00
Karel Zak 28941d202a misc: improve string to number conversions
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:51:02 +02:00
Karel Zak cd969e8908 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-07-20 11:50:52 +02:00
Karel Zak 86328e78ea 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-07-20 11:31:43 +02:00
Karel Zak 42a9c18706 more: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:00 +02:00
Karel Zak 37bb1b07e0 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-07-20 11:23:12 +02:00
Samir Benmendil a27ff267f0 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-07-20 11:09:26 +02: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
Sami Kerola 0186ff364d
ul: use size_t to measure memory allocation size
The size_t is the type libc memory allocation functions use.  The size_t
also provides allocation range that is enough not to a simple tool like this
to perform paranoia size checks.  Just let the realloc(3) fail if there is
not enough memory available to handle the requested line size.  That is a
lot more straightforward.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 21:13:24 +01:00
Sami Kerola 9a59ee6525
ul: improve function and variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 21:13:24 +01:00
Sami Kerola 580c63259b
ul: rename enumerated mode symbols
First two are are ISO/IEC 2022 graphic character sets G0 (normal) and G1
(alternative), that one has to Switch In (SI) and Switch Out (SO).  The rest
are about how ul(1) is interacting with various text emphasis.

Reference: https://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-6.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 21:12:49 +01:00
Sami Kerola 52e3ce0097
ul: remove function like putwp preprocessor define
The #ifdef HAVE_WIDECHAR can be removed, because the command already is
using wide character functions elsewhere without fallbacks.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 20:29:27 +01:00
Sami Kerola 1962d5cfca
ul: free most allocations ncurses did during setupterm()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 20:29:27 +01:00
Sami Kerola eaf68e3083
ul: replace global runtime variables with a control structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 20:29:27 +01:00
Sami Kerola 4942193926
ul: add a term capabilities tracking structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 20:29:27 +01:00
Sami Kerola a2811907e9
ul: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 20:29:27 +01:00
Sami Kerola 5b627d8496
ul: tidy up coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-20 20:29:27 +01:00