diff options
author | Lukas Czerner <lczerner@redhat.com> | 2022-08-12 15:01:22 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2022-08-12 22:32:14 -0400 |
commit | 18ebcf26f478702cd09dd4229320d449469f1490 (patch) | |
tree | e26859b9e05fee3451224f5d5a28efcb62a55138 /debugfs | |
parent | 64d576a89959bfdcf5415be2c36c06549562cbb2 (diff) | |
download | e2fsprogs-18ebcf26f478702cd09dd4229320d449469f1490.tar.gz |
e2fsprogs: fix device name parsing to resolve names containing '='
Currently in varisous e2fsprogs tools, most notably tune2fs and e2fsck
we will get the device name by passing the user provided string into
blkid_get_devname(). This library function however is primarily intended
for parsing "NAME=value" tokens. It will return the device matching the
specified token, NULL if nothing is found, or copy of the string if it's
not in "NAME=value" format.
However in case where we're passing in a file name that contains an
equal sign blkid_get_devname() will treat it as a token and will attempt
to find the device with the match. Likely finding nothing.
Fix it by checking existence of the file first and then attempt to call
blkid_get_devname(). In case of a collision, notify the user and
automatically prefer the one returned by blkid_get_devname(). Otherwise
return either the existing file, or NULL.
We do it this way to avoid some existing file in working directory (for
example LABEL=volume-name) masking an actual device containing the
matchin LABEL. User can specify full, or relative path (e.g.
./LABEL=volume-name) to make sure the file is used instead.
Link: https://lore.kernel.org/r/20220812130122.69468-1-lczerner@redhat.com
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Daniel Ng <danielng@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'debugfs')
0 files changed, 0 insertions, 0 deletions