Skip to content

Commit

Permalink
Only warn about chdir() to user home if no chroot is set
Browse files Browse the repository at this point in the history
The chroot will have its own chdir(), so we can ignore failures.
  • Loading branch information
roehling committed Aug 25, 2023
1 parent bc7fa88 commit 2a00354
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static bool drop_privileges(cfg_t* cfg)
}
target_uid = pwd->pw_uid;
target_gid = pwd->pw_gid;
if (chdir(pwd->pw_dir) < 0)
if (chdir(pwd->pw_dir) < 0 && EMPTY_STRING(chroot_dir))
{
log_warn("cannot chdir to home directory of user %s: %s", user,
strerror(errno));
Expand Down

0 comments on commit 2a00354

Please sign in to comment.