Linux kernel does not allow to change more than one propagation flag
by one mount(2) syscall. The flags also cannot be mixed with another
mount options. It means that the propagation flags cannot be stored in
/etc/fstab, manual "mount --make-* <mountpoint>" is always necessary
after successful mount. Painful...
This patch implements additional mount(2) after previous successful
mount(2) (or exec /sbin/mount.<type>).
For example:
mount /dev/sda1 /A -o private,unbindable,ro
or fstab entry:
/dev/sda1 /A auto ro,private,unbindable
is implemented by three mount(2) calls:
- 1st mounts /dev/sda1 with MS_RDONLY
- 2nd sets MS_PRIVATE flag
- 3rd sets MS_UNBINDABLE flag.
It's the same as as to manually call:
mount /dev/sda1 /A -o ro
mount --make-private /A
mount --make-unbindable /A
This solution is not atomic, and umount(2) is not called if
propagation flags are not successfully applied, only error is
returned.
This change does not affect libmount API, so one beautiful day when
mount(2) syscall will be improved we can drop this nasty patch.
Signed-off-by: Karel Zak <kzak@redhat.com>
The --target <non-mount-point> functionality should be enabled only if
previous regular search found nothing to avoid collisions with bind
mounts, because to detect mountpoint we use traditional child / parent
stat.st_dev comparison which does not work for bind mounts (--bind /A
/A).
Signed-off-by: Karel Zak <kzak@redhat.com>
[kzak@redhat.com: - rename struct member and functions from
"propagation" to "optional fields"
- split the original patch
- fix parser]
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
To fix 'make distcheck' compilation. The fdisks/Makemodule.am has one
new entry 'dos_part_types.h', the rest is about sorting the list.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Btrfs has three superblock. The first one is placed at 64KB, the second one at
64MB, the third one at 256GB.
If the first superblock is valid except that the "magic field" is zeroed, btrfs
skips the check of the other superblocks. If the first superblock is fully
invalid, btrfs checks for the other superblock.
So zeroing the first superblock "magic field" at the beginning seems that the
filesystem is wiped. But when the first superblock is overwritten (eg by
another filesystem), then the other two superblock may be considered valid, and
the filesystem may resurrect.
This patch allow to find and wipe the other btrfs superblocks signature.
Signed-off-by: Karel Zak <kzak@redhat.com>
If the target directory (mountpoint) does not exist then mount(8) will create
it before mount.<type> is executed or mount(2) syscall is called.
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Presently, libmount-mount completely prohibits the use of -t by non-root
users. This breaks using -t in listing mode as a user, which represents
a regression against mount-deprecated, macosx and presumably *BSD.
This commit fixes the issue by deferring the mnt_context_is_restricted
check for -t until we know we're not in listing mode.
Signed-off-by: Rich Tollerton <rich.tollerton@ni.com>
sys-utils/losetup.c:309:2: error: 'for' loop initial declarations are only allowed in C99 mode
sys-utils/losetup.c:374:2: error: 'for' loop initial declarations are only allowed in C99 mode
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The current examples miss the best usage of all: specifying the command
and its arguments directly on the command line. Add that to both the
program usage and the man page.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c. Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.
[kzak@redhat.com: use macro rather than global variable for default
chardata]
Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
We use the code from include/ and lib/ on many places, so use public
domain if possible or LGPL for code copied from libs.
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's make it more obvious if swap area is accessible for non-root
users. The old version prints the warning only if --verbose is
specified.
Reported-by: mp.lists@free.fr
Signed-off-by: Karel Zak <kzak@redhat.com>
In addition to the unshare syscall, there exists the setns syscall, which
allows processes to migrate to the namepsaces of other processes. Add this
functionality into the unshare command, as they operate in a fairly simmilar
fashion.
Note: There was discussion of adding a path based namespace argument to unshare
in the origional discussion thread, but I opted to leave that out as it didn't
seem to fit in nicely with the current argument pattern. I figure we can always
add that in later if we need to
[kzak@redhat.com: - fix optional arguments
- do not call unshare if no flag specified
- use O_CLOEXEC
- codding style cleanup]
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
We're not Russian roulette players, so don't use such ugly things at all..
Reported-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
- move struct chardata to include/ttyutils.h
- move console.{h,c} to login-utils/sulogin-* (it's sulogin specific)
- fix sulogin and agetty includes
Signed-off-by: Karel Zak <kzak@redhat.com>