It might be useful for security auditing purposes list all possible
mount flags/options including default set which are normally not listed.
This patch adds "--vfs-all" option to list all fs-independent flags
on VFS-OPTIONS column, as well as libmount funcionality to accomplish
it.
i.e.:
$ findmnt -o VFS-OPTIONS
VFS-OPTIONS
rw,relatime
rw,nosuid,nodev,noexec,relatime
rw,nosuid,nodev,noexec,relatime
ro,nosuid,nodev,noexec
...
$ findmnt --vfs-all -o VFS-OPTIONS
VFS-OPTIONS
rw,exec,suid,dev,async,loud,nomand,atime,noiversion,diratime,relatime,nostrictatime,nolazytime,symfollow
rw,noexec,nosuid,nodev,async,loud,nomand,atime,noiversion,diratime,relatime,nostrictatime,nolazytime,symfollow
rw,noexec,nosuid,nodev,async,loud,nomand,atime,noiversion,diratime,relatime,nostrictatime,nolazytime,symfollow
ro,noexec,nosuid,nodev,async,loud,nomand,atime,noiversion,diratime,norelatime,nostrictatime,nolazytime,symfollow
...
[kzak@redhat.com: - cleanup coding style and comments]
Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
mnt_fs_get_userdata
mnt_fs_get_user_options
mnt_fs_get_vfs_options
+mnt_fs_get_vfs_options_all
mnt_fs_is_kernel
mnt_fs_is_netfs
mnt_fs_is_pseudofs
return fs ? fs->vfs_optstr : NULL;
}
+/**
+ * mnt_fs_get_vfs_options_all:
+ * @fs: fstab/mtab entry pointer
+ *
+ * Returns: pointer to newlly allocated string (can be freed by free(3)) or
+ * NULL in case of error. The string contains all (including defaults) mount
+ * options.
+ */
+char *mnt_fs_get_vfs_options_all(struct libmnt_fs *fs)
+{
+ const struct libmnt_optmap *map = mnt_get_builtin_optmap(MNT_LINUX_MAP);
+ const struct libmnt_optmap *ent;
+ const char *opts = mnt_fs_get_options(fs);
+ char *result = NULL;
+ unsigned long flags = 0;
+
+ if (!opts || mnt_optstr_get_flags(opts, &flags, map))
+ return NULL;
+
+ for (ent = map ; ent && ent->name ; ent++){
+ if (ent->id & flags) { /* non-default value */
+ if (!(ent->mask & MNT_INVERT))
+ mnt_optstr_append_option(&result, ent->name, NULL);
+ else
+ continue;
+ } else if (ent->mask & MNT_INVERT)
+ mnt_optstr_append_option(&result, ent->name, NULL);
+ }
+
+ return result;
+}
+
/**
* mnt_fs_get_user_options:
* @fs: fstab/mtab entry pointer
extern const char *mnt_fs_get_fs_options(struct libmnt_fs *fs);
extern const char *mnt_fs_get_vfs_options(struct libmnt_fs *fs);
extern const char *mnt_fs_get_user_options(struct libmnt_fs *fs);
+extern char *mnt_fs_get_vfs_options_all(struct libmnt_fs *fs);
extern const char *mnt_fs_get_attributes(struct libmnt_fs *fs);
extern int mnt_fs_set_attributes(struct libmnt_fs *fs, const char *optstr);
mnt_context_get_target_prefix;
mnt_context_set_target_prefix;
} MOUNT_2.34;
+
+MOUNT_2_37 {
+ mnt_fs_get_vfs_options_all;
+} MOUNT_2_35;
.TP
.B \-\-verbose
Force findmnt to print more information (\fB\-\-verify\fP only for now).
+.TP
+.B \-\-vfs-all
+When used with
+.BR VFS-OPTIONS
+column, print all VFS (fs-independent) flags. This option is designed for auditing purposes to
+list also default VFS kernel mount options which are normally not listed.
.SH ENVIRONMENT
.IP LIBMOUNT_FSTAB=<path>
overrides the default location of the fstab file
str = xstrdup(mnt_fs_get_options(fs));
break;
case COL_VFS_OPTIONS:
- if (mnt_fs_get_vfs_options(fs))
+ if (flags & FL_VFS_ALL)
+ str = mnt_fs_get_vfs_options_all(fs);
+ else if (mnt_fs_get_vfs_options(fs))
str = xstrdup(mnt_fs_get_vfs_options(fs));
break;
case COL_FS_OPTIONS:
fputc('\n', out);
fputs(_(" -x, --verify verify mount table content (default is fstab)\n"), out);
fputs(_(" --verbose print more details\n"), out);
+ fputs(_(" --vfs-all print all VFS options\n"), out);
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(24));
FINDMNT_OPT_TREE,
FINDMNT_OPT_OUTPUT_ALL,
FINDMNT_OPT_PSEUDO,
- FINDMNT_OPT_REAL
+ FINDMNT_OPT_REAL,
+ FINDMNT_OPT_VFS_ALL
};
static const struct option longopts[] = {
{ "tree", no_argument, NULL, FINDMNT_OPT_TREE },
{ "real", no_argument, NULL, FINDMNT_OPT_REAL },
{ "pseudo", no_argument, NULL, FINDMNT_OPT_PSEUDO },
+ { "vfs-all", no_argument, NULL, FINDMNT_OPT_VFS_ALL },
{ NULL, 0, NULL, 0 }
};
case FINDMNT_OPT_REAL:
flags |= FL_REAL;
break;
+ case FINDMNT_OPT_VFS_ALL:
+ flags |= FL_VFS_ALL;
+ break;
case 'h':
usage();
FL_VERBOSE = (1 << 16),
FL_PSEUDO = (1 << 17),
FL_REAL = (1 << 18),
+ FL_VFS_ALL = (1 << 19),
/* basic table settings */
FL_ASCII = (1 << 20),