From c2788f88f430da8ae5fb5f293b13fc2b167ea2fe Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 13 Jan 2022 12:56:10 +0100 Subject: 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 --- libbb/setup_environment.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libbb/setup_environment.c') diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index 3777720..3549e20 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c @@ -37,8 +37,7 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass /* Change the current working directory to be the home directory * of the user */ if (flags & SETUP_ENV_CHDIR) { - if (chdir(pw->pw_dir) != 0) { - bb_error_msg("can't change directory to '%s'", pw->pw_dir); + if (chdir_or_warn(pw->pw_dir) != 0) { xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/"); } } -- cgit v1.1