The Samba-Bugzilla – Attachment 6508 Details for
Bug 8198
rsync does not set TZ variable after chroot(), which confuses logging timestamps
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
rsync-3.0.6-chroot-timezone.patch (text/plain), 1.19 KB, created by
Jan Kaluza
on 2011-06-01 10:07:01 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Jan Kaluza
Created:
2011-06-01 10:07:01 UTC
Size:
1.19 KB
patch
obsolete
>diff --git a/clientserver.c b/clientserver.c >index 18a2258..70c28b9 100644 >--- a/clientserver.c >+++ b/clientserver.c >@@ -671,11 +671,41 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host) > * a warning, unless a "require chroot" flag is set, > * in which case we fail. > */ >+ time_t current_time = 0; >+ struct tm* local_tm; >+ char envtz[sizeof("UTC-hh:mm:ss")]; >+ int hour, min, sec; >+ >+ /* Do libc's timezone initialization before it gets lost >+ * because of chroot. */ >+ tzset(); >+ current_time = time(NULL); >+ local_tm = localtime(¤t_time); >+ long timezone = -local_tm->tm_gmtoff; >+ > if (chroot(module_chdir)) { > rsyserr(FLOG, errno, "chroot %s failed", module_chdir); > io_printf(f_out, "@ERROR: chroot failed\n"); > return -1; > } >+ >+ /* Set TZ env variable according to data we got >+ * before chroot. */ >+ hour = timezone; >+ if (hour < 0) { >+ hour = -hour; >+ } >+ if (hour < 25*60*60) { >+ sec = hour % 60; >+ hour /= 60; >+ min = hour % 60; >+ hour /= 60; >+ if (timezone < 0) { >+ hour = -hour; >+ } >+ snprintf(envtz, sizeof(envtz), "UTC%+d:%d:%d", hour, min, sec); >+ setenv("TZ", envtz, 1); >+ } > module_chdir = module_dir; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 8198
: 6508