diff --git a/nslcd/cfg.c b/nslcd/cfg.c index 55fb3c4..9907cef 100644 --- a/nslcd/cfg.c +++ b/nslcd/cfg.c @@ -1161,6 +1161,25 @@ static void check_file(const char *filename, int lnr, } } +/* check whether the specified path is a file or a character device */ +static void check_file_or_chardev(const char *filename, int lnr, + const char *keyword, const char *path) +{ + struct stat sb; + if (stat(path, &sb)) + { + log_log(LOG_ERR, "%s:%d: %s: cannot stat() %s: %s", + filename, lnr, keyword, path, strerror(errno)); + exit(EXIT_FAILURE); + } + if (!S_ISCHR(sb.st_mode) && !S_ISREG(sb.st_mode)) + { + log_log(LOG_ERR, "%s:%d: %s: %s is not a file or a character device", + filename, lnr, keyword, path); + exit(EXIT_FAILURE); + } +} + /* check whether the specified path is a directory */ static void check_dir(const char *filename, int lnr, const char *keyword, const char *path) @@ -1501,7 +1520,7 @@ static void cfg_read(const char *filename, struct ldap_config *cfg) { value = get_strdup(filename, lnr, keyword, &line); get_eol(filename, lnr, keyword, &line); - check_file(filename, lnr, keyword, value); + check_file_or_chardev(filename, lnr, keyword, value); log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_RANDOM_FILE,\"%s\")", value); LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_RANDOM_FILE, value);