mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-08-04 02:15:58 -04:00
main: add checks for valid /proc mount
since fuse-overlayfs needs a writeable /proc mount, add some checks to validate it. Closes: https://github.com/containers/fuse-overlayfs/issues/137 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
f87e1781a8
commit
0988e9bc39
31
main.c
31
main.c
@ -37,7 +37,9 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <linux/magic.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <sys/vfs.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#ifdef HAVE_SYS_SENDFILE_H
|
#ifdef HAVE_SYS_SENDFILE_H
|
||||||
# include <sys/sendfile.h>
|
# include <sys/sendfile.h>
|
||||||
@ -291,6 +293,34 @@ inode_to_node (struct ovl_data *lo, ino_t n)
|
|||||||
return lookup_inode (lo, n)->node;
|
return lookup_inode (lo, n)->node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_writeable_proc ()
|
||||||
|
{
|
||||||
|
struct statvfs svfs;
|
||||||
|
struct statfs sfs;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = statfs ("/proc", &sfs);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "error stating /proc: %m\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sfs.f_type != PROC_SUPER_MAGIC)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "invalid file system type found on /proc: %m\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (svfs.f_flag & ST_RDONLY)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "/proc seems to be mounted as readonly, it can lead to unexpected failures");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_can_mknod (struct ovl_data *lo)
|
check_can_mknod (struct ovl_data *lo)
|
||||||
{
|
{
|
||||||
@ -5617,6 +5647,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
set_limits ();
|
set_limits ();
|
||||||
check_can_mknod (&lo);
|
check_can_mknod (&lo);
|
||||||
|
check_writeable_proc ();
|
||||||
|
|
||||||
if (lo.debug)
|
if (lo.debug)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user