]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
20 months agolibblkid: reset errno before calling probefuncs
Thomas Weißschuh [Mon, 2 Oct 2023 20:24:21 +0000 (22:24 +0200)] 
libblkid: reset errno before calling probefuncs

The probers optionally use errno to communicate error details.
When a leftover errno is set from libblkid internally this can confuse
the probers.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agosetpriv: fix group argument completion
Thomas Weißschuh [Mon, 2 Oct 2023 13:52:33 +0000 (15:52 +0200)] 
setpriv: fix group argument completion

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibfdisk: reset errno before calling read()
Thomas Weißschuh [Mon, 2 Oct 2023 11:01:47 +0000 (13:01 +0200)] 
libfdisk: reset errno before calling read()

The else branch will be executed on short reads.
For those errno is not reset so a random left-over errno value may be
checked.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agoblkid: fix call to err_exclusive_options
Thomas Weißschuh [Mon, 2 Oct 2023 09:39:53 +0000 (11:39 +0200)] 
blkid: fix call to err_exclusive_options

err_exclusive_options needs to be passed the long options array,
otherwise it will crash.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agodocs: use HTTPS for GitHub clone URLs
Jakub Wilk [Mon, 2 Oct 2023 05:22:54 +0000 (07:22 +0200)] 
docs: use HTTPS for GitHub clone URLs

GitHub has dropped support for the git:// protocol:
https://github.blog/changelog/2022-03-15-removed-unencrypted-git-protocol-and-certain-ssh-keys/

20 months agolibblkid: (probe) handle probe without chain gracefully
Thomas Weißschuh [Wed, 27 Sep 2023 22:51:42 +0000 (00:51 +0200)] 
libblkid: (probe) handle probe without chain gracefully

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolib/idcache: always gracefully handle null cache
Thomas Weißschuh [Wed, 27 Sep 2023 22:40:28 +0000 (00:40 +0200)] 
lib/idcache: always gracefully handle null cache

The "get" functions already do this and some callers rely on it also for
"add" ones.

For completeness also handle it in free_idcache().

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agoscript-playutils: close filestream in case ignore_line() fails
Thomas Weißschuh [Wed, 27 Sep 2023 21:30:27 +0000 (23:30 +0200)] 
script-playutils: close filestream in case ignore_line() fails

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibblkid: (vxfs) report endianness
Thomas Weißschuh [Tue, 26 Sep 2023 22:49:04 +0000 (00:49 +0200)] 
libblkid: (vxfs) report endianness

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibblkid: (ntfs) validate that sector_size is a power of two
Thomas Weißschuh [Mon, 25 Sep 2023 22:27:22 +0000 (00:27 +0200)] 
libblkid: (ntfs) validate that sector_size is a power of two

The NTFS prober reads data based off an offset of the sector size.
If the sector size is unaligned and the read data is cached then other
probers can read unaligned values.

Sector sizes for NTFS actually only make sense as power-of-two so
validate that and as a sideeffect avoid the unaligned reads.

Also add the reproducer from OSS-Fuzz that found this issue.

Fixes #2509

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibsmartcols: handle nameless tables in export format
Thomas Weißschuh [Fri, 22 Sep 2023 09:20:36 +0000 (11:20 +0200)] 
libsmartcols: handle nameless tables in export format

fputs(NULL) is not allowed.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agoldattach: don't call exit() from signal handler
Thomas Weißschuh [Fri, 22 Sep 2023 18:21:38 +0000 (20:21 +0200)] 
ldattach: don't call exit() from signal handler

Instead use _exit().

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolslogins: fix realloc() loop allocation size
Thomas Weißschuh [Fri, 22 Sep 2023 18:08:22 +0000 (20:08 +0200)] 
lslogins: fix realloc() loop allocation size

If stat() fails the realloc loop would always try to allocate zero
bytes.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolib/env: avoid underflow of read_all_alloc() return value
Thomas Weißschuh [Fri, 22 Sep 2023 09:19:37 +0000 (11:19 +0200)] 
lib/env: avoid underflow of read_all_alloc() return value

read_all_alloc() returns a negative error on failure.
When casting this to an unsigned type the failure check "< 1"
will not work.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibblkid: avoid memory leak of cachefile path
Thomas Weißschuh [Fri, 22 Sep 2023 09:20:04 +0000 (11:20 +0200)] 
libblkid: avoid memory leak of cachefile path

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibmount: gracefully handle NULL path in mnt_resolve_target()
Thomas Weißschuh [Fri, 22 Sep 2023 09:30:57 +0000 (11:30 +0200)] 
libmount: gracefully handle NULL path in mnt_resolve_target()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agomore: avoid out-of-bound access
Thomas Weißschuh [Fri, 22 Sep 2023 17:53:24 +0000 (19:53 +0200)] 
more: avoid out-of-bound access

The realloc() needs to happen before that memory is used.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibfdisk: handle allocation failure in fdisk_new_partition
Thomas Weißschuh [Fri, 22 Sep 2023 17:35:01 +0000 (19:35 +0200)] 
libfdisk: handle allocation failure in fdisk_new_partition

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agologin: Use pid_t for child_pid
Tobias Stoeckmann [Tue, 19 Sep 2023 18:45:40 +0000 (20:45 +0200)] 
login: Use pid_t for child_pid

Since child_pid keeps track of a PID, it should be of type pid_t
and not of type int.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
20 months agologin: move comment
Tobias Stoeckmann [Tue, 19 Sep 2023 18:42:03 +0000 (20:42 +0200)] 
login: move comment

In 0b4d75fae55b4a5ff8f65df8551c56cf1eeb9b08 the variable "timeout" has
been moved from global to local scope, but its comment was not.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
20 months agobuild-sys: fix libmount/src/hooks.c use
Karel Zak [Mon, 18 Sep 2023 11:08:57 +0000 (13:08 +0200)] 
build-sys: fix libmount/src/hooks.c use

Reported-by: Samuel Thibault <samuel.thibault@aquilenet.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agolscpu: Use 4K buffer size instead of BUFSIZ
Khem Raj [Fri, 15 Sep 2023 07:18:18 +0000 (00:18 -0700)] 
lscpu: Use 4K buffer size instead of BUFSIZ

Some lines in /proc/cpuinfo can be large e.g. flags and can then
truncate them in displaying them

BUFSIZ can vary quite a bit  e.g. glibc/linux systems its 8192
but on musl/linux and OSX its 1024, on mingW it is 256, some tests e.g.
x86_64-64cpu-linux6.2.tar.gz has added really long line for cpu flags
line which is greater than 1024 characters and hence this test fails
on musl because lscpu -s reports truncated string

Fixes x86_64-64cpu-linux6.2 tests

Signed-off-by: Khem Raj <raj.khem@gmail.com>
s

20 months agoautotools: fix typos
Karel Zak [Mon, 11 Sep 2023 18:27:37 +0000 (20:27 +0200)] 
autotools: fix typos

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agolibmount: make.stx_mnt_id use more robust
Karel Zak [Thu, 31 Aug 2023 08:30:55 +0000 (10:30 +0200)] 
libmount: make.stx_mnt_id use more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agolibmount: report statx in features list
Karel Zak [Thu, 31 Aug 2023 08:26:37 +0000 (10:26 +0200)] 
libmount: report statx in features list

Let's make statx() support visible in "mount -V" output.

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agolibmount: fix statx() includes
Karel Zak [Wed, 23 Aug 2023 09:50:37 +0000 (11:50 +0200)] 
libmount: fix statx() includes

Using sys/stat.h and linux/stat is too tricky.h together. It seems
better to rely on libc and use sys/stat.h only. Users affected
by old libc must update to use recent util-linux.

Fixes: https://github.com/util-linux/util-linux/issues/2448
Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agolibblkid: (vfat) avoid modifying shared buffer
Thomas Weißschuh [Tue, 29 Aug 2023 10:44:48 +0000 (12:44 +0200)] 
libblkid: (vfat) avoid modifying shared buffer

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibblkid: (jmicron_raid) use checksum APIs
Thomas Weißschuh [Tue, 29 Aug 2023 10:31:35 +0000 (12:31 +0200)] 
libblkid: (jmicron_raid) use checksum APIs

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibblkid: (jmicron_raid) avoid modifying shared buffer
Thomas Weißschuh [Tue, 29 Aug 2023 10:29:31 +0000 (12:29 +0200)] 
libblkid: (jmicron_raid) avoid modifying shared buffer

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolibblkid: (zonefs) avoid modifying shared buffer
Thomas Weißschuh [Tue, 29 Aug 2023 10:22:28 +0000 (12:22 +0200)] 
libblkid: (zonefs) avoid modifying shared buffer

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agolosetup: fix JSON MAJ:MIN
Karel Zak [Mon, 28 Aug 2023 11:21:33 +0000 (13:21 +0200)] 
losetup: fix JSON MAJ:MIN

Fixes: https://github.com/util-linux/util-linux/issues/2460
Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agolslogins: (man) fix -y option formatting
Thomas Weißschuh [Mon, 28 Aug 2023 07:30:59 +0000 (09:30 +0200)] 
lslogins: (man) fix -y option formatting

Fixes #2461

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
20 months agoinclude: add DragonFlyBSD GPT partition types
Thomas Weißschuh [Mon, 28 Aug 2023 07:01:49 +0000 (09:01 +0200)] 
include: add DragonFlyBSD GPT partition types

Fixes #2462

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
22 months agolibblkid: (bcachefs) fix size validation
Thomas Weißschuh [Wed, 23 Aug 2023 09:58:33 +0000 (11:58 +0200)] 
libblkid: (bcachefs) fix size validation

Avoid signed shift out-of-bounds.

Also mark the constants explitly as unsigned instead of casting.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
(cherry picked from commit befe455f59de8c7bc66b85ed52aae8cbc95325fa)

22 months agolibblkid: (bcachefs) fix compiler warning [-Werror=sign-compare]
Karel Zak [Wed, 23 Aug 2023 09:53:45 +0000 (11:53 +0200)] 
libblkid: (bcachefs) fix compiler warning [-Werror=sign-compare]

Addresses: https://github.com/util-linux/util-linux/pull/2427
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 17873d38fc97913c0a31d4bd08cfbfe45c4de5be)

22 months agolibblkid: (bcachefs) fix not detecting large superblocks
Colin Gillespie [Wed, 9 Aug 2023 08:28:07 +0000 (18:28 +1000)] 
libblkid: (bcachefs) fix not detecting large superblocks

Probing does not detect bcachefs filesystems with a superblock larger
than 4KiB. Bcachefs superblocks grow in size and can become much larger
than this.

Increase the superblock maximum size limit to 1MiB.

Validate the superblock isn't larger than the maximum size defined in
the superblocks layout section.

(cherry picked from commit 48d573797797650d96456979797c0155d58f61cb)

23 months agolibmount: Fix regression when mounting with atime
Filipe Manana [Thu, 17 Aug 2023 09:20:13 +0000 (10:20 +0100)] 
libmount: Fix regression when mounting with atime

A regression was introduced in v2.39 that causes mounting with the atime
option to fail:

  $ mkfs.ext4 -F /dev/sdi
  $ mount -o atime /dev/sdi /mnt/sdi
  mount: /mnt/sdi: not mount point or bad option.
         dmesg(1) may have more information after failed mount system call.

The failure comes from the mount_setattr(2) call returning -EINVAL. This
is because we pass an invalid value for the attr_clr argument. From a
strace capture we have:

  mount_setattr(4, "", AT_EMPTY_PATH, {attr_set=0, attr_clr=MOUNT_ATTR_NOATIME, propagation=0 /* MS_??? */, userns_fd=0}, 32) = -1 EINVAL (Invalid argument)

We can't pass MOUNT_ATTR_NOATIME to mount_setattr(2) through the attr_clr
argument because all atime options are exclusive, so in order to set atime
one has to pass MOUNT_ATTR__ATIME to attr_clr and leave attr_set as
MOUNT_ATTR_RELATIME (which is defined as a value of 0).

This can be read from the man page for mount_setattr(2) and also from the
kernel source:

  $ cat fs/namespace.c
  static int build_mount_kattr(const struct mount_attr *attr, size_t usize,
                               struct mount_kattr *kattr, unsigned int flags)
  {
      (...)
      /*
       * Since the MOUNT_ATTR_<atime> values are an enum, not a bitmap,
       * users wanting to transition to a different atime setting cannot
       * simply specify the atime setting in @attr_set, but must also
       * specify MOUNT_ATTR__ATIME in the @attr_clr field.
       * So ensure that MOUNT_ATTR__ATIME can't be partially set in
       * @attr_clr and that @attr_set can't have any atime bits set if
       * MOUNT_ATTR__ATIME isn't set in @attr_clr.
       */
      if (attr->attr_clr & MOUNT_ATTR__ATIME) {
          if ((attr->attr_clr & MOUNT_ATTR__ATIME) != MOUNT_ATTR__ATIME)
              return -EINVAL;

              /*
               * Clear all previous time settings as they are mutually
               * exclusive.
               */
              kattr->attr_clr |= MNT_RELATIME | MNT_NOATIME;
              switch (attr->attr_set & MOUNT_ATTR__ATIME) {
              case MOUNT_ATTR_RELATIME:
                  kattr->attr_set |= MNT_RELATIME;
                  break;
              case MOUNT_ATTR_NOATIME:
                  kattr->attr_set |= MNT_NOATIME;
                  break;
              case MOUNT_ATTR_STRICTATIME:
                  break;
              default:
                  return -EINVAL;
              }
    (...)

So fix this by setting attr_clr MOUNT_ATTR__ATIME if we want to clear any
atime related option.

Signed-off-by: Filipe Manana <fdmanana@kernel.org>
23 months agobuild-sys: release++ (v2.39.2) v2.39.2
Karel Zak [Thu, 17 Aug 2023 09:05:49 +0000 (11:05 +0200)] 
build-sys: release++ (v2.39.2)

Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agodocs: update v2.39.2-ReleaseNotes
Karel Zak [Thu, 17 Aug 2023 09:04:21 +0000 (11:04 +0200)] 
docs: update v2.39.2-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agodocs: update AUTHORS file
Karel Zak [Thu, 17 Aug 2023 09:00:54 +0000 (11:00 +0200)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agopo-man: merge changes
Karel Zak [Thu, 17 Aug 2023 08:57:14 +0000 (10:57 +0200)] 
po-man: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agopo: merge changes
Karel Zak [Thu, 17 Aug 2023 08:57:06 +0000 (10:57 +0200)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agopo-man: update sr.po (from translationproject.org)
Мирослав Николић [Thu, 17 Aug 2023 08:45:20 +0000 (10:45 +0200)] 
po-man: update sr.po (from translationproject.org)

23 months agopo: update sr.po (from translationproject.org)
Мирослав Николић [Thu, 17 Aug 2023 08:44:54 +0000 (10:44 +0200)] 
po: update sr.po (from translationproject.org)

23 months agopo: update ja.po (from translationproject.org)
Takeshi Hamasaki [Thu, 17 Aug 2023 08:44:54 +0000 (10:44 +0200)] 
po: update ja.po (from translationproject.org)

23 months agopo: update hr.po (from translationproject.org)
Božidar Putanec [Thu, 17 Aug 2023 08:44:54 +0000 (10:44 +0200)] 
po: update hr.po (from translationproject.org)

23 months agopo: update es.po (from translationproject.org)
Antonio Ceballos Roa [Thu, 17 Aug 2023 08:44:53 +0000 (10:44 +0200)] 
po: update es.po (from translationproject.org)

23 months agosetarch: add PER_LINUX_FDPIC fallback
Karel Zak [Tue, 15 Aug 2023 09:33:31 +0000 (11:33 +0200)] 
setarch: add PER_LINUX_FDPIC fallback

Fixes: https://github.com/util-linux/util-linux/issues/2436
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agolibblkid: fix topology chain types mismatch
Karel Zak [Mon, 14 Aug 2023 10:31:48 +0000 (12:31 +0200)] 
libblkid: fix topology chain types mismatch

Reported-by: https://github.com/util-linux/util-linux/pull/2430
References: https://github.com/util-linux/util-linux/commit/3ab9e699a8d90f55e0447516b7e05a8686180467
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agouuidd: improve man page for -cont-clock
Karel Zak [Wed, 9 Aug 2023 10:56:42 +0000 (12:56 +0200)] 
uuidd: improve man page for -cont-clock

Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agozramctl: add hint about supported algorithms
Karel Zak [Wed, 9 Aug 2023 09:26:28 +0000 (11:26 +0200)] 
zramctl: add hint about supported algorithms

It seems the current list of the algorithms is confusing for
end-users, because it's inaccurate in many cases. Let's explain why
the list cannot be "perfect".

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2203324
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agomeson: check for HAVE_STRUCT_STATX_STX_MNT_ID
Karel Zak [Thu, 3 Aug 2023 11:39:32 +0000 (13:39 +0200)] 
meson: check for HAVE_STRUCT_STATX_STX_MNT_ID

References: c0136ac0c98b18208508fbcfac31a843e0bb8a37
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agoinclude: define pidfd syscalls if needed
Markus Mayer [Tue, 1 Aug 2023 20:08:24 +0000 (13:08 -0700)] 
include: define pidfd syscalls if needed

If the kernel headers are too old to provide the pidfd syscall numbers,
let's define them ourselves. This can be helpful while cross-compiling.
The runtime environment may provide a kernel that is new enough to
handle the calls, even if the toolchain doesn't.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
23 months agowall: do not error for ttys that do not exist
Mike Gilbert [Sat, 29 Jul 2023 21:32:57 +0000 (17:32 -0400)] 
wall: do not error for ttys that do not exist

Some wayland display managers (GDM) put strings like "seat0" in the
ut_line field of utmp entries. These are not valid tty devices.

Avoid writing a confusing error message for ttys that do not exist.

Bug: https://bugs.gentoo.org/911336
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
23 months agocolumn: fix -l
Karel Zak [Wed, 2 Aug 2023 10:57:37 +0000 (12:57 +0200)] 
column: fix -l

The original implementation is complicated and broken.

It's possible to calculate the rest of the string (for the last
column) from the current position rather than calculate it
continuously. Use the last wcstok() result also means that it will
work as expected independently on "greedy" mode (skips repeating
separators.

 # printf 'a   b c d\n1 2 3 4\n' | ./column -t -o '|' -l3
 a|b|c d
 1|2|3 4

(see space between 'a' and 'b' on input)

References: 8ac75e31de0ece74515e98e0b22e54cc0a9808bd
Fixes: https://github.com/util-linux/util-linux/issues/1763
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agolscpu: Even more Arm part numbers (early 2023)
Jeremy Linton [Wed, 26 Jul 2023 20:54:20 +0000 (15:54 -0500)] 
lscpu: Even more Arm part numbers (early 2023)

There have been further MIDR/part numbers published
on https://developer.arm.com, they include:

Cortex-X4, Cortex-A520, Cortex-A720, Cortex-M85,
Cortex-M55 and Cortex-R52+.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
23 months agochrt: (man) add note about --sched-period lower limit
Karel Zak [Mon, 31 Jul 2023 10:41:39 +0000 (12:41 +0200)] 
chrt: (man) add note about --sched-period lower limit

References: https://github.com/util-linux/util-linux/pull/2393
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agomeson: add check for struct statx
Thomas Weißschuh [Thu, 3 Aug 2023 10:22:29 +0000 (12:22 +0200)] 
meson: add check for struct statx

meson variant of commit 1fc3471dfb8b ("libmount: check for struct statx").

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
23 months agomeson: add check for linux/mount.h
Thomas Weißschuh [Thu, 3 Aug 2023 10:18:41 +0000 (12:18 +0200)] 
meson: add check for linux/mount.h

meson variant of commit 5502e73d8f82 ("libmount: check for linux/mount.h").

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
23 months agolibmount: improve EPERM interpretation
Karel Zak [Thu, 3 Aug 2023 11:06:30 +0000 (13:06 +0200)] 
libmount: improve EPERM interpretation

In some cases mount(2)/open_tree(2) returns EPERM for root user. In
this case libmount reports it as "mount point is not a directory".

It does not makes sense for bind mount where target could be a
regular file.

This patch is not ideal, the error handler is generic, but semantic
for new mount API and mount(2) is different. For example now it checks
for regular file, but the new API supports bind over symlinks, so
proper fix will require lstat() and S_ISLNK(), etc. We need to move
error messages to hook_mount.c and mount_mount_legacy.c to make it
more specific.

Fixes: https://github.com/util-linux/util-linux/issues/2413
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agolibmount: ifdef statx() call
Karel Zak [Thu, 3 Aug 2023 10:39:19 +0000 (12:39 +0200)] 
libmount: ifdef statx() call

In this case the statx() is use to get mount ID. It's optional and not
required. Let's #ifdef the statx() call and also check for stx_mnt_id
struct member.

Fixes: https://github.com/util-linux/util-linux/issues/2415
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agolibmount: check for struct statx
Markus Mayer [Tue, 1 Aug 2023 19:59:27 +0000 (12:59 -0700)] 
libmount: check for struct statx

Let's ensure struct statx exists before we try to use it. Checking for
the existence of linux/stat.h is not sufficient. This is because
[uapi/]linux/stat.h has existed since Linux 3.7, however struct statx
was only introduced with Linux 4.11.

The problem arises if one happens ot be using kernel headers from within
the aforementioned range, such as Linux 4.9.

  CC       libmount/src/la-utils.lo
In file included from libmount/src/utils.c:31:
./include/fileutils.h:100:33: warning: declaration of 'struct statx' will not
be visible outside of this function [-Wvisibility]
                    unsigned int mask, struct statx *stx)
                                              ^
libmount/src/utils.c:117:16: error: variable has incomplete type 'struct statx'
                struct statx stx = { 0 };
                             ^
libmount/src/utils.c:117:10: note: forward declaration of 'struct statx'
                struct statx stx = { 0 };
                       ^
libmount/src/utils.c:125:5: error: use of undeclared identifier 'STATX_TYPE'
                                STATX_TYPE
                                ^
libmount/src/utils.c:126:8: error: use of undeclared identifier 'STATX_MODE'
                                        | STATX_MODE
                                          ^
libmount/src/utils.c:127:8: error: use of undeclared identifier 'STATX_INO'
                                        | STATX_INO,
                                          ^
1 warning and 4 errors generated.
make[4]: *** [Makefile:11269: libmount/src/la-utils.lo] Error 1

Checking for the presence of struct statx explicitly avoids this
problem.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
23 months agolibmount: check for linux/mount.h
Markus Mayer [Tue, 1 Aug 2023 19:59:26 +0000 (12:59 -0700)] 
libmount: check for linux/mount.h

Check that linux/mount.h is present before using features that rely on
it.

It is necessary to check for the presence of linux/mount.h explicitly.
Simply relying on the presence of several syscalls (e.g. SYS_move_mount,
SYS_open_tree) does not work reliably, at least not in a cross-compiling
environment.

The syscall definitions are provided by the C library. Meanwhile,
linux/mount.h is provided by the kernel. This opens the possibility for
discrepancies.

A problem arises if the C library (e.g. musl-1.2.3) defines all "mount
fd API" syscalls (and HAVE_MOUNTFD_API becomes true), but the kernel
headers are old enough to not provide linux/mount.h. The resulting error
looks as follows. This example is using an LLVM-13 cross-compiler from
x86_64 to aarch64 with musl-1.2.3 as the C library.

  CC       libmount/src/la-hooks.lo
In file included from libmount/src/hooks.c:30:
./include/mount-api-utils.h:11:10: fatal error: 'linux/mount.h' file not found
         ^~~~~~~~~~~~~~~
1 error generated.
make[4]: *** [Makefile:11185: libmount/src/la-hooks.lo] Error 1

To prevent this condition, we add a check to configure that will test
for the presence of linux/mount.h in addition to testing for the mount
fd API. Only if both conditions are met can we actually use the mount
fd API.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
23 months agolibmount: (utils) fix statx fallback
Thomas Weißschuh [Thu, 3 Aug 2023 05:13:28 +0000 (07:13 +0200)] 
libmount: (utils) fix statx fallback

If the systemcall is not available ENOSYS is returned.

Under glibc the statx implementation also has its own fallback logic.
As AT_STATX_DONT_SYNC can't be implemented correctly in that fallback
logic the wrapper will return EINVAL in case the emulation is needed and
AT_STATX_DONT_SYNC is set.
So also use our own fallback in that case.

Fixes: #2409
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
23 months agolibmount: cleanup --fake mode
Karel Zak [Tue, 1 Aug 2023 12:49:48 +0000 (14:49 +0200)] 
libmount: cleanup --fake mode

It was originally designed to play nasty games with /etc/mtab (mount
when /etc is read-only and update later when it's write-able).

The --fake is completely useless with the new API due to complexity
where we cannot skip any step, because the next stuff depends on it.
So, it makes more sense skip all functionality where libmount does
anything significant.

This commit add --fake check to hooks logic to skip all hooks as the
hooks are place where libmount implements mount related invasive
operations (create mountpoint, namespaces, create superblock, move,
mount, etc.).

Frankly, --fake without mtab is useless.

Fixes: https://github.com/util-linux/util-linux/issues/2395
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agolibmount: (python): work around python 3.12 bug
Thomas Weißschuh [Sun, 9 Jul 2023 08:18:15 +0000 (10:18 +0200)] 
libmount: (python): work around python 3.12 bug

Python 3.12 introduced a -Wredundant-decls warning.
Work around it by not breaking the build.

See https://github.com/python/cpython/issues/106560

Closes: #2366
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
23 months agobuild-sys: add AX_COMPARE_VERSION
Thomas Weißschuh [Mon, 10 Jul 2023 11:23:22 +0000 (13:23 +0200)] 
build-sys: add AX_COMPARE_VERSION

It will be used to check the found python version.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
23 months agolibmount: update documentation for MNT_ERR_APPLYFLAGS
Debarshi Ray [Thu, 29 Jun 2023 11:04:41 +0000 (13:04 +0200)] 
libmount: update documentation for MNT_ERR_APPLYFLAGS

The implementation using the new FD based mount kernel API (ie.,
fsconfig/fsopen) uses MNT_ERR_APPLYFLAGS for failed mount_setattr(2)
calls, which involves more mount attributes (eg., MOUNT_ATTR_RDONLY,
MOUNT_ATTR_NOSUID, etc.) in addition to the MS_PROPAGATION flags (eg.,
MS_SHARED, MS_UNBINDABLE, etc.).

Note that mount_setattr(2) is part of the new FD based mount kernel API,
and is not used by the classic mount(2) based version.

Fallout from 987d844cdbc0f91ca81de3c1e5d0628a60eb458f

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
23 months agolibmount: fix typo
Debarshi Ray [Thu, 29 Jun 2023 10:21:07 +0000 (12:21 +0200)] 
libmount: fix typo

Similar to e80f8e46127e45907db25b4ffd58c699fdf4c35f and fallout from
6753e6f6912658e836966a6316df956e1af5fcae

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
23 months agolibmount: use some MS_* flags as superblock flags
Karel Zak [Thu, 20 Jul 2023 10:34:14 +0000 (12:34 +0200)] 
libmount: use some MS_* flags as superblock flags

The old mount(2) API usually utilizes MS_* flags to set up the VFS
node. However, there are some exceptions like "sync" (MS_SYNCHRONOUS),
where the flag is used (by kernel) for the superblock instead. The new
API addresses this issue, ensuring that these options are used for
fsconfig().

This commit introduces MNT_SUPERBLOCK to identify these options in the
libmount options Linux map, and it enforces the new mount code to
utilize these options for fsconfig(FSCONFIG_SET_FLAG).

Reported-by: Abbink Esger <esger.abbink.ext@siemens.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 54e4a6b145fd6ef943d93e16de748283e687855d)
Fixes: #2439
23 months agolibmount: use mount(2) for remount on Linux < 5.14
Karel Zak [Mon, 5 Jun 2023 10:59:41 +0000 (12:59 +0200)] 
libmount: use mount(2) for remount on Linux < 5.14

It seems mount_setattr() is supported on Linux < 5.14, but it's without
MOUNT_ATTR_NOSYMFOLLOW. That's problem for remount where we reset all
VFS flags.

The most simple (but not elegant) is to check for kernel version and
fallback to mount(2) on remount.

Addresses: https://github.com/util-linux/util-linux/issues/2283
Signed-off-by: Karel Zak <kzak@redhat.com>
23 months agogithub: check apt-cache in more robust way
Karel Zak [Wed, 16 Aug 2023 07:03:59 +0000 (09:03 +0200)] 
github: check apt-cache in more robust way

References: 3119a8060102ed7dd04d4a782932494c386f72a6
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibmount: handle failure to apply flags as part of a mount operation
Debarshi Ray [Thu, 13 Jul 2023 09:07:27 +0000 (11:07 +0200)] 
libmount: handle failure to apply flags as part of a mount operation

If a mount operation with extra flags runs into an EPERM when applying
the flags, then mnt_context_get_mount_excode() returns 'Unknown error
5005' and MNT_EX_FAIL.  Here's an example:

Create a mount point on the host with 'nodev,nosuid,noexec':
  $ dd if=/dev/zero of=/var/tmp/loopfile bs=40960 count=1024
  $ sudo losetup --find /var/tmp/loopfile
  $ sudo mkfs.ext4 /dev/loop0
  $ sudo mkdir /mnt/a
  $ sudo mount -o nosuid,nodev,noexec /dev/loop0 /mnt/a

Check the mount options to be sure:
  $ findmnt --output OPTIONS,PROPAGATION /mnt/a
  OPTIONS                                  PROPAGATION
  rw,nosuid,nodev,noexec,relatime,seclabel shared

Enter a mount and user namespace:
  $ podman run \
        --interactive \
        --privileged \
        --rm \
        --tty \
        --volume /:/run/host:rslave \
        registry.fedoraproject.org/fedora:38 \
        /bin/bash

Try to bind mount the mount point from the host inside the namespace
with some extra flags:
  # mkdir ~/b
  # mount --bind -o ro /run/host/mnt/a ~/b
  mount: /root/b: filesystem was mounted, but any subsequent operation
      failed: Unknown error 5005.
  # echo $?
  32

It will be better to show something more human-readable than 'Unknown
error 5005'.

Secondly, an exit code of 32 means 'mount failure', which isn't quite
correct here.  The mount operation is split into two mount(2) calls,
where the first one uses MS_BIND to create the bind mount, and the
second uses MS_REMOUNT | MS_BIND | MS_RDONLY to apply the 'ro' flag.
Here, the first mount(2) does succeed:
  # findmnt --output OPTIONS,PROPAGATION ~/b
  OPTIONS                                  PROPAGATION
  rw,nosuid,nodev,noexec,relatime,seclabel private,slave

It's only the application of the 'ro' flag with the second mount(2) that
fails with an EPERM.  Hence, an exit code of 1 that means 'incorrect
invocation or permissions' seems more appropriate.

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2 years agobuild-sys: release++ (v2.39.1) v2.39.1
Karel Zak [Tue, 27 Jun 2023 12:31:13 +0000 (14:31 +0200)] 
build-sys: release++ (v2.39.1)

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agodocs: update v2.39.1-ReleaseNotes
Karel Zak [Tue, 27 Jun 2023 12:30:01 +0000 (14:30 +0200)] 
docs: update v2.39.1-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agodocs: update AUTHORS file
Karel Zak [Tue, 27 Jun 2023 12:16:53 +0000 (14:16 +0200)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agopo-man: merge changes
Karel Zak [Tue, 27 Jun 2023 12:14:17 +0000 (14:14 +0200)] 
po-man: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agopo: merge changes
Karel Zak [Tue, 27 Jun 2023 12:14:10 +0000 (14:14 +0200)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agopo-man: add ro.po (from translationproject.org)
Remus-Gabriel Chelu [Tue, 27 Jun 2023 12:08:33 +0000 (14:08 +0200)] 
po-man: add ro.po (from translationproject.org)

2 years agopo-man: add ko.po (from translationproject.org)
Seong-ho Cho [Tue, 27 Jun 2023 12:08:33 +0000 (14:08 +0200)] 
po-man: add ko.po (from translationproject.org)

2 years agopo-man: update uk.po (from translationproject.org)
Yuri Chornoivan [Tue, 27 Jun 2023 12:08:33 +0000 (14:08 +0200)] 
po-man: update uk.po (from translationproject.org)

2 years agopo: update hr.po (from translationproject.org)
Božidar Putanec [Tue, 27 Jun 2023 12:05:10 +0000 (14:05 +0200)] 
po: update hr.po (from translationproject.org)

2 years agocal: fix long option name for -c
Jakub Wilk [Mon, 26 Jun 2023 19:02:13 +0000 (21:02 +0200)] 
cal: fix long option name for -c

2 years agocal: fix error message for bad -c argument
Jakub Wilk [Mon, 26 Jun 2023 18:58:21 +0000 (20:58 +0200)] 
cal: fix error message for bad -c argument

2 years agolib/strutils: fix typo
Jakub Wilk [Mon, 26 Jun 2023 18:00:43 +0000 (20:00 +0200)] 
lib/strutils: fix typo

2 years agobuild-sys: don't call pkg-config --static if unnecessary
Karel Zak [Mon, 26 Jun 2023 10:46:15 +0000 (12:46 +0200)] 
build-sys: don't call pkg-config --static if unnecessary

Addresses: https://github.com/util-linux/util-linux/issues/2327
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agologger: initialize socket credentials contol union
Karel Zak [Mon, 26 Jun 2023 09:56:23 +0000 (11:56 +0200)] 
logger: initialize socket credentials contol union

Addresses: https://github.com/util-linux/util-linux/issues/2336
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: fix error message for unexpected time offsets
Thomas Weißschuh [Sun, 25 Jun 2023 11:28:19 +0000 (13:28 +0200)] 
unshare: fix error message for unexpected time offsets

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolosetup: deduplicate find_unused() logic
Thomas Weißschuh [Sun, 25 Jun 2023 07:59:05 +0000 (09:59 +0200)] 
losetup: deduplicate find_unused() logic

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/loopdev: consistently return error values from loopcxt_find_unused()
Thomas Weißschuh [Sun, 25 Jun 2023 07:59:26 +0000 (09:59 +0200)] 
lib/loopdev: consistently return error values from loopcxt_find_unused()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/loopdev: document function return values
Thomas Weißschuh [Sun, 25 Jun 2023 07:58:43 +0000 (09:58 +0200)] 
lib/loopdev: document function return values

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agotests: (run.sh) detect builddir from working directory
Thomas Weißschuh [Wed, 21 Jun 2023 12:26:05 +0000 (14:26 +0200)] 
tests: (run.sh) detect builddir from working directory

This makes it easier to run test.sh from the build directory as
everything will work without any parameters irrespective of the build
directories name.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agohardlink: (man) add missing comma
Jakub Wilk [Sat, 24 Jun 2023 07:24:29 +0000 (09:24 +0200)] 
hardlink: (man) add missing comma

2 years agoMerge branch 'lsfd--fix-separators-for-json-output-endpoints-only' of https://github...
Karel Zak [Mon, 26 Jun 2023 10:00:41 +0000 (12:00 +0200)] 
Merge branch 'lsfd--fix-separators-for-json-output-endpoints-only' of https://github.com/masatake/util-linux into stable/v2.39

* 'lsfd--fix-separators-for-json-output-endpoints-only' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode
  lsfd: use ARRAY_STRING for ENDPOINTS column in JSON output mode
  lsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types

2 years agolibmount: fix sync options between context and fs structs
Karel Zak [Thu, 22 Jun 2023 11:11:57 +0000 (13:11 +0200)] 
libmount: fix sync options between context and fs structs

Since v2.39 libmount prefers "struct libmnt_optlist" to keep mount options
rather than the original "struct libmnt_fs". This is problem if the
"fs" struct is defined and maintained outside the context.

The library has already a way how to sync "fs" and "optlist", but this
needs to be improved and used more widely. Changes:

* force "fs" from context to always read options from "optlist"

* copy options from "fs" to "optlist" in mnt_context_set_fs()

* internally redirect mnt_fs_* API for options to "optlist" if optlist
  defined

* add simple test to make sure options from different sources are
  always merged together

Addresses: https://github.com/util-linux/util-linux/issues/2326
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agotests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode
Masatake YAMATO [Thu, 22 Jun 2023 15:45:23 +0000 (00:45 +0900)] 
tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: use ARRAY_STRING for ENDPOINTS column in JSON output mode
Masatake YAMATO [Thu, 22 Jun 2023 05:42:34 +0000 (14:42 +0900)] 
lsfd: use ARRAY_STRING for ENDPOINTS column in JSON output mode

This is the backport-for-v2.39 version of #2328.

With this change:
  {
     "lsfd": [
        {
           "assoc": "3",
           "endpoints": [
               "9942,test_mkfds,4-w", "9942,test_mkfds,5r-", "9942,test_mkfds,6-w"
           ]
        }
     ]
  }

Without this change:
 {
     "lsfd": [
        {
           "assoc": "3",
           "endpoints": [
               "9942,test_mkfds,4-w\n9942,test_mkfds,5r-\n9942,test_mkfds,6-w"
           ]
        }
     ]
  }

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types
Masatake YAMATO [Thu, 22 Jun 2023 02:28:47 +0000 (11:28 +0900)] 
lsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types

We will have operators for array types in the future.  Till having
them, we treat the types as STRING. So we can use string operators for
the column having types.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agosfdisk: add hint about duplicate UUIDs when use dump
Karel Zak [Wed, 21 Jun 2023 08:57:37 +0000 (10:57 +0200)] 
sfdisk: add hint about duplicate UUIDs when use dump

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolib: remove pager.c from libcommon
Karel Zak [Tue, 20 Jun 2023 11:15:45 +0000 (13:15 +0200)] 
lib: remove pager.c from libcommon

The libcommon is a binary archive to keep compilation and maintenance
simple. The library is not linked as shared or so. The unused symbols
are removed from binaries (for example, by "make install-strip").

But it isn't evident for license analyzers (and some humans) that the
library uses GPL and non-GPL stuff simultaneously. Let's avoid doubts
and keep pager.c (with GPL license) out of the archive

Signed-off-by: Karel Zak <kzak@redhat.com>