Skip to content

Commit

Permalink
Fix #309: Do not try to chown() cache dir or pidfile dir
Browse files Browse the repository at this point in the history
Users that want to drop-privs must ensure the cache and pidfile
directories are writable by the -p uid:gid specified.

Signed-off-by: Joachim Nilsson <[email protected]>
  • Loading branch information
troglobit committed Apr 26, 2020
1 parent c349fa8 commit a3616bf
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ int os_check_perms(void)
if ((mkpath(cache_dir, 0755) && errno != EEXIST) || access(cache_dir, W_OK)) {
logit(LOG_WARNING, "No write permission to %s: %s", cache_dir, strerror(errno));
logit(LOG_WARNING, "Cannot guarantee DDNS server won't lock you out for excessive updates.");
} else if (chown(cache_dir, uid, gid))
logit(LOG_WARNING, "Cannot change owner of cache directory %s to %d:%d, skipping: %s",
cache_dir, uid, gid, strerror(errno));
}

/* Handle --no-pidfile case as well, check for "" */
if (pidfile_name && pidfile_name[0]) {
Expand All @@ -264,10 +262,6 @@ int os_check_perms(void)
if (access(pidfile_dir, F_OK)) {
if (mkpath(pidfile_dir, 0755) && errno != EEXIST)
logit(LOG_ERR, "No write permission to %s, aborting.", pidfile_dir);
else if (chown(pidfile_dir, uid, gid))
logit(LOG_WARNING,
"Cannot change owner of PID file directory %s to %d:%d, skipping: %s",
pidfile_dir, uid, gid, strerror(errno));
}
}

Expand Down

0 comments on commit a3616bf

Please sign in to comment.