Commit Graph

763 Commits

Author SHA1 Message Date
Luca Boccassi 488fd4c3df cryptsetup: add option to use via dlopen in libmount
Enabling libcrypsetup in libmount had several unintended side
effects.
First of all, it increases the Debian minimal image size by
~2.5% (5.6MB worth of new libraries).
Then, due to libcryptsetup linkage to OpenSSL and libjson-c,
it causes incompatibilities with external programs linking
against both libmount and a private, static, old version of
OpenSSL, or external programs linking against libjansson or
json-glib, which have one symbol in common with libjson-c.

If ./configure is ran with --with-crypsetup=dlopen,
instead of linking to libcrypsetup, use dlopen to resolve
the symbols at runtime only when the verity feature is
used, thus avoiding clashes and keeping images size down.

Fixes #1081

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
2020-07-07 16:43:55 +01:00
Karel Zak fe0d12d4f8 libmount: (parser) fix memory leak on error before end-of-file
Let's simplify the loop where we add FS to the table. The optimization
for recoverable errors is a fragile overkill. The new code always
allocates and unrefs FS for each loop.

Addresses: https://github.com/karelzak/util-linux/pull/1068
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-26 12:59:32 +02:00
Karel Zak b3391f3ac7 libmount: add support for ID=
This patch add support for a new tag. The tag is based on udev block
device ID (see /dev/disk/by-id). The usual use-case is to use
WWN for this purpose, for example

  # mount ID=wwn-0x50026b724b09a1ff /mnt

Note that ID is not strictly defined and udevd generates various IDs
also for HW where WWN is undefined. This is reason why introduce ID=
seems better and more generic than more restrictive WWN=.

Addresses: https://github.com/karelzak/util-linux/issues/1008
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-03 16:53:00 +02:00
Gabriel de Perthuis 3dde0d076d Add to the list of pseudo-filesystem types
Useful commands for maintaining the list:

    grep -w ^nodev /proc/filesystems |sort

In a Linux source checkout:

    git grep -wl file_system_type '*.c' |xargs grep -L FS_REQUIRES_DEV |xargs grep -wA12 file_system_type |grep -F '.name' |uniq |column -t
2020-05-20 20:28:01 +02:00
Karel Zak 6390860d71 libmount: (umount) fix FD leak
References: 7065cc0e53
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-15 12:09:43 +02:00
Roberto Bergantinos Corpas 31b3a523ec libmount: fix mount -a EBUSY for cifs
fstab:

 //rhel73/myshare/sub/path  /mnt   cifs

after mount in mountinfo:

 #  grep cifs /proc/self/mountinfo
 47 39 0:40 /sub/path /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
            ^^^^^^^^^
or:

 # grep cifs /proc/self/mountinfo
 47 39 0:40 / /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
            ^

That is so since on kernel cifs code, cifs_get_root (which returns the
entry associated with mnt_root) return s_root if
CIFS_MOUNT_USE_PREFIX_PATH is set, no questions asked.

This situation can occurr often on CIFS mounts, as CIFS servers limit
frequently scope of access to the root path.

[kzak@redhat.com: - add more info to the commit message,
                  - clean up variable names]

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1826719
Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-27 15:46:02 +02:00
Tycho Andersen 64cb2da8dc libmount: do not unnecessarily chmod utab.lock
Before ecfeae90a2 ("libmount: Ensure utab.lock mode 644"), you could do
something like:

irc:/tmp umount --version
umount from util-linux 2.27.1 (libmount 2.27.0: selinux, assert, debug)
irc:/tmp mkdir foo bar
irc:/tmp unshare -Urm
irc:/tmp mount --bind foo bar
irc:/tmp umount bar
irc:/tmp echo $?
0

However, afterwards, you get:

/tmp unshare -Urm
/tmp mount --bind foo bar
/tmp umount bar
umount: /tmp/bar: filesystem was unmounted, but failed to update userspace mount table.

Because of the chmod failing:

fchmod(3, 0644)                         = -1 EPERM (Operation not permitted)

Let's figure out whether the chmod is necessary before doing it, and only
do it if it is necessary. This won't fix cases where the system is already
broken, but at least on healthy systems umount will behave as before.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2020-04-22 12:36:43 +02:00
Karel Zak 69fe4f4ba6 Merge branch 'clang' of https://github.com/neheb/util-linux
* 'clang' of https://github.com/neheb/util-linux:
  [clang-tidy] fix misleading identation
  [clang-tidy] use ceil
  [clang-tidy] fix wrong *cmp usage
  [clang-tidy] do not use else after return
  [clang-tidy] do not return in void functions
  [clang-tidy] fix mismatching declarations
2020-04-22 10:07:51 +02:00
Karel Zak e2aedec8d1 pylibmount: cleanup and sync UL_RaiseExc
Addresses: https://github.com/karelzak/util-linux/issues/1013
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-22 09:44:47 +02:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Karel Zak 3168ba091f libmount: use mnt_stat_mountpoint() on more places
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-06 11:58:29 +02:00
Fabian Vogt 7065cc0e53 libmount: Avoid triggering autofs in lookup_umount_fs_by_statfs
Currently, umount /foo results in a statfs("/foo") call, which triggers
autofs. This can create another mountpoint on /foo, which is then unmounted
later instead of the actual /foo at the time umount was called.

This is especially an issue for umount -R /bar, which just fails with
-EBUSY as the accidental mountpoint is never accounted for and so it tries
to umount /bar before /bar/someautofs.

Replace the direct statfs call with open(path, O_PATH) + fstatfs, which sees
the autofs mount directly, without triggering it.
2020-04-01 13:34:43 +02:00
Karel Zak a971746370 libmount: make mnt_context_find_umount_fs() more extendable
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-27 11:34:12 +01:00
Karel Zak 4ce77c625a libmount: (umount) FS lookup refactoring
Let's split lookup to more function to make it easy to add another
lookup method.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-27 11:10:26 +01:00
Karel Zak 36d80cb6c1 libmount: smb2 is unsupported alias
Kenneth D'souza wrote:
 # grep -w MODULE_ALIAS_FS fs/cifs/cifsfs.c
 MODULE_ALIAS_FS("cifs");
 112/112│MODULE_ALIAS_FS("smb3");

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1812118
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-11 18:38:09 +01:00
Karel Zak b7ff4134be libmount: improve smb{2,3} support
It seems kernel can use smb3 as fstype in mountinfo.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1812118
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-11 10:47:52 +01:00
Karel Zak 11b916cdab libmount: try read-only mount on write-protected superblock too
The classic mount(8) behavior is to try read-only on write-protected devices
if the first mount syscall attempt ends with EACCES.

It seems we can implement this feature also for EBUSY if the same mount source
is already mounted with "ro" superblock option.

The typical use-case is iso image (always read-only) mounted on two places.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1809124
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 11:39:10 +01:00
Karel Zak acd229fc2a libmount: move "already mounted" code to separate function
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 10:55:28 +01:00
Karel Zak 88f04bf9e6 libmount: fix x- options use for non-root users
libmount returns EPERM for all X- and x- mount options for non-root
users when evaluate X-mount.mkdir. It's bug, we need to be sensitive
to only X-mount.mkdir and only if the target directory is missing.

Addresses: https://github.com/karelzak/util-linux/issues/941
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-28 10:54:33 +01:00
Karel Zak e3e7cd659e Merge branch 'dmverity_sig' of https://github.com/bluca/util-linux
* 'dmverity_sig' of https://github.com/bluca/util-linux:
  libmount: add support for signed verity devices
2020-01-23 15:47:15 +01:00
Karel Zak eae8661e68 libmount: (monitor) remove dead code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-15 14:08:06 +01:00
Karel Zak 810dfb7de6 libmount: use vsnprintf() in more robust way [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-15 13:59:42 +01:00
Luca Boccassi 123b1a6708 libmount: add support for signed verity devices
A new API was added to libcryptsetup to make use of the kernel's new
CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG feature, which allows to sign
root hashes. Add a verity.roothashsig option to use it.
Device reuse will be allowed only if signatures are used by all, or
by none.
2020-01-13 12:24:55 +00:00
Karel Zak bb607cb3b2 docs: fix typos [fossies codespell scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-09 10:18:16 +01:00
Luca Boccassi e7924c4f15 libmount: do not obscure return code when checking verity options
In some corner cases, the return code was being overwritten without
being checked
2020-01-08 12:59:23 +01:00
Karel Zak 24cee7157a docs: update year in libs docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-06 12:59:45 +01:00
Karel Zak 6b0094d0c1 libmount: improve X-mount.mkdir for non-root users
Since v2.35 mount(8) drops suid on -EPERM and repeat necessary actions
before mount(2) syscall. This patch also improves this behavior for
X-mount.mkdir too.

mount(8):
 * return -EPERM on sanitize_paths() rather than call err()
 * call suid_drop() on failed sanitize_paths()
 * update man page

libmount:
 * mnt_context_prepare_target() refactoring
 * return -EPERM when in restricted mode for X-mount.mkdir

Fixed version:
 /home/kzak/mnt-foo   sr.net.home:/home/kzak   fuse.sshfs noauto,X-mount.mkdir

 $ mount /home/kzak/mnt-foo
 kzak@sr.net.home's password:

 $ /home/projects/util-linux/util-linux  findmnt /home/kzak/mnt-foo
 TARGET             SOURCE                 FSTYPE     OPTIONS
 /home/kzak/mnt-foo sr.net.home:/home/kzak fuse.sshfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000

Addresses: https://github.com/systemd/systemd/issues/14418
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-03 10:48:09 +01:00
Luca Boccassi 9835a4b6a1 verity: add support for Forward Error Correction options
Requires kernel built with CONFIG_DM_VERITY_FEC.
2019-12-10 12:52:39 +00:00
Luca Boccassi fe8358bf05 verity: ensure that hash_device and root_hash[_file] are passed together or not at all
If a hash device or a roothash are passed for verity usage, both have to be present
or we cannot use them. Make it an error to pass only one of them.
2019-12-10 12:52:39 +00:00
Luca Boccassi 141bb954e7 verity: add new verity.roothashfile option
Allow users to point mount to a file to read the roothash, in addition
to passing it inline.
Allows a volume managed by a systemd mount unit to be updated without
changing the mount unit content itself, for easier and more user friendly
servicing.
2019-12-10 12:52:39 +00:00
Karel Zak cbc390da3a libmount: add verity to mount -V output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 14:57:29 +01:00
Karel Zak 9309ca1b93 Merge branch 'dmverity' of https://github.com/bluca/util-linux
* 'dmverity' of https://github.com/bluca/util-linux:
  libmount: add support for verity devices via libcryptsetup
2019-12-05 13:23:46 +01:00
Luca Boccassi e6a498877c libmount: add support for verity devices via libcryptsetup
The following new options are added:

verity.hashdevice
verity.roothash
verity.hashoffset

The source path will be used as a dm-verity object, and will be
opened using libcryptsetup APIs.

A new --with-cryptsetup build-time option is added, which adds a
dependency on libcryptsetup. To ease bootstrapping, given libcryptsetup
build-depends on util-linux for libuuid, if --with-cryptsetup=yes but
libcryptsetup is not installed only a warning will be printed at
configure time rather than an error. This way stage0/first stage/ring0
builds can use the same configure options but avoid installing
cryptsetup to get a working base set, and then rebuild util-linux in
the next step of the boostrapping process.

If verity options are selected but cannot be fullfilled due to lack of
dependencies, mounting a volume will fail even if using a loop device
would work as a fallback, to avoid silently skipping integrity checks.
2019-12-05 10:39:21 +00:00
Karel Zak 3861c371f6 Merge branch 'mount-eperm'
* mount-eperm:
  mount: no exit on EPERM, continue without suid
2019-12-03 15:23:53 +01:00
Karel Zak 6f7c67a5ff libmount: fix typo in mnt_context_prepare_helper() [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:31:55 +01:00
Karel Zak 6497f2d99e mount: no exit on EPERM, continue without suid
The current libmount assumes that mount(8) and umount(8) are suid
binaries. For this reason it implements internal rules which
restrict what is allowed for non-root users. Unfortunately, it's
out of reality for some use-cases where root permissions are no
required. Nice example are fuse filesystems.

So, the current situation is to call exit() always when mount, umount or
libmount are unsure with non-root user rights. This patch removes the
exit() call and replaces it with suid permissions drop, after that it
continues as usually. It means after suid-drop all depend on kernel
and no another security rule is used by libmount (simply because any
rule is no more necessary).

Example:

old version:
   $ mount -t fuse.sshfs kzak@192.168.111.1:/home/kzak /home/kzak/mnt
   mount: only root can use "--types" option

new version:
   $ mount -t fuse.sshfs kzak@192.168.111.1:/home/kzak /home/kzak/mnt
   kzak@192.168.111.1's password:

   $ findmnt /home/kzak/mnt
   TARGET         SOURCE                        FSTYPE     OPTIONS
   /home/kzak/mnt kzak@192.168.111.1:/home/kzak fuse.sshfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000

   $ umount /home/kzak/mnt
   $ echo $?
   0

Note that fuse user umount is supported since v2.34 due to user_id= in
kernel mount table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-19 14:58:20 +01:00
Karel Zak 916a3f8d29 libmount: don't access struct member, use API
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-18 16:19:15 +01:00
Karel Zak 6a735c2c5b libmount: make sure optsmode is initialized
Since 34333e5244 we apply fstab options
manually by mnt_context_apply_fs() on --all. The function does not
work correctly when optsmode is zero.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 13:51:29 +01:00
Karel Zak 34333e5244 libmount: allow use -o together with --all
For example:
	# mount --verbose --all -t xfs -o ro

will mount all all XFS filesystems from fstab, but read-only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 7a56878d4b libmount: move context fs merge to separate function
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak e5d2044407 libmount: fix mnt_context_next_remount()
The current implementation works, but the remount operation is done in
the cloned context and the original context (and calling application)
has no information about the final status/errors. This is mistake.

This new implementation works like mnt_context_next_mount(), it means
the same context (as used by application) is reused for all remounts.
The original setting is restored by mnt_context_apply_template().

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak e83c09d49e libmount: save current FS setting as template
This commit adds new functions to save and reuse the current FS
setting (mount options from command line, etc) after context reset.
It's usable for example in "mount --all" when we use the same context
for more times for more mount operations.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak eee7ea558c libmount: use strdup_between_structs()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 779e3c97aa libmount: cleanup strdup() use in context, add reg.test
* don't ignore strdup() result
* cleanup mnt_context_prepare_helper() to have only one return point
  (due to mnt_context_switch_ns())
* add mnt_context_prepare_helper() test program

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 71ed3b8337 libmount: add target prefix support
* add set/get functions to context
* use prefix to detect already mounted filesystems
* use prefix when prepare target path

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 05842a92d8 libmount: don't use /proc/mounts fallback if filename specified
The current solution is to use /proc/mounts if previous attempt to
open /proc/self/mountinfo failed. The fallback should not be used when
mount table path is explicitly specified by application. The default
is NULL, only in this case libmount should be try to be smart.

Reported-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-29 12:59:08 +01:00
Masami Hiramatsu 9ae113ca73 libmount: Add libselinux dependency to pkgconfig file
Add libselinux dependency to libmount if it is compiled
with selinux support.

Without this fix, 'pkg-config --libs --static mount' doesn't
show libselinux related options.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
2019-10-11 10:28:57 +02:00
Darsey Litzenberger e7305e4ea3 libmount: Recognize more FUSE pseudofs (avfsd, lxcfs, vmware-vmblock)
General info about these filesystems:

* fuse.avfsd: https://sourceforge.net/projects/avf/
* fuse.lxcfs: https://linuxcontainers.org/lxcfs/
* fuse.vmware-vmblock: https://github.com/vmware/open-vm-tools

Signed-off-by: Darsey Litzenberger <dlitz@dlitz.net>
2019-10-02 17:29:05 -07:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak bc747dfccf libmount: fix free() call on error
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-21 11:16:34 +02:00
Karel Zak 026f7d3020 libmount: use fmemopen() in more robust way [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 13:00:19 +02:00
Karel Zak 987ec2a696 libmount: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 16:18:48 +02:00
Karel Zak ee551c909f libmount; fix and improve read+poll mountinfo
* fix read() buffer size (stupid bug...)

* split read() EINTR and poll() based attempts

* use 100 attempts

* wait 10000 usec between attempts, but first 10 attempts are without
  this delay. It makes the function usable for usual use-cases as well
  as on very busy systems (successfully tested with 300 concurrent
  mount/umount processes)

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-29 15:50:58 +02:00
Karel Zak e4925f591c libmount: improve mountinfo reliability
The standard way how we read mount table is not reliable because
during the read() syscalls the table may be modified by some another
process. The changes in the table is possible to detect by poll()
event, and in this case it seems better to lseek to the begin of the file
and read it again. It's expensive, but better than races...

This patch does not modify mountinfo parser, but it reads all file to
memory (by read()+poll()) and than it creates memory stream
from the buffer and use it rather than a regular file stream.

It means the parser is still possible to use for normal files
(e.g. fstab) as well as for mountinfo and it's also portable to
systems where for some reason is no fmemopen().

Note that re-read after poll() event is limited to 5 attempts (but
successful read() without event zeroize the counter). It's because we
do not want to wait for consistent mountinfo for ever. It seems better
to use old (less reliable) way than hang up in read()+poll()
loop.

Addresses: https://github.com/systemd/systemd/issues/10872
Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-29 14:27:11 +02:00
Patrick Steinhardt ad167a9023 libmount: fix comment referring to passno field
There's an obvious copy-paste error in `mnt_parse_table_line` when
referring to the 6th field of the fstab format, where it says "freq"
instead of "passno". This has probably been copied from the 5th field,
which is in fact correctly labelled as "freq".

Fix the mistake by changing the comment to say "passno" instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-08-20 14:04:33 +02:00
Kevin Hao 042057d802 libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()
The "umount -f -a -r" get stuck in a endless loop when run with a
mountinfo like below:
  15 0 179:2 / / ro,relatime - ext4 /dev/root ro
  16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755
  17 15 0:4 / /proc rw,relatime - proc proc rw
  18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
  19 15 0:16 / /sys rw,relatime - sysfs sysfs rw
  20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
  21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755
  22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw
  23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
  24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
  25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k

The reason is that the two same mnt entry "/mnt/.psplash" will cause
the dst->tab set to NULL when umount this mnt entry the second time.
This will trigger an endless loop in mnt_reset_table() because that
mnt entry is linked on the libmnt_table but its .tab is set to NULL.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
2019-08-19 14:36:55 +02:00
Sami Kerola 371be858d7
libmount: fix potential null pointer dereference
This is false positive warning, but lets silence it so that if and when
warnings crop up they are easy to notice and take seriously.

libmount/src/optstr.c:354:29: warning: potential null pointer dereference
[-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-12 22:09:31 +01:00
Karel Zak 369e4c53a8 libmount: fix docs typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-13 13:45:39 +02:00
Karel Zak 2089538adb libmount: (docs) add reference to v2.33 and v2.34
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-07 12:37:28 +02:00
Karel Zak 9db442e954 libmount: add selinuxfs between pseudo filesystems
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-29 18:04:57 +02:00
Karel Zak 0e36d7c271 libmount: add bpf between pseudo filesystems
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-29 18:01:04 +02:00
Sami Kerola cbcedf6ba8
libmount: avoid possible null pointer dereference [cppcheck]
[libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:17:10 +01:00
Karel Zak cb400752a4 libmount: fix memory leak on error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 17:25:04 +02:00
Austin English 9d71482941 libmount: fix "maybe be" duplication
Signed-off-by: Austin English <austinenglish@gmail.com>
2019-05-15 13:48:47 +02:00
Karel Zak cb055909c3 libmount: return errno on failed fstab stat()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-09 10:09:34 +02:00
Karel Zak 2e5ff9db30 libmount: fix compiler warning [-Wsometimes-uninitialized]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-15 13:35:21 +02:00
Karel Zak 82e39473a5 libmount: fix memleak on parse errors
Addresses: https://github.com/systemd/systemd/pull/12252
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-15 12:55:46 +02:00
Karel Zak 6c9ab254ae libmount: don't use sscanf() for swaps parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 15:16:23 +02:00
Karel Zak 86673b3a46 libmount: don't use sscanf() for mountinfo parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 14:45:56 +02:00
Karel Zak 36fcefa651 libmount: don't use sscanf() for fstab parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 13:34:47 +02:00
Tim Hildering 9d5eb4c464 libmount: improve fs referencing in tables
* Added member 'struct libmnt_table *tab' to libmnt_fs structure.
* Added 'mnt_fs_get_table()'.
* Removed overhead from 'mnt_table_{insert,move,remove}_fs().
* Added check to 'mnt_table_set_iter()' that entry is member of table.

[kzak@redhat.com: - add to libmount.sys
                  - add to docs
                  - cleanup commit message
                  - set fs->tab = NULL before mnt_unref_fs() in mnt_table_remove_fs()]

Signed-off-by: Tim Hildering <hilderingt@posteo.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-08 11:40:20 +01:00
Stanislav Brabec 89342e0406 libmount: Recognize more fuse filesystems as pseudofs and netfs
Add some fuse filesystems to the list of pseudofs and netfs.

There are still tens of filesystems that should be evaluated and added.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-03-04 11:38:28 +01:00
Karel Zak 911e694528 libmount: add mnt_table_{find,insert,move}_fs()
Add functions to insert FS into table to specified position and to
move FS between two tables.

Co-Author: Tim Hildering <hilderingt@posteo.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-21 13:49:39 +01:00
Sami Kerola 110260830d docs: fix typos [codespell]
Reference: https://github.com/codespell-project/codespell
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:22:43 +01:00
Karel Zak a57c9865f8 libmount: (tabdiff) use list_add_tail() in more robust way
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 12:35:51 +01:00
Tim Hildering beb60dbd6f libmount: check table membership before adding entry
Added validation to function 'mnt_table_add_fs()' to check that added @fs
is not already a member of another table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 11:50:52 +01:00
Karel Zak 189a1bf3b3 libmount: add support for MS_REMOUNT on --all
This patch add to support for remount-all operation to
libmount and mount(8).

For example:
	mount --all -o remount,ro -t vfat

to remount read-only all VFAT filesystems.

Addresses: https://github.com/karelzak/util-linux/issues/589
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-16 15:00:07 +01:00
Karel Zak 2859592ecb libmount: (umount) make mnt_stat_mountpoin() usable for relative paths
# mount -o loop devicefile /mnt/test
 # umount devicefile
 umount: devicefile: not mounted.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653781
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-10 16:25:08 +01:00
Karel Zak 1dae161c83 libmount: export mnt_guess_system_root() by API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-10 11:39:08 +01:00
Karel Zak df61216c67 libmount: (fuse) follow only user_id= on umount
The option user= is already handled by evaluate_permissions() and by
classic mount and umount usermount support. It seems we do not need
to duplicate support for user= in is_fuse_usermount().

The option user_id= is fuse specific and it's maintained by
libfuse/kernel in /proc/self/mountinfo. This is feature we need to
support in umount(8).

Addresses: https://github.com/karelzak/util-linux/pull/705
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-30 10:25:04 +01:00
Rian Hunter 5fea669e9e libmount: Support unmount FUSE mounts
FUSE mounts don't need an fstab entry to be unmounted.
This checks if a mount is a FUSE mount before checking for
the fstab entry, and if so returns success.

[kzak@redhat.com: - use libmount tools for mount options
                  - use namespace switches
                  - cleanup code

 The requirement is user=<username> or user_id=<uid> in /proc/self/mountinfo
 for fuse filesystem. The logic is the same as for user= mount options, but in
 this case it is not maintained by libmount in userspace, but by fuse FS in kernel.]

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-30 10:25:04 +01:00
Karel Zak 4f7acf32b5 libmount: keep namespaces support optional
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-05 11:35:45 +02:00
Karel Zak 71c7d37bc4 docs: fix gtkdoc warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-24 11:21:09 +02:00
Karel Zak 2c37ca7c4b libmount: cleanup licenses sections in the files
* add SPDX-License-Identifier (see https://spdx.org/licenses/)
* add "This file part of libmount from util-linux project."
* use proper text for LGPL-2.1-or-later
* use the same texts everywhere

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 15:43:53 +02:00
Karel Zak 4189907e6c docs: use SPDX license names
Let's use standardized names for licenses. The names used by SPDX
makes things more obvious at first glance. For complete list see:
https://spdx.org/licenses/

Note, this commit does not change any license or so...

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 14:47:21 +02:00
Karel Zak 51d5109782 libmount: report context paths on debug
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-14 21:03:42 +02:00
Karel Zak 9c566fce79 libmount: (utils) fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:58:57 +02:00
Karel Zak b00dd55ac8 libmount: fix compiler warning [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:33:13 +02:00
Karel Zak 78c66fc61d lib/mangle: const quialifier cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 15:31:42 +02:00
Karel Zak ea927bde6b libmount: cleanup const in umount code
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 14:15:42 +02:00
Karel Zak a679b0823f libmount: add missing const
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:51:52 +02:00
Karel Zak 0d1e744c20 libmount: use const char in swaps parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:49:08 +02:00
Karel Zak 4e4c9629e6 libmount: use const char in mountinfo parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:48:09 +02:00
Karel Zak 4ccc64c4ca libmount: use const char in fstab parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:44:53 +02:00
Karel Zak fae8328928 libmount: add since tag for new functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-19 11:38:48 +02:00
Karel Zak 4f9d999a97 build-sys: add -Wno-cast-function-type for python
libmount/python/pylibmount.c:158:19: warning: cast between incompatible function types
   from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’}
     to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’}
   [-Wcast-function-type]

This is generic problem in all Python C code and gcc v8. The another
possible (and probably more correct) way is to add unused argument to
all API functions. Unfortunately, this solution is pretty invasive. The
question is if gcc is not too paranoid in this case.

For more details see https://bugs.python.org/issue33012. It seems
Python guys also prefer CFLAGS modification for now.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 10:23:51 +02:00
Frank Schaefer 8a12ab5775 * break up large strings for PySys_WriteStdout() 2018-07-10 20:21:02 -05:00
Alban Crequy 18a52a5094 libmount: (mountinfo) parse empty strings in source
The source of a mount in /proc/self/mountinfo can unfortunately be an
empty string. Before this patch, 'mount' and 'mountpoint' fail as
following:

  $ sudo mount -t tmpfs "" /tmp/bb
  $ mount
  mount: /proc/self/mountinfo: parse error at line 64 -- ignored
  $ mountpoint /tmp/bb
  /tmp/bb is not a mountpoint

This patch fixes the parsing. It is unfortunately more complex because
sscanf() does not handle fields with empty strings easily.

Other projects have their own parser for mountinfo and have similar
issues. I know of runc and runtime-tools (I'll send a patch for those
two) but there are probably others.

Signed-off-by: Alban Crequy <alban@kinvolk.io>
2018-07-10 13:48:38 +02:00
Vaclav Dolezal cddd2eaa27 libmount: switch namespace when appropriate
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:12:55 +02:00