Commit Graph

14674 Commits

Author SHA1 Message Date
leeceeksdee 40d249fca0
his -> their 2020-08-28 19:15:34 +02:00
leeceeksdee d15a6c22cf
he -> they 2020-08-28 19:12:44 +02:00
leeceeksdee c2fcf2f797
he -> they 2020-08-28 19:11:45 +02:00
leeceeksdee 3ba9018b85
he -> they 2020-08-28 19:11:02 +02:00
Michael Kerrisk (man-pages) 76054e1527 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>
2020-08-28 09:15:25 +02:00
Soumendra Ganguly 75ccd75a2f 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>
2020-08-27 12:56:46 +02:00
Karel Zak d3f21dca1e bash-completion: add column --table-columns-limit
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-25 14:23:28 +02:00
Karel Zak ea160a2bef 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>
2020-08-25 14:15:36 +02:00
Karel Zak 816c5754f2 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
2020-08-25 11:29:16 +02:00
Karel Zak f1f48270c9 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>
2020-08-25 10:48:29 +02:00
Karel Zak e113093ce9 lib/env: add function to save and restore unwanted variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-25 10:43:07 +02:00
Adriaan de Groot bc743b355c
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.
2020-08-24 23:30:35 +02:00
nl6720 80a54e2b3e
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>
2020-08-22 15:40:06 +03:00
Karel Zak 72f783d0ea libmount: fix tab parser for badly terminated lines
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-17 16:33:59 +02:00
Evgeny Vereshchagin d7720587f5 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
```
2020-08-13 05:21:26 +00:00
Karel Zak 93bf606312 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
2020-08-14 11:18:59 +02:00
Karel Zak 91a3e37489 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
2020-08-14 11:16:12 +02:00
Karel Zak 1f50296c0f libfdisk: (script) fix possible partno overflow
Addresses: https://oss-fuzz.com/testcase-detail/5740890480705536
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-14 11:13:50 +02:00
Soumendra Ganguly 5679c7bbdb
Update pty-session.c 2020-08-13 12:58:22 -05:00
Karel Zak 678d03cc8a libfdisk: (script) fix possible memory leaks
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-13 13:48:28 +02:00
Soumendra Ganguly c556dc5943
More minor typos 2020-08-13 06:01:57 -05:00
Karel Zak d8f35960ae libfdisk: another parse_line_nameval() cleanup 2020-08-13 10:13:01 +02:00
Karel Zak 9f03ad60e5 libfdisk: make fdisk_partname() more robust 2020-08-13 10:12:01 +02:00
Soumendra Ganguly 86139a7041
Fix minor typo
terminall -> terminal
2020-08-13 02:44:28 -05:00
Karel Zak 3b87a9af49 libfdisk: fix typo from 255f5f4c77
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-12 19:48:47 +02:00
Karel Zak 4bdb681571 libfdisk: (script) make sure buffer is initialized
Just to make static analyzers happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-12 19:39:34 +02:00
Karel Zak 8bbc11f12f 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>
2020-08-12 15:59:38 +02:00
Karel Zak 255f5f4c77 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>
2020-08-12 15:52:53 +02:00
Evgeny Vereshchagin 519ad7a136 tests: add testcases that triggered various crashes
to make it easier to catch regressions going forward.

It's a follow-up to 678d03cc8a, 9f03ad60e5
and 4bdb681571

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-12 00:21:45 +00:00
Evgeny Vereshchagin 6c13bfcfed 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'
```
2020-08-11 00:21:27 +00:00
Evgeny Vereshchagin b62ec52e8f 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
2020-08-10 23:30:50 +00:00
Karel Zak 943f4dbdfe Merge branch 'scriptreplay_noebadf' of https://github.com/8vasu/util-linux 2020-08-11 11:58:30 +02:00
Karel Zak 69e4fbfbfd hwclock: add fallback if SYS_settimeofday does not exist
It seems Musl-C removes SYS_settimeofday macro at all.

Addresses: 9c6139a720 (commitcomment-41290951)
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-11 11:02:31 +02:00
Karel Zak c87cce57d8 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
2020-08-10 14:40:44 +02:00
Karel Zak dc4816142c tests: add sfdisk test for 4fe7f9b614
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-10 12:00:17 +02:00
Karel Zak 4fe7f9b614 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>
2020-08-10 11:37:32 +02:00
Soumendra Ganguly 535e81ebba Change tcgetattr error handling. 2020-08-08 05:28:42 -05:00
Karel Zak fbc9b69151 Merge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux 2020-08-07 15:08:03 +02:00
Karel Zak 4418b5aa49 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
2020-08-07 15:02:56 +02:00
Karel Zak 8451390bd9 docs: fix typo in v2.36-ReleaseNotes
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-07 13:49:19 +02:00
Soumendra Ganguly cfc264d50b Add more elegant error handling. Avoid isatty. 2020-08-07 03:01:02 -05:00
Evgeny Vereshchagin 67884c75e2 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>
2020-08-06 16:15:31 +00:00
Evgeny Vereshchagin 2bb8c73696 cifuzz: turn on MSan
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 15:36:45 +00:00
Evgeny Vereshchagin 0be452a82a build-system: stop looking for %ms and %as
Looks like those specifiers haven't been used since 6c9ab254ae
(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>
2020-08-06 14:27:20 +00:00
Evgeny Vereshchagin 6e277b7a97 tests: pack testcases into zip archives
so that OSS-Fuzz can use them as seed corpora

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 877356164a 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>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 2cdbf06f5e tests: add a fuzzer for process_wtmp_file
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 0f311c7ae7 docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 02f5fc1407 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>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 681d3a9586 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>
2020-08-06 12:33:11 +00:00