Commit Graph

15300 Commits

Author SHA1 Message Date
Karel Zak ec194114e1 hardlink: use errx() when parse options
Don't waste time with some cleanup on --exclude and --include regex
errors.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak c12b639443 hardlink: use err() if possible
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 631e6865e3 hardlink: cleanup --minimum-size stuff
* use uintmax_t
* use strtosize_or_err()
* add info about suffixes to man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 9e7235e7e0 hardlink: move default to options initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak d2c3c5a684 hardlink: cleanup usage()
Let's make --help more util-linux compatible.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 0361f7440c hardlink: use our xalloc.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 40b119b990 hardlink: check and use sys/xattr.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 43989bad9e hardlink: use PRCE2 posix header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak cd6b8d3926 hardlink: cleanup includes and types
* use config.h like other code on package
* use c.h and remove from code stuff defined in the header file
* remove FALSE/TRUE redefinition

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 2180ecc81b hardlink: replace with code from Debian
The current version used in util-linux is based on original code from
Jakub Jelinek.

The new version is based on Debian implementation from
https://salsa.debian.org/jak/hardlink.  This new version uses nftw()
to walk on directories tree and organize internal data binary tree
(tsearch() and twalk()). This new version provides more features like
--ignore-{mode,owner,time}, --respect-xattrs, --respect-name,
--include, --keep-oldest, --minimize, --maximize, etc.

Note that the new version uses -f for --respect-name, the old version
uses -f to hardlinking across filesystems (very probably rarely unused
feature).

Addresses: https://github.com/karelzak/util-linux/issues/808
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Evgeny Vereshchagin a7c22c164b ci: trigger CiFuzz for the master branch only
CIFuzz and OSS-Fuzz are in sync with the master branch so it would
probably make sense to avoid running it for long-lived branches.

Inspired by https://github.com/karelzak/util-linux/pull/1248#issuecomment-776342252

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-02-15 13:25:19 +00:00
Karel Zak 15a37d00e5 tests: don't reply on scsi_debug partitions
The disk layout as created by scsi_debug depends on kernel version.
Let's make the partition sizes hardcoded in our tests than rely on
kernel.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-11 12:44:44 +01:00
Karel Zak e1efda47dd libfdisk: (dos) fix last possible sector calculation
* rename 'last' to 'first' as we use this value as the first available free
  sector rather than last used

* use '-1' when calculate last partition sector to compare with last
  disk sector

* improve debug messages

Fixes: https://github.com/karelzak/util-linux/issues/1249
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-11 12:18:34 +01:00
Sami Loone ee978576b1 agetty: tty eol defaults to REPRINT
Adapting tty eol settings from defaults misbehaves as CTRL('r') aka
REPRINT is confused with CR. Consequently --skip-login does not set
tty CR<->NL translations and thus acts against advertised CR as eol
default.

[kzak@redhat.com:
   It seems this issue has been introduced by commit f566447 where we
   merged sulogin and agetty terminal initialization together to the file
   include/ttyutils.h.

  The original agetty has really used .eol=13 (aka CR) for the default.
  The problem is invisible for sulogin(1) because it always asks for a
  password and .eol= is set to NL/CR, the same agetty when it asks for
  username.]

Addresses: https://github.com/karelzak/util-linux/pull/1247
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-10 17:48:46 +01:00
Karel Zak 78d43728b1 Merge branch 'switch_root-check-if-mounted' of https://github.com/Whissi/util-linux 2021-02-10 10:52:16 +01:00
Karel Zak c3a6350335 tests: be explicit with file permissions for cramfs
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-09 18:02:13 +01:00
Karel Zak b6787fca02 libmount: fix /{etc,proc}/filesystems use
* always update context->helper
* consolidate helper and syscall status use

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-09 10:36:04 +01:00
Thomas Deutschmann 037c7816ce
switch_root: check if mount point to move even exists
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
2021-02-08 15:35:07 +01:00
Karel Zak d4b5887354 build-sys: add --disable-scriptutils
This new ./configure option disables script, scriptreplay ans
scriptlive.

Fixes: https://github.com/karelzak/util-linux/issues/1244
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-08 15:01:33 +01:00
Karel Zak f458782f14 libsmartcols: remove unnecessary code
Fixes: https://github.com/karelzak/util-linux/pull/1243
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-08 14:47:38 +01:00
Karel Zak 56fc4adac9 github: fix distcheck job
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-05 15:21:56 +01:00
Karel Zak 63900c506b github: add 'distcheck' workflow job
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-05 15:03:49 +01:00
Karel Zak ec89bec1cd Merge branch 'gh-actions-bionic' of https://github.com/mrc0mmand/util-linux
* 'gh-actions-bionic' of https://github.com/mrc0mmand/util-linux:
  ci: run the build test for each pull request
  ci: build both w/ and w/o sanitizers on GH Actions
  ci: code cleanup
  ci: deal with uninstrumented binaries using instrumented libs
  text-utils: correctly detect ASan under clang
  ci: use the correct compiler version
  ci: 'downgrade' Ubuntu version to Bionic
2021-02-05 10:29:26 +01:00
Karel Zak 0edc239542 build-sys: fix schedutils/sched_attr.h include
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-05 10:23:04 +01:00
Karel Zak 9c7a613c82 login: use full tty path for PAM_TTY
pam_set_item() man page:
 PAM_TTY
   The terminal name: prefixed by /dev/ if it is a device file;
   for graphical, X-based, applications the value for this item
   should be the $DISPLAY variable.

It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...

Fixes: https://github.com/karelzak/util-linux/issues/1242
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-03 14:49:09 +01:00
Karel Zak 6165376737 su: use full tty path for PAM_TTY
pam_set_item() man page:
 PAM_TTY
   The terminal name: prefixed by /dev/ if it is a device file;
   for graphical, X-based, applications the value for this item
   should be the $DISPLAY variable.

It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...

Fixes: https://github.com/karelzak/util-linux/issues/1242
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-03 14:45:15 +01:00
Karel Zak 82643a9be5 build-sys: cleanup uclampset dependencies
chrt requires sched_setattr() or sched_setscheduler(), the both is
covered by have_schedsetter variable in ./configure.ac. This variable
is useless for uclampset, because it requires sched_setattr(). Let's
make it more explicit for uclampset.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-02 16:54:33 +01:00
Karel Zak f4b07719ee uclampset: cleanup --hel output
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-02 16:54:22 +01:00
Karel Zak 12d776c833 include/pathnames: cleanup /proc/sys/kernel use
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-02 16:54:12 +01:00
Karel Zak 9a823f1536 Merge branch 'uclampset-v3' of https://github.com/qais-yousef/util-linux
* 'uclampset-v3' of https://github.com/qais-yousef/util-linux:
  uclampset: Plumb in bash-completion
  uclampset: Plump into the build system
  uclampset: Add man page
  Add uclampset schedutil
  Move sched_attr struct and syscall definitions into header file
2021-02-02 16:53:50 +01:00
Qais Yousef 860112cb21 uclampset: Plumb in bash-completion
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-02-02 10:56:26 +00:00
Qais Yousef f59654bb06 uclampset: Plump into the build system
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-02-02 10:56:26 +00:00
Qais Yousef 9dd95bea42 uclampset: Add man page
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-02-02 10:56:26 +00:00
Qais Yousef 5407f89782 Add uclampset schedutil
Utilization clamping is a new kernel feature that got merged in 5.3. It
allows controlling the performance of a process by manipulating the
utilization such that the task appears bigger or smaller than what it
really is.

There's a system-wide control to to restrict what maximum values the
process are allowed to use.

Man page added in a later patch attempts to explain the usage in more
detail.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-02-02 10:56:26 +00:00
Ivan Mironov 5df455dbbc agetty: Allow --init-string on a virtual console
This option has valid use cases on virtual consoles. Example:
enabling screen blanking in the same way as `setterm --blank ...`
does.

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
2021-02-02 00:29:25 +05:00
Karel Zak d687a6b4b0 eject: cleanup before successful exit
Fixes: https://github.com/karelzak/util-linux/issues/1239
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-01 12:21:18 +01:00
Frantisek Sumsal f30ec3eee6 ci: run the build test for each pull request 2021-02-01 12:00:30 +01:00
Frantisek Sumsal eed6393d14 ci: build both w/ and w/o sanitizers on GH Actions 2021-02-01 12:00:30 +01:00
Frantisek Sumsal b17a386004 ci: code cleanup 2021-02-01 12:00:30 +01:00
Frantisek Sumsal 81edf9f0da ci: deal with uninstrumented binaries using instrumented libs
All `eject` tests were failing under ASan, since they call /bin/mount,
which is uninstrumented, but it picks up the instrumented `libblkid`
library, causing ASan to complain:

gcc:
ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
eject: unmount of `/home/runner/work/util-linux/util-linux/tests/output/eject/umount-by-disk-mounted-mnt' failed

clang:
/bin/umount: symbol lookup error: /home/runner/work/util-linux/util-linux/.libs/libblkid.so.1: undefined symbol: __sancov_lowest_stack
eject: unmount of `/home/runner/work/util-linux/util-linux/tests/output/eject/umount-by-disk-mounted-mnt' failed

Subsequently, all tests which require the `scsi_debug` module get skipped,
since it's still in use due to the failed umount:

fdisk: align 512/4K                   ... SKIPPED (cannot remove scsi_debug module (rmmod))
fdisk: align 512/4K +alignment_offset ... SKIPPED (cannot remove scsi_debug module (rmmod))
fdisk: align 512/4K +MD               ... SKIPPED (cannot remove scsi_debug module (rmmod))

In case of gcc this can be easily resolved by setting $LD_PRELOAD to the
respective ASan library. clang makes this a bit more difficult, since it
compiles the ASan library statically, so firstly we need to force dynamic
linking (via -shared-asan), and then add the runtime DSO path to the
linker cache, since it's in a non-standard path.
2021-02-01 12:00:30 +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
Frantisek Sumsal 0388289e3a ci: use the correct compiler version 2021-02-01 11:54:31 +01:00
Frantisek Sumsal 4076d51e2e ci: 'downgrade' Ubuntu version to Bionic
Since the current Ubuntu Focal image in GH Actions is missing the
`kernel-modules-extra` package with the `scsi_debug` module[0], let's
change the distro flag from `ubuntu-20.04` (Focal) to `ubuntu-latest`
(currently Bionic, as Focal is still in the beta phase).

[0] https://github.community/t/missing-scsi-debug-linux-kernel-module-on-gh-actions/157698
2021-01-30 19:11:23 +01:00
Qais Yousef ee3f4a3dfc Move sched_attr struct and syscall definitions into header file
So that we can re-use them in other files.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-01-30 17:13:17 +00:00
ToddRK deba6720fb fsck.cramfs: fix fsck.cramfs crashes on blocksizes > 4K
fsck.cramfs crashes when extracting a cramfs image with a 16KB blocksize.
The read_buffer is hardcoded for a 4KB blocksize.  When using a blocksize
larger than 4KB, the program's code uses indexes that go past the end of the
allocated space for the read_buffer and this causes the crash.

The following changes fix the problem for me in the latest 2.36.1 release of
fsck.cramfs.c.  However there are hardcoded values of 4096 in the code that
might cause problems under other circumstances and I have not attempted to
fix those.

[kzak@redhat.com: - some coding style changes to code]

Fixes: https://github.com/karelzak/util-linux/issues/1232
Signed-off-by: ToddRK <ToddRK@example.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-28 12:46:49 +01:00
Karel Zak 867df2617c lib: use ul_prefix for close_all_fds() and mkdir_p()
The names are too generic and it makes problems in static libraries.

Addresses: https://gitlab.com/cryptsetup/cryptsetup/-/issues/623
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-28 10:27:21 +01:00
Karel Zak 67f2918a6b github: enable ci-build for all basic branches
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-26 15:52:41 +01:00
Karel Zak ba8fbf21ef docs: update TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-26 15:51:26 +01:00
Karel Zak b94c187069 travis: remove old ubuntu
Ubuntu 12.04 LTS (Precise Pangolin) -- from April 2012 to April 2017.

It's more and more difficult to keep code and tests in all details
compatible with it 4 years dead distro.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-26 15:25:54 +01:00
Karel Zak bf32069382 github: make sure compiler is defined
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-26 12:39:22 +01:00