summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab_parse.c
diff options
context:
space:
mode:
authorKarel Zak2016-04-14 14:26:54 +0200
committerKarel Zak2016-04-14 14:26:54 +0200
commite778642a9eb96975fcf3baa61dfa10add628af1a (patch)
treebcd1f5f3030d19b56755abcbf71a3420e36bedcc /libmount/src/tab_parse.c
parentbuild-sys: add --enable-libuuid-force-uuidd (diff)
downloadkernel-qcow2-util-linux-e778642a9eb96975fcf3baa61dfa10add628af1a.tar.gz
kernel-qcow2-util-linux-e778642a9eb96975fcf3baa61dfa10add628af1a.tar.xz
kernel-qcow2-util-linux-e778642a9eb96975fcf3baa61dfa10add628af1a.zip
libmount: don't support /etc/mtab by default
The file mtab is evil and already unused by mainstream distributions. Now libmount is able to detect mtab->/proc/mounts and use /proc/self/mountinfo if necessary. This heuristic seems overkill in many cases. It's also dangerous on systems where mountinfo is strongly required (systemd based distros). This patch #ifdefs mtab code and forces libmount to always use /proc/self/mountinfo. The new configure option --enable-libmount-support-mtab is necessary to enable old behavior to support mtab. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_parse.c')
-rw-r--r--libmount/src/tab_parse.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 23076bfc0..3253db714 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -679,7 +679,7 @@ err:
* @tb: tab pointer
* @filename: file
*
- * Parses the whole table (e.g. /etc/mtab) and appends new records to the @tab.
+ * Parses the whole table (e.g. /etc/fstab) and appends new records to the @tab.
*
* The libmount parser ignores broken (syntax error) lines, these lines are
* reported to the caller by the errcb() function (see mnt_table_set_parser_errcb()).
@@ -1051,6 +1051,8 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
return fs;
}
+/* default filename is /proc/self/mountinfo
+ */
int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
struct libmnt_table *u_tb)
{
@@ -1058,9 +1060,7 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
assert(tb);
-#ifdef USE_LIBMOUNT_FORCE_MOUNTINFO
- DBG(TAB, ul_debugobj(tb, "mtab parse: ignore %s", filename ? filename : "mtab"));
-#else
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
if (mnt_has_regular_mtab(&filename, NULL)) {
DBG(TAB, ul_debugobj(tb, "force mtab usage [filename=%s]", filename));
@@ -1085,15 +1085,19 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
* useless /etc/mtab
* -- read kernel information from /proc/self/mountinfo
*/
- tb->fmt = MNT_FMT_MOUNTINFO;
- rc = mnt_table_parse_file(tb, _PATH_PROC_MOUNTINFO);
+ tb->fmt = filename ? MNT_FMT_GUESS : MNT_FMT_MOUNTINFO;
+ rc = mnt_table_parse_file(tb, filename ? filename : _PATH_PROC_MOUNTINFO);
if (rc) {
/* hmm, old kernel? ...try /proc/mounts */
tb->fmt = MNT_FMT_MTAB;
return mnt_table_parse_file(tb, _PATH_PROC_MOUNTS);
}
+ if (!is_mountinfo(tb))
+ return 0;
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
read_utab:
+#endif
DBG(TAB, ul_debugobj(tb, "mtab parse: #2 read utab"));
if (mnt_table_get_nents(tb) == 0)
@@ -1139,7 +1143,7 @@ read_utab:
/**
* mnt_table_parse_mtab:
* @tb: table
- * @filename: overwrites default (/etc/mtab or $LIBMOUNT_MTAB) or NULL
+ * @filename: overwrites default or NULL
*
* This function parses /etc/mtab or /proc/self/mountinfo +
* /run/mount/utabs or /proc/mounts.