Skip to content

Commit

Permalink
Try to provide a default TZ environment variable, when chrooting, eve…
Browse files Browse the repository at this point in the history
…n for

platforms that don't use glibc.
  • Loading branch information
Castaglia committed May 21, 2016
1 parent 43f97e2 commit f8806ca
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/auth.c
Expand Up @@ -1741,33 +1741,36 @@ int pr_auth_chroot(const char *path) {
int res, xerrno = 0;
time_t now;
char *tz = NULL;
const char *default_tz;

if (path == NULL) {
errno = EINVAL;
return -1;
}

#if defined(HAVE_SETENV) && \
defined(__GLIBC__) && \
#if defined(__GLIBC__) && \
defined(__GLIBC_MINOR__) && \
__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3
default_tz = tzname[0];
#else
/* Per the tzset(3) man page, this should be the assumed default. */
default_tz = ":/etc/localtime";
#endif

tz = pr_env_get(session.pool, "TZ");
if (tz == NULL) {
if (pr_env_set(session.pool, "TZ", pstrdup(permanent_pool,
tzname[0])) < 0) {
default_tz)) < 0) {
pr_log_debug(DEBUG0, "error setting TZ environment variable to "
"'%s': %s", tzname[0], strerror(errno));
"'%s': %s", default_tz, strerror(errno));

} else {
pr_log_debug(DEBUG10, "set TZ environment variable to '%s'", tzname[0]);
pr_log_debug(DEBUG10, "set TZ environment variable to '%s'", default_tz);
}

} else {
pr_log_debug(DEBUG10, "TZ environment variable already set to '%s'", tz);
}
#else
(void) tz;
#endif

pr_log_debug(DEBUG1, "Preparing to chroot to directory '%s'", path);

Expand Down

0 comments on commit f8806ca

Please sign in to comment.