| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current libmount MS_REMOUNT|MS_BIND support is restricted to
MS_RDONLY (read-only bind mount). This is too restrictive as Linux
kernel supports bind-remount for arbitrary VFS flags.
After this update you can use
# mount /dev/sdc1 /mnt/A
# mount --bind -onosuid,noexec /mnt/A /mnt/B
# findmnt /dev/sdc1 -oTARGET,SOURCE,FS-OPTIONS,VFS-OPTIONS
TARGET SOURCE FS-OPTIONS VFS-OPTIONS
/mnt/A /dev/sdc1 rw,stripe=512,data=ordered rw,relatime
/mnt/B /dev/sdc1 rw,stripe=512,data=ordered rw,nosuid,noexec,relatime
The "mount --bind" is composed from two syscalls of course (1st is
bind, 2nd is bind,remount,nosuid,noexec).
Addresses: https://github.com/karelzak/util-linux/issues/637
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
| |
Reported-by: L A Walsh <lkml@tlinx.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When you bind-mount a subdirectory of a local filesystem, the
path to that subdirectory appears as the fourth field in mountinfo.
For nfs mounts, the fourth field is always "/", and the subdirectory
part is appended to the "special" (aka "device") field. This is
consistent with historical NFS usage which always includes a path in
the fs_spec field.
libmount needs to know about this when "mount -a" checks to see if
a filesystem is already mounted.
Without this fix, fstab lines like:
server::/path /dir nfs defaults 0 0
/dir/subdir /mnt/test none bind 0 0
result in a new mount at /mnt/test every time "mount -a" is run.
[kzak@redhat.com: - use strappend() rather than asprintf()]
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
| |
mnt_context_get_mtab() doesn't set its return **tb argument on error,
and so in mnt_context_next_umount() mtab will remain uninitialized on
error, later resulting in cxt->mtab containing garbage, possibly
resulting in segfault on exit.
|
|
|
|
|
| |
Addresses: https://github.com/systemd/systemd/issues/8507
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
| |
Addresses: https://github.com/karelzak/util-linux/issues/599
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
| |
Addresses: https://github.com/karelzak/util-linux/issues/596
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
Let's include sys/mount.h to be sure that our local libmount fallbacks
are not used by default to avoid possible conflicts with later included
sys/mount.h.
Addresses: https://github.com/systemd/systemd/pull/8452
Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The command "mount -a -t <pattern>" uses the -t as pattern to filter
fstab entries. And "mount -t <type>" is used to specify FS type.
Unfortunately libmount does not care about this difference when it
calls standard mount functionality. The original pattern is still in
the library control struct and mnt_do_mount() tries to use it as FS
type.
This patch is just bugfix. Maybe the long term solution would be to
differentiate between the pattern and type in the library API. Now the
library follows mount(8) command line and it's little bit messy.
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
| |
Some more funny typos, please review carefully.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
| |
From libs where suid program may be executed by non-root user.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
| |
The sources of AC_CONFIG_FILES (*.in) are automatically
distributed.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
|
|
|
| |
Use EXTRA_prog_DEPENDENCIES to have the benefit
of automake's automatic prog_DEPENDENCIES.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
|
|
|
|
|
|
| |
We have already automakes's automatic dependencies like
bla.h.in -> bla.h -> foo.o -> bar.la
An explicit direct dependency bla.h.in -> bar.la
is redundant and useless anyways.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
| |
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Headers should only be listed in either *_HEADERS or
*_SOURCES, especially when we want nodist_*_HEADERS.
Since all the generated headers are made by configure we
don't even need to use BUILT_SOURCES or other tricks.
Also see automake docs 9.4.1 Built Sources Example:
case "Build bindir.h from configure"
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
|
|
|
| |
Let's make it possible to use debug.h without environment variables.
Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing
* use __UL_DEBUG_FL_NOADDR when SUID
* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
to provide access to the current mask from ul_debugobj(). It's better
than modify all ul_debugobj() calls and use the global mask as
argument.
* remove never used UL_DEBUG_DEFINE_FLAG
Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is no difference between "bind" and "rbind" if we want to FS
root to search for the FS in mountinfo file.
fstab:
/dev/sdc1 /mnt/foo xfs defaults 0 0
/mnt/foo /mnt/test none rw,rbind 0 0
use -a more than once:
mount -a
mount -a
/proc/mounts (the current result):
/dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0
/dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0
/dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0
/dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0
expected (fixed version) result:
/dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0
/dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1528959
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
utimensat() is pretty expensive when mounting parallel filesystems from
the same source. It's possible to ignore all this if mtab is not
writable.
Note that this change is irrelevant for default util-linux builds
where all around mtab is already disabled since v2.30 (commit
89958178f6d6ebe0944d423feaea66be521fff43).
This change is relevant only for users who still use --enable-libmount-support-mtab.
Reported-by: Douglas Jacobsen <dmjacobsen@lbl.gov>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The commit c08396c7691e1e6a04b6b45892e7e4612ceed8d7 replaces
open(O_CREATE) with ecaccess(). Unfortunately, another code depends on
the original behavior.
* let's make utab when really necessary rather than in the try_write() test
* __mnt_new_table_from_file() returns NULL if tab-file does not
exists. This is incorrect for tab_update.c stuff. We need empty table
in this case.
* we can check /run/mount/ directory for write access if
eaccess(filename) return ENOENT (because file does not exist)
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
| |
MNT_FORCE and MNT_DETACH are orthogonal in the Linux kernel, so both may
be specified without any problems. Even if there were a problem with
this combination, it should be up to the kernel to take the correct
action or report an error.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Using wait() in a library may be problematic as it may reap some
totally unrelated child process instead of the just forked
one. That can result in the library call doing weird things and
returning bad return values, but also in a breakage of an
arbitrary other thing in the program using the library.
[[kzak@redhat.com: - use waitpid() for umount too
- keep the current codding style]
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
| |
The open() syscall is probably the most strong way how to check write
accessibility in all situations, but it's overkill and on some
paranoid systems with enabled audit/selinux. It fills logs with
"Permission denied" entries. Let's use eaccess() if available.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
| |
mount: /media/sdb5: mount(2) system call failed: Bad message.
is really ugly for end users. It seems XFS, extN (etc) use EBADMSG for
bad checksums. For network or pseudo filesystems continue to use "Bad
message" error...
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1496764
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The mount man page assumes locking errors mapped to MNT_EX_FILEIO (16)
return code. Unfortunately, this is internally not exported as a
special error code, so it's returned as a generic (errno based)
stuff. This patch fixes this issue.
Note that we still use locking for example for utab or when enabled
/etc/mtab (disabled by default).
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
| |
We've added UUID_LIBS in f77a4d1087 but I don't see what it
was good for.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Assume that /proc is not mounted instead of returning an error when we
are unable to open the mounts and mountinfo files in /proc. Also set
cxt->mtab back to NULL so that it gets properly parsed when we check if
the next filesystem is mounted.
The goal is to have mount -a work when /proc is not mounted, typically
with /proc on the first line of fstab.
Signed-off-by: Ivan Delalande <colona@arista.com>
|
|
|
|
|
|
|
| |
The originally used exit() is bad idea for the shared library.
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current code always apply all flags from /etc/fstab on remount.
Unfortunately remount+bind has special semantic and it's impossible
from command line to avoid interaction with the "bind" from fstab.
Example, fstab:
/dev/sda1 /bar ext4 defaults 0 1
/bar /foo none bind 0 0
Command line:
# mount /foo -o remount,rw
produces:
mount(... MS_REMOUNT|MS_BIND ) syscall
This changes the per-mountpoint (VFS) ro flag to rw, but doesn't
change the filesystem itself.
This patch forces libmount to ignore "bind" from fstab when "-o
remount" specified on command line. If you need remount+bind semantic
you have to specify the "bind" flag on command line. This allow to
differentiate between
# mount /foo -o remount,bind,rw --> mount(MS_REMOUNT|MS_BIND)
and
# mount /foo -o remount,rw --> mount(MS_REMOUNT)
Suggested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
| |
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
|
|
| |
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
|
|
|
|
|
| |
We have never used them since introduced in 2cd28fc8.
clang compiler warned about it.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
|
|
|
| |
The path canonicalization is the worst use-case, it's better to read
all mount table than try canonicalize.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
| |
The umount command option --no-canonicalize means that the path is
already canonical. So, we can use mount table filter in this case too.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is currently not possible to reliably and automatically
unmount an NFS filesystem. If the server is not available, the
umount command will hang.
The hang can be avoided by using "-l" or "-f", but neither
of these are appropriate for automatic use such as by an
automounter (e.g automountd or systemd).
"-l" will unmount even if the filesystem is in use, which
an automounter generally doesn't want. If the filesystem
is in use, then the umount should fail.
"-f" can cause the filesystem to abort pending transactions
which might break filesystem semantics. This can be useful
in the hands of a sysadmin, but not when used by an
automatic tool.
umount has another option, "-c" aka "--no-canonicalize"
which avoids some "stat" calls.
Currently this doesn't avoid all calls to
canonicalize_path()
as
mnt_context_prepare_umount() ->
lookup_umount_fs() ->
mnt_context_find_umount_fs() ->
mnt_context_get_mtab_for_target() ->
mnt_resolve_path() ->
canonicalize_path_and_cache() ->
canonicalize_path()
leads to that function being called.
The "-c" option could be taken to mean "I know what I'm
doing, this really is the path to a mount point, I just want
you to unmount it". Given that, it seems suitable to
extend this to avoid all 'stat' calls on the mountpoint.
It is already appropriate for any automount program to pass
"-c" to "umount", so they can be changed to do so at any
time.
With the patch below, "-c" will result in the mountpoint
never being "stat"ed, so umount won't hang on an
inaccessible server.
This isn't quite sufficient, for NFS at least, as the usage
of libmount in umount.nfs still calls 'stat' on the mount
point.
"-c" isn't passed to the umount helper, but it is reasonable
for such helpers to assume "-c" because "umount" will have
canonicalized the path when that is appropriate.
So, this patch treats "-c" much like "-l" and "-f" when
deciding whether it is safe to 'stat' the path.
Signed-off-by: NeilBrown <neilb@suse.com>
|
|
|
|
|
|
|
|
|
|
| |
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:
./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
| |
Signed-off-by: Karel Zak <kzak@redhat.com>
|