From 1baf694356a64c900d241a069e36529dd65fc679 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Sat, 9 Feb 2013 20:49:56 +0100 Subject: Use access to ensure readability of config gile This patch adds a call to access to check the readability of the configuration file. --- src/conffile.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/conffile.c') diff --git a/src/conffile.c b/src/conffile.c index dd0ed8f..616d7a9 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -16,9 +16,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include #include +#include /* points to config entry with error */ @@ -89,10 +91,17 @@ static char *get_word(char *line, char *not, char *buf) /* register config file with us */ int config_register_file(const char *file) { - /* FIXME: stat of file */ if (fname) return 1; + if (access(file, R_OK) != 0) { + ulogd_log(ULOGD_ERROR, + "unable to read configfile \"%s\": %s\n", + file, + strerror(errno)); + return 1; + } + pr_debug("%s: registered config file '%s'\n", __func__, file); fname = (char *) malloc(strlen(file)+1); -- cgit v1.2.3