]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
3 years agocol: move option handling to separate function
Sami Kerola [Sat, 27 Jun 2020 18:32:25 +0000 (19:32 +0100)] 
col: move option handling to separate function

Mark --tabs and --spaces mutually exclusive in same go.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agocol: move global variables to a control structure
Sami Kerola [Sat, 27 Jun 2020 18:23:29 +0000 (19:23 +0100)] 
col: move global variables to a control structure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agocol: use inline function rather than function like define
Sami Kerola [Sat, 27 Jun 2020 18:03:33 +0000 (19:03 +0100)] 
col: use inline function rather than function like define

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agocol: use typedef and enum to clarify struct
Sami Kerola [Sat, 27 Jun 2020 17:57:48 +0000 (18:57 +0100)] 
col: use typedef and enum to clarify struct

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agocol: remove function prototypes
Sami Kerola [Sat, 27 Jun 2020 17:40:44 +0000 (18:40 +0100)] 
col: remove function prototypes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agocol: add more tests
Sami Kerola [Fri, 26 Jun 2020 21:24:25 +0000 (22:24 +0100)] 
col: add more tests

With these tests coverage is about 89%.

The ts_run is added to ensure ASAN_OPTIONS and UBSAN_OPTIONS are set
correctly when the tests run.

Reference: https://github.com/karelzak/util-linux/pull/1115#issuecomment-670140224
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agoblkzone: add report capacity command
Hans Holmberg [Fri, 11 Sep 2020 08:47:23 +0000 (10:47 +0200)] 
blkzone: add report capacity command

Add a command that answers the the question:
"How much data can I store on this device/in this range of zones?"

Implement this by summing up zone capacities over the given range.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
3 years agologin: add option to not reset username on each attempt
Thayne McCombs [Fri, 4 Sep 2020 08:33:54 +0000 (02:33 -0600)] 
login: add option to not reset username on each attempt

[kzak@redhat.com: - use different message on failed password]

Addresses: https://github.com/karelzak/util-linux/pull/1138
Addresses: https://github.com/karelzak/util-linux/issues/6
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomkswap: add --verbose, reduce extents check output
Karel Zak [Thu, 10 Sep 2020 10:54:14 +0000 (12:54 +0200)] 
mkswap: add --verbose, reduce extents check output

We do not need to provide details in the default output. It seems
better to hide it behind --verbose to be user-friendly.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomkswap: cleanup usage()
Karel Zak [Thu, 10 Sep 2020 09:26:18 +0000 (11:26 +0200)] 
mkswap: cleanup usage()

- don't use one string for all --help output
- use USAGE_* macros

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomkswap: remove unnecessary on FS_IOC_FIEMAP
Karel Zak [Wed, 9 Sep 2020 13:50:39 +0000 (15:50 +0200)] 
mkswap: remove unnecessary on FS_IOC_FIEMAP

This is something user cannot fix and extents check is nothing critical.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomkswap: improve extents check
Karel Zak [Wed, 9 Sep 2020 13:37:27 +0000 (15:37 +0200)] 
mkswap: improve extents check

- remove unknown extent type (kernel does not care about it too)
- fix last_logical use in messages
- improve warning for DELALLOC extents
- check for hole at the end of the file

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolsblk: show all empty, except loopdevs
Karel Zak [Wed, 9 Sep 2020 12:50:02 +0000 (14:50 +0200)] 
lsblk: show all empty, except loopdevs

This patch improves the previous commit to accept also another empty devices.

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolsblk: ignore only loopdevs without backing file
Karel Zak [Wed, 9 Sep 2020 10:18:07 +0000 (12:18 +0200)] 
lsblk: ignore only loopdevs without backing file

* do not ignore all empty devices, we need more smart solution

* ignore only loop devices without backing file, for example:
 # touch img
 # losetup -f img
 losetup: img: Warning: file is smaller than 512 bytes; the loop device may be useless or invisible for system tools.

 - old version display nothing
 - new version:

 # lsblk /dev/loop0
 NAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
 loop0   7:0    0   0B  0 loop

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolsblk: print zero rather than empty SIZE
Karel Zak [Wed, 9 Sep 2020 10:00:10 +0000 (12:00 +0200)] 
lsblk: print zero rather than empty SIZE

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'cramfs-use-prepared-test-data' of https://github.com/masami256/util...
Karel Zak [Wed, 9 Sep 2020 09:23:48 +0000 (11:23 +0200)] 
Merge branch 'cramfs-use-prepared-test-data' of https://github.com/masami256/util-linux

3 years agoMerge branch 'nosymfollow' of https://github.com/rzwisler/util-linux
Karel Zak [Wed, 9 Sep 2020 09:13:34 +0000 (11:13 +0200)] 
Merge branch 'nosymfollow' of https://github.com/rzwisler/util-linux

* 'nosymfollow' of https://github.com/rzwisler/util-linux:
  mount: Add support for "nosymfollow" mount option.

3 years agomkswap: check for holes and unwanted extentd in file
Karel Zak [Wed, 9 Sep 2020 09:00:40 +0000 (11:00 +0200)] 
mkswap: check for holes and unwanted extentd in file

Let's make mkswap(8) more user-friend and report possible swapon
issues already when user initialize a swap file. The extents check
produces warnings, no exit with error.

  # dd if=/dev/zero of=img count=100 bs=1MiB
  # chmod 0600 img

  # fallocate --dig-hole --offset 64520192 --length 1MiB img
  # fallocate --dig-hole --offset 84520960 --length 1MiB img

  # ./mkswap img
  mkswap: extents check failed:
    - hole detected at offset 64520192 (size 1048576 bytes)
    - hole detected at offset 84520960 (size 1048576 bytes)
  file img can be rejected by kernel on swap activation.

  Setting up swapspace version 1, size = 100 MiB (104853504 bytes)
  no label, UUID=92091112-26b5-47aa-a02a-592e52528319

It checks for holes in the file, and for unknown, inline, shared and
deallocated extents.

Addresses: https://github.com/karelzak/util-linux/issues/1120
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: mkfs-endianness test uses prepared test data
Masami Ichikawa [Tue, 8 Sep 2020 05:19:32 +0000 (14:19 +0900)] 
tests: mkfs-endianness test uses prepared test data

Commit 7b54f05d6b7124c23bff3bc1b8310231c8a2e131 added iflag=fullblock
option, it works fine with coreutils's dd but macOS's dd doesn't support
iflag option then test failed on macOS[1].

This commit added prepared test data for test to not use dd command to
avoid dd command difference.

tested on raspberry pi3
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
0

tested on macOS
$ sudo sh -c 'for i in $(seq 1 500); do ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
       0

[1]https://travis-ci.org/github/karelzak/util-linux/jobs/723642222#L3907

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
3 years agolibfdisk: reset context FD on error
yangzz-97 [Sun, 6 Sep 2020 10:30:48 +0000 (18:30 +0800)] 
libfdisk: reset context FD on error

When the query disk fails, reset cxt->dev_fd.

Addresses: https://github.com/karelzak/util-linux/pull/1137
Addresses: https://github.com/karelzak/util-linux/issues/1131
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibsmartcols: don't print empty output on empty table in JSON
Karel Zak [Mon, 7 Sep 2020 09:52:13 +0000 (11:52 +0200)] 
libsmartcols: don't print empty output on empty table in JSON

old version:
 $ findmnt --json --type foo
 $

new version:
 $ findmnt --json --type foo
 {
    "filesystems": [
    ]
 }

Addresses: https://github.com/karelzak/util-linux/issues/1136
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomount: Add support for "nosymfollow" mount option.
Mattias Nissler [Thu, 17 Nov 2016 13:47:51 +0000 (14:47 +0100)] 
mount: Add support for "nosymfollow" mount option.

This adds support for the "nosymfollow" mount option, which indicates
that symlinks should not be traversed on the mount this option is
applied to.  Also update the mount(8) man page with information about
this option.

Signed-off-by: Mattias Nissler <mnissler@chromium.org>
Signed-off-by: Ross Zwisler <zwisler@google.com>
3 years agoMerge branch 'cramfs-test-fix' of https://github.com/masami256/util-linux
Karel Zak [Thu, 3 Sep 2020 08:57:13 +0000 (10:57 +0200)] 
Merge branch 'cramfs-test-fix' of https://github.com/masami256/util-linux

* 'cramfs-test-fix' of https://github.com/masami256/util-linux:
  tests: mkfs-endianness test use iflag=fullblock to fill block completely with string

3 years agotests: mkfs-endianness test use iflag=fullblock to fill block completely with string
Masami Ichikawa [Thu, 3 Sep 2020 01:04:36 +0000 (10:04 +0900)] 
tests: mkfs-endianness test use iflag=fullblock to fill block completely with string

When run mkfs-endianness test on lowend machine, sometimes dd didn't
fill block with string then test failed.
So, it's nice to add iflag=fullblock option to fill a block with
string read from stdin.

Tested on Raspberry Pi 3 B+(using 1core to simulate lowend environment)
 with iflag=fullblock option didn't get test failure.

Without iflag=fullblock option.
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
49

With iflag=fullblock option.
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
0

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
3 years agolibmount: do not use pointer as an integer value
Sami Kerola [Fri, 28 Aug 2020 19:59:57 +0000 (20:59 +0100)] 
libmount: do not use pointer as an integer value

Fix couple "initialization of ‘long int’ from ‘void *’ makes integer from
pointer without a cast" warnings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
3 years agolsblk: fix -T optional argument
Karel Zak [Wed, 2 Sep 2020 09:10:18 +0000 (11:10 +0200)] 
lsblk: fix -T optional argument

Addresses: https://github.com/karelzak/util-linux/issues/1132
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agopg: fix wcstombs() use
Karel Zak [Tue, 1 Sep 2020 09:50:11 +0000 (11:50 +0200)] 
pg: fix wcstombs() use

The size (3rd) argument should be ignored if the 1st *dest is NULL, but it seems gcc & glibc headers
are more pedantic now:

ext-utils/pg.c:456:13: error: argument 1 is null but the corresponding size argument 3 value is 2048 [-Werror=nonnull]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: remove read-mountinfo workaround
Karel Zak [Tue, 1 Sep 2020 08:15:14 +0000 (10:15 +0200)] 
libmount: remove read-mountinfo workaround

This workaround has been introduced by
http://github.com/karelzak/util-linux/commit/e4925f591c1bfb83719418b56b952830d15b77eb

And originally requested by https://github.com/systemd/systemd/issues/10872

It seems we do not need it anymore as the problem should be fixed in kernel since 5.8
(kernel commit 9f6c61f96f2d97cbb5f7fa85607bc398f843ff0f).

Note that the libmount solution is very expensive as it repeats read()
many times (until we get consistent result) if kernel is busy with
mount table modification. This behaviour makes events management in
systemd (or other places) pretty difficult as read mountinfo takes
time on busy systems.

Addresses: https://github.com/systemd/systemd/pull/16537
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'master' of https://github.com/itsthem/util-linux
Karel Zak [Tue, 1 Sep 2020 07:45:32 +0000 (09:45 +0200)] 
Merge branch 'master' of https://github.com/itsthem/util-linux

* 'master' of https://github.com/itsthem/util-linux:
  her -> their
  her -> their
  him -> them
  him -> them
  his -> their
  he -> they
  he -> they
  he -> they

3 years agohwclock: fix SYS_settimeofday fallback
Rosen Penev [Sun, 30 Aug 2020 04:55:58 +0000 (21:55 -0700)] 
hwclock: fix SYS_settimeofday fallback

turns out this is subtly broken. musl 1.2.x for 64-bit architectures defines __NR_settimeofday but not
for 32-bit ones. For 32-bit, it defines a _time32 variant.

3 years agoher -> their
leeceeksdee [Fri, 28 Aug 2020 17:19:23 +0000 (19:19 +0200)] 
her -> their

3 years agoher -> their
leeceeksdee [Fri, 28 Aug 2020 17:18:33 +0000 (19:18 +0200)] 
her -> their

3 years agohim -> them
leeceeksdee [Fri, 28 Aug 2020 17:17:00 +0000 (19:17 +0200)] 
him -> them

3 years agohim -> them
leeceeksdee [Fri, 28 Aug 2020 17:16:33 +0000 (19:16 +0200)] 
him -> them

3 years agohis -> their
leeceeksdee [Fri, 28 Aug 2020 17:15:34 +0000 (19:15 +0200)] 
his -> their

3 years agohe -> they
leeceeksdee [Fri, 28 Aug 2020 17:12:44 +0000 (19:12 +0200)] 
he -> they

3 years agohe -> they
leeceeksdee [Fri, 28 Aug 2020 17:11:45 +0000 (19:11 +0200)] 
he -> they

3 years agohe -> they
leeceeksdee [Fri, 28 Aug 2020 17:11:02 +0000 (19:11 +0200)] 
he -> they

3 years agoManual pages: blockdev.8, sfdisk.8: typo fixes
Michael Kerrisk (man-pages) [Thu, 27 Aug 2020 15:12:45 +0000 (17:12 +0200)] 
Manual pages: blockdev.8, sfdisk.8: typo fixes

Fix a couple of typos that I introduced.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
3 years agoscript: cleanup --echo
Soumendra Ganguly [Thu, 27 Aug 2020 09:50:25 +0000 (11:50 +0200)] 
script: cleanup --echo

Permanently turn off current stdin ECHO when it is a terminal and enable setting slave ECHO instead.
Fix other minor typos, update documentation.

[kzak@redhat.com: - remove irrelevant changes
                  - keep --echo argument unchanged]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agobash-completion: add column --table-columns-limit
Karel Zak [Tue, 25 Aug 2020 12:23:28 +0000 (14:23 +0200)] 
bash-completion: add column --table-columns-limit

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agocolumn: add --table-columns-limit
Karel Zak [Tue, 25 Aug 2020 12:15:36 +0000 (14:15 +0200)] 
column: add --table-columns-limit

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':'
AAA  BBB  CCC  DDD

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':' -l 2
AAA  BBB:CCC:DDD

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':' -l 3
AAA  BBB  CCC:DDD

Addresses: https://github.com/karelzak/util-linux/issues/1124
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux
Karel Zak [Tue, 25 Aug 2020 09:29:16 +0000 (11:29 +0200)] 
Merge branch 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux

* 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux:
  Generate valid JSON if partition table is empty

3 years agomount, umount: restore environ[] after suid drop
Karel Zak [Tue, 25 Aug 2020 08:48:29 +0000 (10:48 +0200)] 
mount, umount: restore environ[] after suid drop

The commands mount and umount sanitize environment variables as it
works with suid permissions by default. Since v2.36 it's possible
that the commands drop the permissions and continue as regular user.
It seems we also need to restore the original environ to keep things
consistent for users (e.g. HOME=).

The implementation is pretty simple -- it keeps in memory removed
variables and use it after switch to non-suid mode.

Addresses: https://github.com/karelzak/util-linux/issues/880
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/env: add function to save and restore unwanted variables
Karel Zak [Tue, 25 Aug 2020 08:43:07 +0000 (10:43 +0200)] 
lib/env: add function to save and restore unwanted variables

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoGenerate valid JSON if partition table is empty
Adriaan de Groot [Mon, 24 Aug 2020 21:30:35 +0000 (23:30 +0200)] 
Generate valid JSON if partition table is empty

When the partition table is present **but** empty, the existing code would output fields followed by a `,` , on the assumption that the list of partitions would follow. But if the list of partitions is empty, it is skipped, leading to output like this:

```
{
  "partitiontable": {
      "label":"gpt",
      "id":"1F9E80D9-DD78-024F-94A3-B61EC82B18C8",
      "device":"/dev/sdb",
      "unit":"sectors",
      "firstlba":2048,
      "lastlba":30949342,
      "sectorsize":512,
  }
}
```

Note the `512,` on the *sectorsize* line.

This is invalid JSON for some parsers, which choke on it.

Avoid this, by checking when outputting the last separator: if there's no table, or there is a table but it is empty, then just put a newline, otherwise use the old path of comma-newline and assume there's going to be a list of partitions after.

3 years agolibfdisk: add systemd-homed user's home GPT partition type
nl6720 [Sat, 22 Aug 2020 12:16:27 +0000 (15:16 +0300)] 
libfdisk: add systemd-homed user's home GPT partition type

See https://systemd.io/HOME_DIRECTORY/ .
Additionally update the URL of the Boot Loader Specification.

Signed-off-by: nl6720 <nl6720@gmail.com>
3 years agolibmount: fix tab parser for badly terminated lines
Karel Zak [Mon, 17 Aug 2020 14:33:59 +0000 (16:33 +0200)] 
libmount: fix tab parser for badly terminated lines

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: cover the code parsing comments
Evgeny Vereshchagin [Thu, 13 Aug 2020 05:20:14 +0000 (05:20 +0000)] 
tests: cover the code parsing comments

It seems to be failing with
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==13==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000055f428 bp 0x7ffc3743a170 sp 0x7ffc3743a080 T0)
==13==The signal is caused by a WRITE memory access.
==13==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x55f428 in mnt_table_parse_next /src/util-linux/libmount/src/tab_parse.c:587:6
    #1 0x55c200 in __table_parse_stream /src/util-linux/libmount/src/tab_parse.c:737:8
    #2 0x55be38 in mnt_table_parse_stream /src/util-linux/libmount/src/tab_parse.c:809:8
    #3 0x5511ff in LLVMFuzzerTestOneInput /src/util-linux/libmount/src/fuzz.c:21:16
    #4 0x458a31 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:558:15
    #5 0x458175 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
    #6 0x45a117 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:770:7
    #7 0x45a319 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:799:3
    #8 0x44a055 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:846:6
    #9 0x471bf2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
    #10 0x7fe3bd93b83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #11 0x41f208 in _start (/out/test_mount_fuzz+0x41f208)

DEDUP_TOKEN: mnt_table_parse_next--__table_parse_stream--mnt_table_parse_stream
```

3 years agoMerge branch 'patch-1' of https://github.com/8vasu/util-linux
Karel Zak [Fri, 14 Aug 2020 09:18:59 +0000 (11:18 +0200)] 
Merge branch 'patch-1' of https://github.com/8vasu/util-linux

* 'patch-1' of https://github.com/8vasu/util-linux:
  Update pty-session.c
  More minor typos
  Fix minor typo

3 years agoMerge branch 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux
Karel Zak [Fri, 14 Aug 2020 09:16:12 +0000 (11:16 +0200)] 
Merge branch 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux

* 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux:
  tests: add testcases that triggered various crashes

3 years agolibfdisk: (script) fix possible partno overflow
Karel Zak [Fri, 14 Aug 2020 09:13:50 +0000 (11:13 +0200)] 
libfdisk: (script) fix possible partno overflow

Addresses: https://oss-fuzz.com/testcase-detail/5740890480705536
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoUpdate pty-session.c
Soumendra Ganguly [Thu, 13 Aug 2020 17:58:22 +0000 (12:58 -0500)] 
Update pty-session.c

3 years agolibfdisk: (script) fix possible memory leaks
Karel Zak [Thu, 13 Aug 2020 11:48:28 +0000 (13:48 +0200)] 
libfdisk: (script) fix possible memory leaks

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMore minor typos
Soumendra Ganguly [Thu, 13 Aug 2020 11:01:57 +0000 (06:01 -0500)] 
More minor typos

3 years agolibfdisk: another parse_line_nameval() cleanup
Karel Zak [Thu, 13 Aug 2020 08:13:01 +0000 (10:13 +0200)] 
libfdisk: another parse_line_nameval() cleanup

3 years agolibfdisk: make fdisk_partname() more robust
Karel Zak [Thu, 13 Aug 2020 08:12:01 +0000 (10:12 +0200)] 
libfdisk: make fdisk_partname() more robust

3 years agoFix minor typo
Soumendra Ganguly [Thu, 13 Aug 2020 07:44:28 +0000 (02:44 -0500)] 
Fix minor typo

terminall -> terminal

3 years agolibfdisk: fix typo from 255f5f4c770ebd46a38b58975bd33e33ae87ed24
Karel Zak [Wed, 12 Aug 2020 17:48:47 +0000 (19:48 +0200)] 
libfdisk: fix typo from 255f5f4c770ebd46a38b58975bd33e33ae87ed24

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: (script) make sure buffer is initialized
Karel Zak [Wed, 12 Aug 2020 17:36:51 +0000 (19:36 +0200)] 
libfdisk: (script) make sure buffer is initialized

Just to make static analyzers happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: (script) don't use sector size if not specified
Karel Zak [Wed, 12 Aug 2020 13:59:38 +0000 (15:59 +0200)] 
libfdisk: (script) don't use sector size if not specified

This is probably bad script API use, but better be safe than sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: (script) make sure label is specified
Karel Zak [Wed, 12 Aug 2020 13:52:53 +0000 (15:52 +0200)] 
libfdisk: (script) make sure label is specified

and unref type if already specified (unlikely, but be paranoid)

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: add testcases that triggered various crashes
Evgeny Vereshchagin [Tue, 11 Aug 2020 23:58:15 +0000 (23:58 +0000)] 
tests: add testcases that triggered various crashes

to make it easier to catch regressions going forward.

It's a follow-up to 678d03cc8a9c665ba989b099f03ad60e58f7bdcac6a
and 4bdb681571d5f510ab2abff86

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotravis: stop building fuzz targets on macOS
Evgeny Vereshchagin [Mon, 10 Aug 2020 23:33:51 +0000 (23:33 +0000)] 
travis: stop building fuzz targets on macOS

Looks like `-fsanitize=fuzzer` isn't supported there:

https://travis-ci.org/github/karelzak/util-linux/jobs/716894984
```
clang: error: unsupported option '-fsanitize=fuzzer' for target 'x86_64-apple-darwin17.7.0'
```

3 years agotests: add a fuzz target calling fdisk_script_read_file
Evgeny Vereshchagin [Mon, 10 Aug 2020 22:24:41 +0000 (22:24 +0000)] 
tests: add a fuzz target calling fdisk_script_read_file

It has already found a couple of issues mentioned in
https://github.com/karelzak/util-linux/issues/1023#issuecomment-671910621

3 years agoMerge branch 'scriptreplay_noebadf' of https://github.com/8vasu/util-linux
Karel Zak [Tue, 11 Aug 2020 09:58:30 +0000 (11:58 +0200)] 
Merge branch 'scriptreplay_noebadf' of https://github.com/8vasu/util-linux

3 years agohwclock: add fallback if SYS_settimeofday does not exist
Karel Zak [Tue, 11 Aug 2020 09:02:31 +0000 (11:02 +0200)] 
hwclock: add fallback if SYS_settimeofday does not exist

It seems Musl-C removes SYS_settimeofday macro at all.

Addresses: https://github.com/karelzak/util-linux/commit/9c6139a72017cecb9145e46102152cb4f456ada6#commitcomment-41290951
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'fuzz' of https://github.com/evverx/util-linux
Karel Zak [Mon, 10 Aug 2020 12:40:44 +0000 (14:40 +0200)] 
Merge branch 'fuzz' of https://github.com/evverx/util-linux

* 'fuzz' of https://github.com/evverx/util-linux:
  tests: pack testcases into zip archives
  tests: integrate test_last_fuzz into the testsuite
  tests: add a fuzzer for process_wtmp_file
  docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
  tools: make it possible to set all the fuzzing flags with config-gen
  build-system: make "make distcheck" work
  travis: set CXX correctly
  travis: turn on --enable-fuzzing-engine
  build-sys: add support for --enable-fuzzing-engine
  tests: integrate test_mount_fuzz into the testsuite
  tests: take exit codes into account
  tests: add a fuzzer for mnt_table_parse_stream

3 years agotests: add sfdisk test for 4fe7f9b614e2b5bb97f6d89af02acb867cffccc1
Karel Zak [Mon, 10 Aug 2020 10:00:17 +0000 (12:00 +0200)] 
tests: add sfdisk test for 4fe7f9b614e2b5bb97f6d89af02acb867cffccc1

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: fix last free sector detection if partition size specified
Karel Zak [Mon, 10 Aug 2020 09:37:32 +0000 (11:37 +0200)] 
libfdisk: fix last free sector detection if partition size specified

We need to skip useless gaps between partition if the gap is no large
enough for a new partition. Unfortunately, the current code checks
size of the gap, but does not care for location of the gap -- this is
good enough for dialog driven partitioning, but it's pretty bad if
start of the partition is explicitly specified (e.g. sfdisk).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1860461
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoChange tcgetattr error handling.
Soumendra Ganguly [Sat, 8 Aug 2020 10:28:42 +0000 (05:28 -0500)] 
Change tcgetattr error handling.

3 years agoMerge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux
Karel Zak [Fri, 7 Aug 2020 13:08:03 +0000 (15:08 +0200)] 
Merge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux

3 years agoMerge branch 'sscanf-specifiers' of https://github.com/evverx/util-linux
Karel Zak [Fri, 7 Aug 2020 13:02:56 +0000 (15:02 +0200)] 
Merge branch 'sscanf-specifiers' of https://github.com/evverx/util-linux

* 'sscanf-specifiers' of https://github.com/evverx/util-linux:
  travis: turn off libmount on OSX
  cifuzz: turn on MSan
  build-system: stop looking for %ms and %as

3 years agodocs: fix typo in v2.36-ReleaseNotes
Karel Zak [Fri, 7 Aug 2020 11:49:19 +0000 (13:49 +0200)] 
docs: fix typo in v2.36-ReleaseNotes

Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoAdd more elegant error handling. Avoid isatty.
Soumendra Ganguly [Fri, 7 Aug 2020 08:01:02 +0000 (03:01 -0500)] 
Add more elegant error handling. Avoid isatty.

3 years agotravis: turn off libmount on OSX
Evgeny Vereshchagin [Thu, 6 Aug 2020 16:10:28 +0000 (16:10 +0000)] 
travis: turn off libmount on OSX

Now that the absence of the sscanf modifiers no longer prevents Travis from building libmount
automatically it seems util-linux is failing to compile there with
```
In file included from disk-utils/fsck.c:49:

[1m./libmount/src/libmount.h:32:10: [0m[0;1;31mfatal error: [0m[1m'mntent.h' file not found[0m

[0;1;32m         ^~~~~~~~~~

[0m1 error generated.

make[2]: *** [disk-utils/fsck-fsck.o] Error 1

make[2]: *** Waiting for unfinished jobs....

make[1]: *** [all-recursive] Error 1

make: *** [all] Error 2
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agocifuzz: turn on MSan
Evgeny Vereshchagin [Thu, 6 Aug 2020 14:10:22 +0000 (14:10 +0000)] 
cifuzz: turn on MSan

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agobuild-system: stop looking for %ms and %as
Evgeny Vereshchagin [Thu, 6 Aug 2020 13:59:35 +0000 (13:59 +0000)] 
build-system: stop looking for %ms and %as

Looks like those specifiers haven't been used since 6c9ab254aefb6ce7e0e
(where sscanf was removed) was merged. This should help to get
util-linux to compile with MSan. Currently it's failing with
```
...
configure: error: libmount selected, but required scanf string alloc modifier not available
...
configure:20240: ./conftest
==116617==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x496fd6 in main /home/vagrant/util-linux/conftest.c:171:6
    #1 0x7f5eb85ea1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #2 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/vagrant/util-linux/conftest.c:171:6 in main
Exiting
configure:20240: $? = 77
...
configure:20265: $? = 0
configure:20265: ./conftest
MemorySanitizer: bad pointer 0x000000496e60
==116627==MemorySanitizer CHECK failed: /builddir/build/BUILD/compiler-rt-9.0.1.src/lib/msan/../sanitizer_common/sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast<uptr>(p), page_size_))) != (0)" (0x0, 0x0)
    #0 0x41d1d8 in MsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x41d1d8)
    #1 0x484e1e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x484e1e)
    #2 0x42066c in __msan::MsanDeallocate(__sanitizer::StackTrace*, void*) (/home/vagrant/util-linux/conftest+0x42066c)
    #3 0x424bc9 in free (/home/vagrant/util-linux/conftest+0x424bc9)
    #4 0x496fae in main /home/vagrant/util-linux/conftest.c:173:2
    #5 0x7f2245f311a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #6 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)

configure:20265: $? = 77
configure: program exited with status 77
...
| }
configure:22568: result: no
configure:22926: error: libmount selected, but required scanf string alloc modifier not available
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotests: pack testcases into zip archives
Evgeny Vereshchagin [Wed, 29 Jul 2020 07:22:41 +0000 (07:22 +0000)] 
tests: pack testcases into zip archives

so that OSS-Fuzz can use them as seed corpora

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotests: integrate test_last_fuzz into the testsuite
Evgeny Vereshchagin [Wed, 29 Jul 2020 06:31:11 +0000 (06:31 +0000)] 
tests: integrate test_last_fuzz into the testsuite

by adding tests/ts/* and a testcase triggering https://github.com/karelzak/util-linux/pull/1097

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotests: add a fuzzer for process_wtmp_file
Evgeny Vereshchagin [Wed, 8 Jul 2020 22:13:40 +0000 (22:13 +0000)] 
tests: add a fuzzer for process_wtmp_file

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agodocs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
Evgeny Vereshchagin [Tue, 28 Jul 2020 11:47:08 +0000 (11:47 +0000)] 
docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotools: make it possible to set all the fuzzing flags with config-gen
Evgeny Vereshchagin [Tue, 28 Jul 2020 11:23:50 +0000 (11:23 +0000)] 
tools: make it possible to set all the fuzzing flags with config-gen

so that the fuzz targets (along with everything else) can be built
and run with:
```
./tools/config-gen fuzz
make check
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agobuild-system: make "make distcheck" work
Evgeny Vereshchagin [Tue, 28 Jul 2020 10:31:58 +0000 (10:31 +0000)] 
build-system: make "make distcheck" work

It failed with:
```
make[5]: Entering directory '/home/travis/build/karelzak/util-linux/util-linux-2.36.32-0fea/_build/sub/po'
make[5]: *** No rule to make target '../../../include/fuzz.h', needed by 'util-linux.pot-update'.  Stop.
make[5]: Leaving directory '/home/travis/build/karelzak/util-linux/util-linux-2.36.32-0fea/_build/sub/po'
Makefile:896: recipe for target 'update-po' failed
make[4]: *** [update-po] Error 2
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotravis: set CXX correctly
Evgeny Vereshchagin [Tue, 28 Jul 2020 05:26:53 +0000 (05:26 +0000)] 
travis: set CXX correctly

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotravis: turn on --enable-fuzzing-engine
Evgeny Vereshchagin [Tue, 28 Jul 2020 04:19:10 +0000 (04:19 +0000)] 
travis: turn on --enable-fuzzing-engine

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agobuild-sys: add support for --enable-fuzzing-engine
Evgeny Vereshchagin [Tue, 28 Jul 2020 04:17:40 +0000 (04:17 +0000)] 
build-sys: add support for --enable-fuzzing-engine

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotests: integrate test_mount_fuzz into the testsuite
Evgeny Vereshchagin [Tue, 28 Jul 2020 00:56:04 +0000 (00:56 +0000)] 
tests: integrate test_mount_fuzz into the testsuite

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotests: take exit codes into account
Evgeny Vereshchagin [Sun, 28 Jun 2020 02:15:23 +0000 (04:15 +0200)] 
tests: take exit codes into account

In its current form the testsuite isn't suitable for running
fuzz targets because it ignores exit codes and relies solely
on diffs (that unfortunately aren't helpful because the nondeterministic
nature of fuzz targets makes it kind of hard to specify expected output
in advance). This patch is supposed to address the "exit code" issue for now.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agotests: add a fuzzer for mnt_table_parse_stream
Evgeny Vereshchagin [Sat, 11 Apr 2020 13:25:26 +0000 (13:25 +0000)] 
tests: add a fuzzer for mnt_table_parse_stream

The fuzzer is supposed to cover `mnt_table_parse_stream`, which is
used by systemd to parse /proc/self/mountinfo. The systemd project
has run into memory leaks there at least twice:

https://github.com/systemd/systemd/pull/12252#issuecomment-482804040
https://github.com/systemd/systemd/issues/8504

so it seems to be a good idea to continuously fuzz that particular
function.

The patch can be tested locally by installing clang and running
./tools/oss-fuzz.sh. Currently the fuzzer is failing with
```
=================================================================
==96638==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 216 byte(s) in 1 object(s) allocated from:
    #0 0x50cd77 in calloc (/home/vagrant/util-linux/out/test_mount_fuzz+0x50cd77)
    #1 0x58716a in mnt_new_fs /home/vagrant/util-linux/libmount/src/fs.c:36:25
    #2 0x54f224 in __table_parse_stream /home/vagrant/util-linux/libmount/src/tab_parse.c:728:9
    #3 0x54eed8 in mnt_table_parse_stream /home/vagrant/util-linux/libmount/src/tab_parse.c:804:8
    #4 0x5448b2 in LLVMFuzzerTestOneInput /home/vagrant/util-linux/libmount/src/fuzz.c:19:16
    #5 0x44cc88 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/util-linux/out/test_mount_fuzz+0x44cc88)
    #6 0x44d8b0 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) (/home/vagrant/util-linux/out/test_mount_fuzz+0x44d8b0)
    #7 0x44e270 in fuzzer::Fuzzer::MutateAndTestOne() (/home/vagrant/util-linux/out/test_mount_fuzz+0x44e270)
    #8 0x450617 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) (/home/vagrant/util-linux/out/test_mount_fuzz+0x450617)
    #9 0x43adbb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/util-linux/out/test_mount_fuzz+0x43adbb)
    #10 0x42ad46 in main (/home/vagrant/util-linux/out/test_mount_fuzz+0x42ad46)
    #11 0x7fa084f621a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: 216 byte(s) leaked in 1 allocation(s).
INFO: to ignore leaks on libFuzzer side use -detect_leaks=0.
```

Once the bug is fixed and the OSS-Fuzz counterpart is merged it should be possible
to turn on CIFuzz to make sure the fuzz target can be built and run for some time
without crashing: https://google.github.io/oss-fuzz/getting-started/continuous-integration/

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agoMerge branch 'mk-rm' of https://github.com/evverx/util-linux
Karel Zak [Thu, 6 Aug 2020 09:49:29 +0000 (11:49 +0200)] 
Merge branch 'mk-rm' of https://github.com/evverx/util-linux

* 'mk-rm' of https://github.com/evverx/util-linux:
  tests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110

3 years agolibfdisk: fix fdisk_reread_changes() for extended partitions
Karel Zak [Thu, 6 Aug 2020 09:32:33 +0000 (11:32 +0200)] 
libfdisk: fix fdisk_reread_changes() for extended partitions

Linux kernel assumes only 1KiB extended partition to avoid overlapping
with nested logical partitions. We need to follow this rule for
BLKPG_ADD_PARTITION.

Addresses: https://github.com/karelzak/util-linux/issues/1112
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110
Evgeny Vereshchagin [Tue, 28 Jul 2020 08:04:35 +0000 (08:04 +0000)] 
tests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
3 years agoManual pages: wipefs.8: Formatting fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:18 +0000 (12:06 +0200)] 
Manual pages: wipefs.8: Formatting fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
3 years agoManual pages: agetty.8: Minor formatting and wording fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:17 +0000 (12:06 +0200)] 
Manual pages: agetty.8: Minor formatting and wording fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
3 years agoManual pages: wdctl.8: typo fix
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:16 +0000 (12:06 +0200)] 
Manual pages: wdctl.8: typo fix

3 years agoManual pages: lsblk.8: Minor formatting and typo fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:15 +0000 (12:06 +0200)] 
Manual pages: lsblk.8: Minor formatting and typo fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
3 years agoManual pages: logger.1: minor formatting and typo fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:14 +0000 (12:06 +0200)] 
Manual pages: logger.1: minor formatting and typo fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
3 years agoManual pages: nologin.8: formatting fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:13 +0000 (12:06 +0200)] 
Manual pages: nologin.8: formatting fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
3 years agoManual pages: lslogins.1: Minor wording and formatting fixres
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:12 +0000 (12:06 +0200)] 
Manual pages: lslogins.1: Minor wording and formatting fixres

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>