Commit Graph

79 Commits

Author SHA1 Message Date
Karel Zak 670b10ae36 lib/c_strtod; add locale independent strtod()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-25 11:31:08 +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 0216836e8b build-sys: fix test_loopdev build
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-20 14:22:34 +02:00
Karel Zak d4423cce9b lib/loopdev: fix is_loopdev() to be usable with partitions
The current implementation of the function does not care if the device
is whole-disk device or partition, all is loopdev. This is regression
as the original is_loopdev() version was based on whole-disk devices
major numbers only.

Fixes: https://github.com/karelzak/util-linux/issues/1202
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-20 13:20:12 +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
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
Karel Zak 308a097968 meson: update sources and dependencies
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-17 15:07:27 +01:00
Luca Boccassi c65953d72b Automake: use EXTRA_LTLIBRARIES instead of noinst_LTLIBRARIES
noinst_LTLIBRARIES causes the libraries to be always built
unconditionally. EXTRA_LTLIBRARIES causes them to be built
only if other build target needs them.
In other words, avoid building libcommon.a and libtcolors.a
unless they are needed by another library/executable and
save some build time.

https://www.gnu.org/software/automake/manual/html_node/Libtool-Convenience-Libraries.html
2021-03-15 12:17:31 +00:00
Karel Zak 71ba2792ab lib: use procutils.c on Linux only
Fixes: https://github.com/karelzak/util-linux/issues/1251
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 12:24:13 +01:00
Karel Zak 966420219c lib/caputils: split to multiple functions, add test
Let's split the code to make it possible to test separately bsearch as
well as procfs based cap_last_cap().

 $ ./test_caputils --last-by-bsearch
 last cap: 39
 $ ./test_caputils --last-by-procfs
 last cap: 39
 $ ./test_caputils --last
 last cap: 39

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-20 11:21:41 +01:00
Karel Zak 37bcd05602 lib/jsonwrt: add new functions to write in JSON
We need JSON formatting stuff also outside libsmartcols.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-12 11:19:13 +01:00
Karel Zak b21d741c21 login: move proctitle code to login.c
The functions are used only by login(1), let's keep the code in
login.c only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-06 15:15:15 +02:00
Karel Zak eee886ba1d build-sys: exclude GPL from libcommon
The library is not distributed and almost all code in this ar(1)
archive is Public Domain or LGPL ... but let's avoid any doubts and do
not mix non-GPL and GPL code there.

Addresses: https://github.com/karelzak/util-linux/issues/1157
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-06 13:26:36 +02:00
Karel Zak 0a9939816c lib/buffer: add simple grow-able buffer
The goal is to use it in libmount when generate options strings
and in libsmartcols to replace libscols_buffer.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-29 12:06:11 +02:00
Sami Kerola 3d6fa8da69
tests: add sanitize_env() check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:08 +01:00
Zbigniew Jędrzejewski-Szmek ac660b80fd build-sys: rename automake variable to match define name
Just to make things a bit more consistent.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 10:53:15 +01:00
Karel Zak 35c6ed615f libblkid: move UTF encoding function to lib/
Let's consolidate the code, we need to use it in libfdisk too. It
seems better to keep it generic and libblkid independent.

This patch also removes blkid_encode_alloc(), this function is overkill.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 12:00:27 +01:00
Karel Zak 8e1b131e0a build-sys: use parse-date() only for hwclock
The parse-date.y is used only for hwclock, let's keep it together.
Note that the file (originally from gnulib) has GPLv3 license, so it's
better to make it obvious that we use it really only for hwclock (also
GPL).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-07 09:02:23 +01:00
Karel Zak 52e9e94ea3 lib/pty-session: fix compilation
lib/test_pty-monotonic.o: In function `get_boot_time':
/home/travis/build/karelzak/util-linux/lib/monotonic.c:29: undefined reference to `clock_gettime'
lib/test_pty-monotonic.o: In function `gettime_monotonic':
/home/travis/build/karelzak/util-linux/lib/monotonic.c:56: undefined reference to `clock_gettime'

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-10 08:57:30 +02:00
Karel Zak 4d5b2fed8f lib/pty: allow use callback from mainloop
This allows to control mainloop behavior from PTY applications. For
example you can write to child (shell) process independently on the
current stdin.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:54 +02:00
Karel Zak 6954895cae lib/pty-session: add generic PTY container code
The idea is to consolidate script(1), scriptlive(1) and su(1) --pty
and use the same code everywhere.

TODO: add callbacks for stdin/out logging (necessary for script(1)).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:54 +02:00
James Peach cef4decf04 unshare: add --keep-caps option
Add the --keep-caps option to unshare to preserve capabilities that
are granted when creating a new user namespace. This allows the child
process to retain privilege within the new user namespace without also
being UID 0.
2019-09-09 20:23:08 -07:00
Karel Zak a68ed87ffe build-sys: do not require dirfd()
The dirfd() is required on many places, but it should not be required for
all utils by ./configure.ac.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-03 11:23:33 +01:00
Karel Zak 5387c01517 lib/sysfs: new implementation
* reuse ul_path_* API

* allow to use prefix for sysfs paths, so we can use snapshots from
  sysfs for regression tests

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 12:56:16 +02:00
Karel Zak 1ed21c80ed lib/path: new implementation
The goal is to avoid duplicate code in path.c and sysfs.c and make it
possible to define prefix for paths for all sysfs and procfs based
utils. Now we have /proc snapshots (for tests) for lscpu only. It
would be nice to have the same (for sysfs) for lsblk and another tools.

* very simple API to read numbers, strings and symlinks

* based on openat()

     pc = ul_new_path("/sys/block/sda");
     ul_path_read_u64(pc, &size, "size");
     ul_path_read_u64(pc, &lsz, "queue/logical_block_size");

* printf-like API to generate paths, for example:

     ul_path_readf_u64(pc, &num, "sda%d/size", partno)

* allow to define prefix to redirect hardcoded paths to another
  location, for example:

     pc = ul_new_path("/sys/block/sda");
     ul_path_set_prefix(pc, "/my/regression/dump");
     ul_path_read_u64(pc, &num, "size");

  to read /my/regression/dump/sys/block/sda/size

* allow to extend the API by "dialects", for example for sysfs:

     pc = ul_new_path(NULL);
     sysfs_blkdev_init_path(pc, devno, NULL);

  and use ul_path_* functions to read from @pc initialized by
  sysfs_blkdev_init_path()

* add test_path binary

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 11:58:10 +02:00
John Groves 277e777fe8 lib: Add simple crc32c() function
Source: freebsd/sys/libkern/crc32.c
This code is an unmodified fragment from the source.  Will fixup
comments / naming in next commit

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-16 11:44:39 +01:00
Niklas Hambüchen 6855f6e80b kill: Extract signal names into signames.h/signames.c 2017-10-14 04:46:13 +02:00
Karel Zak 4f5f35fc83 login: add xgetpwnam()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:48:56 +02:00
Philip Prindeville 0047626887 libuuid: add support for hash-based UUIDs
Adding V3 and V5 UUIDs per RFC-4122.

[kzak@redhat.com: - fix symbols file]

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-05 11:26:39 +02:00
Ruediger Meier c0d7b11a3f build-sys: fix library order when linking
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:

./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 03:16:48 +02:00
Karel Zak c9ae73c03f lib/colors: fix test compilation
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-31 01:29:25 +02:00
Karel Zak 23d4726784 lib/colors: ncurses cleanup
* use proper paths to term.h
* keep ncurses support optional
* link with TINFO_LIBS (-ltinfo), or fallback to NCURSES_LIBS (-ltinfo -lncurses)
* don't include unnecessary ncurses.h (term.h is enough)

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-30 17:14:12 +02:00
Karel Zak 30d7f61f4f build-sys: add parse-date.y
* add lib/parse-date.y to build system
* add necessary autotools stuff to generate .c on the fly
  (autotools are smart enough to add generated file to tarball)
* check for bison version by ./autogen.sh
* add non-wanted junk to .gitignore

With some modification by J William Piggott with regard to
moving the parse-date API into timeutils.h

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-03-04 11:01:56 -05:00
Karel Zak 299ef2c457 lib/mbsedit: add simple buffer editor
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 13:47:44 +01:00
Karel Zak 63dc575be3 build-sys: test_linux_version is Linux only
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-04 15:44:51 +01:00
Karel Zak e8f7acb0d3 lib: use unique ifdefs for tests
Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more
robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-04 11:44:37 +01:00
Karel Zak 5b9403a68f lib/linux_version: add test for manual testing
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-02 11:36:53 +01: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 3c201431ee lib/timeutils: add strxxx_iso() functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-11 15:31:02 +02:00
Kent Overstreet 7ce27dc517 libblkid: Update for newer bcache superblocks
Later version of bcache add different checksum types, and allow for superblocks
greater than 4k - skipping the checksum check (as in most other probes) is the
easiest solution.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2016-03-23 10:52:38 +01:00
Ruediger Meier dc0495166f build-sys: add and use openat build conditionals
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:37:25 +01:00
Ruediger Meier 1a048dc5e2 lib: move fopen_at() to fileutils.h, remove at.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:36:00 +01:00
Ruediger Meier 2208b3ccb2 lib: remove openat fallback functions (include/at.h)
I have validated that we are still compatible at least back to
  - openSUSE 11.4
  - SLE 11
  - RHEL/CentOS 6
  - OSX 10.10.x, (Xcode 6.3)
  - FreeBSD 10.2

Confirmed incompatibility:
  - OSX 10.9.x, (Xcode 6.2)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:33:56 +01:00
Ruediger Meier b0b54cc582 build-sys: always add AM_CFLAGS
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:17:29 +01:00
Ruediger Meier b201f1d86c build-sys: always use global LDADD
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:16:58 +01:00
Karel Zak 04a5cb58b6 namei: move icache to lib/
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-27 13:56:01 +01:00
Karel Zak f9ffaac0d2 build-sys: fix test_colors build
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-24 14:33:25 +02:00
Karel Zak 0bef6f759b libsmartcols: don't link with tinfo
Let's move color names to sequence translation to separate file to
make it usable without all the stuff in lib/colors.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-24 12:57:46 +02:00
Karel Zak a6bf40ee77 lslogins: merge read_utmp() code
The code is used only in lslogins, so it does not make sense to
maintain it in libcommon.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-16 11:26:14 +02:00