base: Do support /dev/null as a config file

This commit is contained in:
Nicolas Williams
2023-05-27 16:27:30 -05:00
parent 9cbafd7320
commit bc4e6591af

View File

@@ -535,6 +535,22 @@ heim_config_parse_dir_multi(heim_context context,
return 0;
}
static int
is_devnull(struct stat *st)
{
#ifdef WIN32
return 0;
#else
struct stat devnullst;
if (stat("/dev/null", &devnullst) == -1)
return 0;
return st->st_dev == devnullst.st_dev && st->st_ino == devnullst.st_ino;
#endif
}
HEIMDAL_THREAD_LOCAL int config_include_depth = 0;
/**
* Parse a configuration file and add the result into res. This
* interface can be used to parse several configuration files into one
@@ -548,8 +564,6 @@ heim_config_parse_dir_multi(heim_context context,
* @ingroup heim_support
*/
HEIMDAL_THREAD_LOCAL int config_include_depth = 0;
heim_error_code
heim_config_parse_file_multi(heim_context context,
const char *fname,
@@ -630,7 +644,7 @@ heim_config_parse_file_multi(heim_context context,
goto out;
}
if (!S_ISREG(st.st_mode)) {
if (!S_ISREG(st.st_mode) && !is_devnull(&st)) {
(void) fclose(f.f);
heim_set_error_message(context, EISDIR, "not a regular file %s: %s",
fname, strerror(EISDIR));