This reverts commit
44fc841929934a55f690422ee1d25c3190c5c900.
stat() is not the same as fstat(). The first one checks a
file which has the same name as the one we opened. The second
checks the file which we just opened.
The cf_file_input() checks just check if the filename for
security (globally writeable, etc.). cf_file_open() will
open the file and read it's contents
CONF_DATA *cd;
CONF_SECTION *top;
rbtree_t *tree;
+ int fd;
FILE *fp;
top = cf_top_section(cs);
return NULL;
}
+ fd = fileno(fp);
+
file = talloc(tree, cf_file_t);
if (!file) {
fclose(fp);
file->cs = cs;
file->input = true;
- if (stat(filename, &file->buf) < 0) {
+ if (fstat(fd, &file->buf) == 0) {
#ifdef S_IWOTH
if ((file->buf.st_mode & S_IWOTH) != 0) {
ERROR("Configuration file %s is globally writable. "
if (!cd) return false;
tree = cd->data;
+
file = talloc(tree, cf_file_t);
if (!file) return false;