Commit Graph

15567 Commits

Author SHA1 Message Date
Tj 9fd75ae758 mount: man-page; add all overlayfs options
The section in man (8) mount for overlay is missing nine options which
aren't documented elsewhere either and are useful features to be aware
of and use.

Fixes #1350.
2021-06-17 13:20:36 +01:00
Alex Xu 637cc045ee build-sys: Update configure.ac
1. the test incorrectly used AC_COMPILE_IFELSE instead of
   AC_LINK_IFELSE, defeating the purpose of checking -lcrypt.
2. the test did not properly restore LIBS, causing later checks to all
   fail if libcrypt wasn't found.
3. HAVE_LIBCRYPT only controls whether to use -lcrypt, it is not
   needed or used in any source files.

[kzak@redhat.com: - improve commit message
                  - use UL_{SET,RESTORE}_FLAGS() rather than directly
		    modify $LIBS]

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 13:59:35 +02:00
Karel Zak 9dbae34c3d lib/path: improve ul_path_readlink() to be more robust
According to POSIX, readlink() makes no effort to null-terminate buffer
with the result. It seems better to hide this disadvantage in the
ul_path_...() API rather than assume buf[sz] = '\0' everywhere.

Reported-by: Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 13:28:32 +02:00
Karel Zak 2384fa6e4d mkfs.cramfs: add comment to explain readlink() use
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 13:26:50 +02:00
Karel Zak 538f010c8f rename: use readlink() in more robust way
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 13:25:43 +02:00
Karel Zak 403cd1086e namei: simplify code
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 13:23:53 +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
Karel Zak 8ff8b02782 hardlink: small regex stuff refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:58:14 +02:00
Karel Zak d3f77b4b8b sulogin: add missing ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:44:02 +02:00
Karel Zak 286865bf7e sulogin: use explicit_bzero() for buffer with password
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:39:32 +02:00
Karel Zak 59e2df8fe8 login: remove obsolete and confusing comment
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:13:50 +02:00
Huang Shijie 4cae2104ec lscpu: add bios_family
In the arm platform, we do not have the "CPU family" as X86.
In the linux kernel, it is hardcode to set the "CPU architecuture:8"
which should be changed for arm v9 in future.

This patch adds "bios_family" field, which we can get from the DMI table.
In the ampere Altra platform, we can get the new lscpu output:
    ----------------------------------------------------------------
	Architecture:                    aarch64
	CPU op-mode(s):                  32-bit, 64-bit
	Byte Order:                      Little Endian
	CPU(s):                          160
	On-line CPU(s) list:             0-159
	Vendor ID:                       ARM
	BIOS Vendor ID:                  Ampere(R)
	Model name:                      Neoverse-N1
	BIOS Model name:                 Ampere(R) Altra(R) Processor Q00-00 CPU @ 3.0GHz
	BIOS CPU family:                 257
	Model:                           1
	Thread(s) per core:              1
    ----------------------------------------------------------------

[kzak@redhat.com: - s/sprintf/snprintf/]

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 11:12:14 +02:00
Huang Shijie a772d7c493 lscpu: get the processor information by DMI
The patch :367c85c47286 ("lscpu: use SMBIOS tables on ARM for lscpu")
relies on the existence of "/sys/firmware/dmi/entries/4-0/raw",
which may not exist in standard linux kernel.

But "/sys/firmware/dmi/tables/DMI" should exist and can provide the required
processor information.

This patch uses "/sys/firmware/dmi/tables/DMI"
to get the processor information:

Before this patch, in Ampere Altra platform, the lscpu output is:
   ---------------------------------------------
	Architecture:                    aarch64
	CPU op-mode(s):                  32-bit, 64-bit
	Byte Order:                      Little Endian
	CPU(s):                          160
	On-line CPU(s) list:             0-159
	Vendor ID:                       ARM
	Model name:                      Neoverse-N1
	Model:                           1
	Thread(s) per core:              1
	Core(s) per socket:              80
	Socket(s):                       2
    ........................................
   ---------------------------------------------

After this patch, we can use get the lscpu output
in Ampere Altra platform:
   ---------------------------------------------
	Architecture:                    aarch64
	CPU op-mode(s):                  32-bit, 64-bit
	Byte Order:                      Little Endian
	CPU(s):                          160
	On-line CPU(s) list:             0-159
	Vendor ID:                       ARM
	BIOS Vendor ID:                  Ampere(R)
	Model name:                      Neoverse-N1
	BIOS Model name:                 Ampere(R) Altra(R) Processor Q00-00 CPU @ 3.0GHz
	Model:                           1
	Thread(s) per core:              1
	Core(s) per socket:              80
	Socket(s):                       2
    ........................................
   ---------------------------------------------

[kzak@redhat.com: - s/sprintf/snprintf/]

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 11:09:19 +02:00
Karel Zak 66e259c746 libblkid: fix and cleanup blkid_safe_string()
* Don't use 'size_t len' variable for utf8_encoded_valid_unichar()
  return code as it returns negative numbers on invalid utf8 sequence.

* Don't rely only on \0, but check the current position against output
  buffer size.

* Accept hex encoding like the original version.

* Use else-if to avoid unnecessary 'continue'.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 10:58:11 +02:00
Karel Zak 8a3a74160b mkswap: fix holes detection (infinite loop and/or stack-buffer-underflow)
Reported-by: Brian Lane <bcl@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1971877
Fix: https://github.com/karelzak/util-linux/issues/1348
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-15 12:07:34 +02:00
Karel Zak 3e03cb6806 lib/loopdev: perform retry on EAGAIN
Suggested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-15 10:34:46 +02:00
Karel Zak 6db3685989 libblkid: Optimize the blkid_safe_string() function
Processing whitespace characters. Allows valid ASCII, valid UTF-8.
Replace everything else with '_'

Co-Author: changlianzhi <changlianzhi@uniontech.com>
Signed-off-by: changlianzhi <changlianzhi@uniontech.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-15 10:25:24 +02:00
Karel Zak f3e5d34cac lib/strutils: make test_strutils_normalize() more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-15 10:25:06 +02:00
Karel Zak c862d0e177 lib/strutils: improve normalize_whitespace()
Let's make it possible to use the function to normalize the string
between two buffers (from source to destination).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-14 16:24:59 +02:00
Karel Zak 38b9be784b Merge branch 'document-selinux-nosuid' of https://github.com/topimiettinen/util-linux
* 'document-selinux-nosuid' of https://github.com/topimiettinen/util-linux:
  mount.8.adoc: document SELinux use of nosuid mount flag
2021-06-14 12:48:08 +02:00
Topi Miettinen 9a06cc233c
mount.8.adoc: document SELinux use of nosuid mount flag
Using mount flag `nosuid` also affects SELinux domain transitions but
this has not been documented well.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2021-06-12 11:37:51 +03:00
Platon Pronko 8153ca8eee dmesg: fix indentation in man page
Double-semicolon at the end of the option line results in description
being indented extra tab to the right. Replacing them with double-colons
allows all options to be displayed at the same indent level.
2021-06-11 21:23:59 +03:00
Karel Zak 1e881378d6 lib/path: fix possible leak when use ul_path_read_string() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-11 15:43:36 +02:00
Karel Zak 3fdb178370 hwclock: close adjtime on write error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-11 15:17:42 +02:00
Karel Zak 777fe9f512 newgrp: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-11 15:10:22 +02:00
Karel Zak fb9ed3b409 dmesg: fix possible memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-10 13:44:25 +02:00
Karel Zak a71f7f1173 findmnt: (verify) fix memory leak [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-10 13:35:05 +02:00
Karel Zak 3c3f7722ae findmnt: (verify) fix cache related memory leaks on --nocanonicalize [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-10 13:28:35 +02:00
Karel Zak 60d1f1a329 libblkid: check for ioctl macro rather than for header file
libblkid/src/probe.c:1012:22: error: ‘BLKGETZONESZ’ undeclared (first use in this function)
 1012 |   if (!ioctl(pr->fd, BLKGETZONESZ, &zone_size_sector))
      |                      ^~~~~~~~~~~~

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09 16:12:13 +02:00
Karel Zak 366063645f build-sys: make autogen.sh output more user friendly
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09 16:09:16 +02:00
Karel Zak 67735475db build-sys: be verbose about missing gettext
Reported-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09 15:54:09 +02:00
Karel Zak 98a586f672 lsblk: sort list of columns
It's better to maintain sorted list and it's also better for --help output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09 11:09:33 +02:00
Karel Zak 856457bfcf lsblk: add column START for partition start offsets
Fix: https://github.com/karelzak/util-linux/issues/1340
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09 10:57:54 +02:00
John Baublitz 0842c84218 libblkid: Add hyphens to UUID string representation in Stratis superblock parsing
[kzak@redhat.com: - small code cleanup]

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09 10:40:31 +02:00
Karel Zak 20cc7d100a Merge branch 'fix-display-signed-char' of https://github.com/Ram-Z/util-linux
* 'fix-display-signed-char' of https://github.com/Ram-Z/util-linux:
  hexdump: correctly display signed single byte integers
2021-06-09 10:32:23 +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
ratijas 3f347f956a
lsblk: fix formatting in -e option 2021-06-08 19:12:19 +03:00
Qais Yousef 6da826a521 uclampset: Fix left over optind++
The code was changed to use ':' in getopt_long() but these were left
over by mistake causing weird random errors when using these options
depending on the order they were fed.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-06-08 15:56:00 +02:00
Nicolai Dagestad 63e523a151 rfkill: Set scols table name to make the json output valid
[kzak@redhat.com: - s/rfkill/rfkilldevices/]

Fixes: https://github.com/karelzak/util-linux/issues/1339
Signed-off-by: Nicolai Dagestad <nicolai@dagestad.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-07 10:42:02 +02:00
Karel Zak 0d281926a3 libsmartcols: fix bare array on JSON output
The bare array ({[...]}) for top level list of entries is invalid. It
seems better to print empty string than nothing. This is workaround
for broken utils, better is to define a table name.

Addresses: https://github.com/karelzak/util-linux/issues/1339
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-07 10:32:20 +02:00
Karel Zak 1a30b2bd5e build-sys: make re-use of generated man-pages more robust
We need to ignore man-pages at all if not available (not generated
yet), but asciidoctor is not installed.

Fix: https://github.com/karelzak/util-linux/issues/1334
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-04 11:46:55 +02:00
Karel Zak 780f0f8183 Merge branch 'nortas' of https://github.com/gyakovlev/util-linux
* 'nortas' of https://github.com/gyakovlev/util-linux:
  lscpu: fix build on powerpc
2021-06-03 12:25:35 +02:00
Karel Zak daf9f2e997 build-sys: add generated man-pages to distribution tarball
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-03 12:17:27 +02:00
Georgy Yakovlev 45cd3aa4de
lscpu: fix build on powerpc
fails with error: label at end of compound statement
and fix typo as bonus.

Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
2021-06-02 13:59:26 -07:00
Karel Zak 308a15c71c build-sys: add missing header
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-02 15:31:39 +02:00
Karel Zak 1775aaf1d7 lsblk: use ID_MODEL_ENC is possible
Fix: https://github.com/karelzak/util-linux/issues/1098
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-02 13:32:43 +02:00
Karel Zak 0e54ac3980 lscpu: remove extra blank lines
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-02 13:09:28 +02:00
Karel Zak 79884c5dd1 Merge branch 'lscpu-json-types' of https://github.com/t-8ch/util-linux
* 'lscpu-json-types' of https://github.com/t-8ch/util-linux:
  lscpu: use optional json values
  libsmartcols: add support for optional boolean values
  lscpu: use json types
2021-06-02 13:06:10 +02:00
Karel Zak ac55a4130f Merge branch 'next'
* next: (26 commits)
  build-sys: add script to compare config.h from meson and autotools
  meson: add missing header files check
  docs: update TODO
  tests: update lscpu outputs
  lscpu: read MHZ from /sys/.../cpufreq/scaling_cur_freq
  lscpu: use locale-independent strtod() when read from kernel
  lib/c_strtod; add locale independent strtod()
  tests: update lscpu output
  lscpu: use MHZ as number to be locale sensitive
  lscpu: add SCALMHZ% and "CPU scaling MHz:"
  sulogin: fix whitespace error
  sulogin: ignore none-existing console devices
  lsns: fix old error message
  lsns: fix copy & past in man page
  lsns: fill UID and USER columns for interpolated namespaces
  fixup! lsns: interpolate missing namespaces for converting forests to a tree
  lsns: interpolate missing namespaces for converting forests to a tree
  lsns: reorganize members specifying other namespaces in lsns_namespace
  lsns: make namespace having no process printable
  libblkid: support zone reset for wipefs
  ...
2021-06-02 12:33:07 +02:00
Karel Zak 902d216412 mount: use mnt_fs_is_regularfs()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-02 12:19:06 +02:00