aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-07-08 12:08:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-07-08 12:08:44 -0400
commit42b61c50e5af99a10fc56975ecd08ab71e4f00e8 (patch)
tree27a603914f3d5673a4653386b5597715e0652fa0
parent05958122453834079195230ff054cfd6073fbc98 (diff)
downloade2fsprogs-42b61c50e5af99a10fc56975ecd08ab71e4f00e8.tar.gz
e2fsprogs-42b61c50e5af99a10fc56975ecd08ab71e4f00e8.tar.xz
e2fsprogs-42b61c50e5af99a10fc56975ecd08ab71e4f00e8.zip
libext2fs, tests: allow /etc/mtab file to be missing
The environment variable EXT2FS_NO_MTAB_OK will suppress the error code EXT2_NO_MTAB_FILE when the /etc/mtab file can not be found. This allows the e2fsprogs regression test suite to be run in chroots which might not have an /etc/mtab file. By default will still want to complain if the /etc/mtab file is missing, since we really don't want to discourage distributions and purveyors of embedded systems from running without an /etc/mtab file. But if it's missing it only results in a missing sanity check that might cause file system corruption if the file system is mounted when programs such as e2fsck, tune2fs, or resize2fs is running, so there is no potential security problems that might result if this environment variable is set inappropriately. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--lib/ext2fs/ismounted.c11
-rw-r--r--tests/test_config2
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index 6a223df5..9bccc74d 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -53,8 +53,15 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
int fd;
*mount_flags = 0;
- if ((f = setmntent (mtab_file, "r")) == NULL)
- return (errno == ENOENT ? EXT2_NO_MTAB_FILE : errno);
+ if ((f = setmntent (mtab_file, "r")) == NULL) {
+ if (errno == ENOENT) {
+ if (getenv("EXT2FS_NO_MTAB_OK"))
+ return 0;
+ else
+ return EXT2_NO_MTAB_FILE;
+ }
+ return errno;
+ }
if (stat(file, &st_buf) == 0) {
if (S_ISBLK(st_buf.st_mode)) {
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
diff --git a/tests/test_config b/tests/test_config
index 36b53b7e..67896562 100644
--- a/tests/test_config
+++ b/tests/test_config
@@ -34,3 +34,5 @@ MKE2FS_CONFIG=./mke2fs.conf
export MKE2FS_CONFIG
E2FSPROGS_SKIP_PROGRESS=yes
export E2FSPROGS_SKIP_PROGRESS
+EXT2FS_NO_MTAB_OK=yes
+export EXT2FS_NO_MTAB_OK