Skip to content

Commit

Permalink
chown of a file that does not exist, is not really worth a warning. O…
Browse files Browse the repository at this point in the history
…nly mention it when debug.config is true.

Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Jan 6, 2025
1 parent 5c21814 commit 4501265
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 4501265

Please sign in to comment.