From 45012651a32d3002f361932491765bcbaedc7b2a Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 6 Jan 2025 18:31:33 +0100 Subject: [PATCH] chown of a file that does not exist, is not really worth a warning. Only mention it when debug.config is true. Signed-off-by: DL6ER --- src/files.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/files.c b/src/files.c index cbc6daac9..7489dc77f 100644 --- a/src/files.c +++ b/src/files.c @@ -454,6 +454,11 @@ bool chown_pihole(const char *path, struct passwd *pwd) // Change ownership of file to pihole user if(chown(path, pwd->pw_uid, pwd->pw_gid) < 0) { + if(errno == ENOENT) // ENOENT = No such file or directory + { + log_debug(DEBUG_CONFIG, "File \"%s\" does not exist, not changing ownership", path); + return true; + } log_warn("Failed to change ownership of \"%s\" to %s:%s (%u:%u): %s", path, pwd->pw_name, grp_name, pwd->pw_uid, pwd->pw_gid, errno == EPERM ? "Insufficient permissions (CAP_CHOWN required)" : strerror(errno));