-static char *bt_secure_getenv(const char *name)
-{
- if (is_setuid_setgid()) {
- printf_err("Disregarding %s environment variable for setuid/setgid binary", name);
- return NULL;
- }
- return getenv(name);
-}
-
-static const char *get_home_dir(void)
-{
- char *val = NULL;
- struct passwd *pwd;
-
- val = bt_secure_getenv(HOME_ENV_VAR);
- if (val) {
- goto end;
- }
- /* Fallback on password file. */
- pwd = getpwuid(getuid());
- if (!pwd) {
- goto end;
- }
- val = pwd->pw_dir;
-end:
- return val;
-}
-