Now the code only checks that /sys/.../dm/name exists, but never
verify the device node in /dev (because path prefix is never NULL).
The prefix is used to redirect hardcoded paths to /sys dumps (e.g.
lsblk regression tests, etc.)
This bug has been introduced in v2.33. Fortunately, it's probably no
big issue as /dev is always in sync with /sys (thanks to udevd).
Signed-off-by: Karel Zak <kzak@redhat.com>
Accessing FUSE mounts require suid/sgid (saved uid) to be equal to the
owner of the mount. If mount is running as a setuid process, swapping
creds by only setting the euid/egid isn't enough to change the
suid/sgid as well. We must do a full setuid()/setgid(), but that
removes our ability to re-assume the identity of the original
euid. The solution is swap creds in a child process, preserving the
creds of the parent.
[kzak@redhat.com: - use switch() rather than if() for fork
- use all-io.h
- close unused pipe[] ends
- be more strict about used types]
Addresses: https://github.com/karelzak/util-linux/pull/705
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/canonicalize.c: In function ‘canonicalize_dm_name’:
lib/canonicalize.c:42:45: warning: ‘%s’ directive output may be truncated
writing up to 255 bytes into a region of size 244 [-Wformat-truncation=]
snprintf(path, sizeof(path), "/dev/mapper/%s", name);
Notice that this warnign fix does not improve code enormously. The earlier
snprintf() truncation will not happen a bit earlier when fgets() is called.
In that sense this change merely makes one easy to silence warning to
disappear, and therefore improve change of noticing useful messaging as such
crops up.
[kzak@redhat.com: - use macro rather than hardcoded string for mapper path]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
The path canonicalization is expensive and in many cases unwanted due
to problems with readlink() on unreachable NFS and automounters.
This patch add a possibility to search also by $(CWD)/<path> if the
<path> is relative to reduce number of situation when we convert the
path to the canonical absolute path.
The common use-case:
# cd /some/long/path
# umount ./mountpoint
old version:
15543: libmount: TAB: [0x560a99a54230]: lookup TARGET: './test'
15543: libmount: CACHE: [0x560a99a54290]: canonicalize path ./test
15543: libmount: CACHE: [0x560a99a54290]: add entry [ 1] (path): /mnt/test: ./test
15543: libmount: TAB: [0x560a99a54230]: lookup canonical TARGET: '/mnt/test'
15543: libmount: CXT: [0x560a99a54050]: umount fs: /mnt/test
new version:
15597: libmount: TAB: [0xabf230]: lookup TARGET: './test'
15597: libmount: TAB: [0xabf230]: lookup absolute TARGET: '/mnt/test'
15597: libmount: CXT: [0xabf050]: umount fs: /mnt/test
Signed-off-by: Karel Zak <kzak@redhat.com>
The current code cares about filenames, but it's too fragile, we have
to check the path is really path to the block device.
Addresses: https://github.com/karelzak/util-linux/issues/83
Signed-off-by: Karel Zak <kzak@redhat.com>
.. after many many years it seems that we can follow libc code rather
than duplicate realpath(3) implementation.
Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/canonicalize.c: don't interpret empty strings as relative paths
* libmount: more robust libmnt_table find function and debug messages
References: https://bugzilla.novell.com/show_bug.cgi?id=825150
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
It's overkill to modify unknown paths in a generic function like
canonicalize_path().
for example:
mount -t fuse 'sshfs#marty@thee:/' /media/thee
will be canonicalized to
mount -t fuse 'sshfs#marty@thee:' /media/thee
and this obvious bug.
Reported-by: Martin Panter <vadmium+floss@gmail.com>
This reverts commit 28074a0952.
$ make checkincludes
fsck/fsck.c: errno.h is included more than once.
lib/canonicalize.c: string.h is included more than once.
shlibs/blkid/src/blkidP.h: stdio.h is included more than once.
shlibs/blkid/src/devname.c: string.h is included more than once.
shlibs/blkid/src/devno.c: string.h is included more than once.
Signed-off-by: Karel Zak <kzak@redhat.com>
* mount(8) uses private device-mapper names in mtab
* libblkid returns private device-mapper names when evaluate udev
/dev/disk-by symlinks.
* on systems where DM is fully integrated with udev the /dev/mapper/<name>
files are symlinks to /dev/dm-N. It means we need a special care to hide
private device-mapper names.
Signed-off-by: Karel Zak <kzak@redhat.com>