Package: proftpd-basic
Version: 1.3.2e-4
Severity: minor
Tags: patch

Hello,

If proftpd is configured to chroot(), e.g. with an <Anonymous> stanza or
with the DefaultRoot directive, it first sets the TZ variable so that
glibc will have something to work with.  (See [1] for more information,
and pr_auth_chroot() in src/auth.c for the implementation.)
Unfortunately, it always picks the non-daylight-savings timezone, so log
messages printed after it sets TZ are inconsistent during DST.

It's actually pretty simple to determine whether DST is in effect, and
the name of the DST timezone from tzname[1]; however, glibc doesn't
actually recognize that as a timezone (at least for me - rather than
MDT, it wants MST7MDT).

Luckily, there's a simple solution that should always work for Debian:
set the TZ variable to ":/etc/localtime".  I have attached a patch that
adds the appropriate directive to the proftpd.conf template with a
comment.

 [1]: http://www.proftpd.org/docs/howto/Timestamps.html

-- 
+-----------------------------------------+
| John Wright <john.wri...@hp.com>        |
| Hewlett-Packard Telco Platform Software |
+-----------------------------------------+
>From 83c5b7c053ee8e3b8a53053ae51a493c554027eb Mon Sep 17 00:00:00 2001
From: John Wright <john.wri...@hp.com>
Date: Wed, 7 Apr 2010 18:47:17 -0600
Subject: [PATCH] Use consistent timezone in logs

Before chroot()ing, if the TZ environment variable isn't set, proftpd
will set it to the first element of the tzname global variable, which
represents the non-DST timezone.  So during DST, all logs after the
variable change will be have incorrect timestamps.  Unfortunately, while
it's easy to determine whether DST is in effect, and to get the name of
that timezone, glibc doesn't actually recognize it as a valid timezone.
But on Debian systems, we can just set the TZ environment variable to
:/etc/localtime to solve the problem.
---
 debian/templates/proftpd.conf |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/debian/templates/proftpd.conf b/debian/templates/proftpd.conf
index 12137f5..2cd0989 100644
--- a/debian/templates/proftpd.conf
+++ b/debian/templates/proftpd.conf
@@ -85,6 +85,12 @@ AllowOverwrite			on
 #
 # UseSendFile			off
 
+# In order to keep log file dates consistent after chroot, use timezone info
+# from /etc/localtime.  If this is not set, and proftpd is configured to
+# chroot (e.g. DefaultRoot or <Anonymous>), it will use the non-daylight
+# savings timezone regardless of whether DST is in effect.
+SetEnv TZ :/etc/localtime
+
 TransferLog /var/log/proftpd/xferlog
 SystemLog   /var/log/proftpd/proftpd.log
 
-- 
1.6.6

Reply via email to