diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/irmd/oap/io.c | 8 | ||||
| -rw-r--r-- | src/lib/crypt.c | 11 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/irmd/oap/io.c b/src/irmd/oap/io.c index 5c560ea5..7b661435 100644 --- a/src/irmd/oap/io.c +++ b/src/irmd/oap/io.c @@ -50,11 +50,17 @@ static bool file_exists(const char * path) { struct stat s; - if (stat(path, &s) < 0 && errno == ENOENT) { + if (stat(path, &s) == 0) + return true; + + if (errno == ENOENT) { log_dbg("File %s does not exist.", path); return false; } + /* Can't stat for another reason; assume present, fail on load */ + log_warn("Failed to stat %s: %s.", path, strerror(errno)); + return true; } diff --git a/src/lib/crypt.c b/src/lib/crypt.c index 73cb0b51..9728ac8c 100644 --- a/src/lib/crypt.c +++ b/src/lib/crypt.c @@ -265,12 +265,17 @@ int load_sec_config_file(struct sec_config * cfg, fp = fopen(path, "r"); if (fp == NULL) { - /* File doesn't exist - disable encryption */ - CLEAR_KEX_ALGO(cfg); - return 0; + /* Absent config disables encryption; other errors fail */ + if (errno == ENOENT) { + CLEAR_KEX_ALGO(cfg); + return 0; + } + return -errno; } + pthread_cleanup_push(__cleanup_fclose, fp); ret = parse_sec_config(cfg, fp); + pthread_cleanup_pop(0); fclose(fp); |
