commit: b2c92b88cc6ce6d81444667efbc6d44542db1788 Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> AuthorDate: Tue Jun 7 09:31:48 2016 +0000 Commit: William Hubbs <williamh <AT> gentoo <DOT> org> CommitDate: Fri Jun 10 22:16:37 2016 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b2c92b88
fstabinfo/mountinfo: ensure /etc/fstab exists before calling setmntent This is based on a patch by A. Wilcox <awilfox.gentoo <AT> 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 src/rc/fstabinfo.c | 3 +++ src/rc/mountinfo.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c index bd2372d..75c8bc2 100644 --- a/src/rc/fstabinfo.c +++ b/src/rc/fstabinfo.c @@ -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"); diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c index 10e3238..29eb160 100644 --- a/src/rc/mountinfo.c +++ b/src/rc/mountinfo.c @@ -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)