Skip to content

Commit

Permalink
fstabinfo/mountinfo: ensure /etc/fstab exists before calling setmntent
Browse files Browse the repository at this point in the history
This is based on a patch by A. Wilcox <awilfox.gentoo@foxkit.us>.

X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226

X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226
  • Loading branch information
williamh committed Jun 10, 2016
1 parent 1b32af1 commit b2c92b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/rc/fstabinfo.c
Expand Up @@ -178,6 +178,9 @@ int main(int argc, char **argv)
FILE *fp;
#endif

/* fail if there is no /etc/fstab */
if (!exists("/etc/fstab"))
eerrorx("/etc/fstab does not exist");
/* Ensure that we are only quiet when explicitly told to be */
unsetenv("EINFO_QUIET");

Expand Down
3 changes: 3 additions & 0 deletions src/rc/mountinfo.c
Expand Up @@ -297,6 +297,9 @@ getmntfile(const char *file)
struct mntent *ent = NULL;
FILE *fp;

if (!exists("/etc/fstab"))
return NULL;

fp = setmntent("/etc/fstab", "r");
while ((ent = getmntent(fp)))
if (strcmp(file, ent->mnt_dir) == 0)
Expand Down

0 comments on commit b2c92b8

Please sign in to comment.