libbb: introduce and use chdir_or_warn()

function                                             old     new   delta
chdir_or_warn                                          -      37     +37
send_cgi_and_exit                                    720     711      -9
xchdir                                                27      15     -12
setup_environment                                    233     217     -16
fork_job                                             449     433     -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2022-01-13 12:56:10 +01:00
parent 931c55f9e2
commit c2788f88f4
5 changed files with 13 additions and 8 deletions

View File

@@ -675,8 +675,7 @@ static void change_user(struct passwd *pas)
{
/* careful: we're after vfork! */
change_identity(pas); /* - initgroups, setgid, setuid */
if (chdir(pas->pw_dir) < 0) {
bb_error_msg("can't change directory to '%s'", pas->pw_dir);
if (chdir_or_warn(pas->pw_dir) != 0) {
xchdir(CRON_DIR);
}
}