There have been various reports that timestamps displayed in various ProFTPD log files, such as an ExtendedLog or TransferLog, or even in directory listings, are not as expected. Other applications (e.g. sshd) on the same machine do not exhibit the same problem. So is proftpd having issues with timestamps?
ExtendedLog
TransferLog
sshd
proftpd
If the timestamps in question are those displayed in directory listings, then you need to check your TimesGMT configuration. Otherwise, depending on the logs at which you are looking, the timestamps will be correct until the user logs in. After that, the timestamps are wrong. This is one clue. The other clue is that these wrong timestamps go away when the DefaultRoot directive is removed from the proftpd.conf file.
TimesGMT
DefaultRoot
proftpd.conf
The answer turns out to be the chroot(2) system call, which proftpd uses to restrict users to certain directories, usually their home directory. There are two configuration directives which tell proftpd to use the chroot(2) system call:
chroot(2)
<Anonymous> DefaultRoot
libc
glibc
The good news is that the above behavior does not happen if the TZ environment variable is set explicitly, to the required timezone. That is, if glibc needs to detect the timezone and it finds that TZ is set, then glibc will use that TZ setting, rather than falling back to GMT.
TZ
Affected Library Functions Once a process has chrooted, the following libc function calls will have possibly-bad side effects, with regard to timezone detection: localtime(3), ctime(3), and mktime(3). As documented in the man pages for these functions, each of them will set the tzname global variable to the "current" timezone. This "current" timezone is what changes, once the process has become chrooted. (For more information on the tzname global variable, read the tzset(3) man page.)
localtime(3)
ctime(3)
mktime(3)
tzname
tzset(3)
Solutions Recent releases of ProFTPD attempt to work around these issues by preserving the tzname global variable after calling localtime(3), and by automatting setting the TZ environment variable, is not already set, before calling chroot(2). These measures are defensive at best, though.
The best way to deal with this issue, which is especially prominent on systems running glibc-2.3 or later, is to set the TZ environment variable explicitly, before starting proftpd. This can be done in an init script for proftpd, for example.
glibc-2.3
init
You can also use the SetEnv configuration directive within the proftpd.conf file to set the TZ environment variable, e.g.:
SetEnv
# Set the TZ environment variable to be Pacific Standard Time (PST) SetEnv TZ PST
SetEnv TZ :/etc/localtime
MFMT
MFF
These are provided as examples; please consult your system documentation for the proper syntax to use for the TZ value.
Frequently Asked Questions Question: Why is the timestamp on my newly uploaded file wrong? Answer: If by "wrong" you mean "different from the timestamp of that file on my client machine", then that is the expected behavior. The modification timestamp on a file is not part of the data uploaded over the data connection when uploading a file. Timestamps like that are metadata for that file, not part of the bytes of the file itself. FTP does not supporting sending of timestamps as part of the upload transfer process. See below for a common follow-up question. Question: Does ProFTPD support changing the timestamp on a file using the MDTM command? That's what my client does. Answer: No. Why not? For several reasons: The MDTM command is not one of the commands mandated by RFC 959. Some FTP clients use MDTM for retrieving the modification time, others try to use it to set the modification time, and still others do both. Among those FTP clients that do use MDTM, there is no consistent format of the timestamp used. In short, it is a royal mess. ProFTPD supports MDTM for retrieving the modification time, in GMT. Period. If you want to set the modification time, you can use the MFMT command supported by the mod_facts module, or the mod_site_misc module's SITE UTIME command. Question: I thought that the TimesGMT directive was affected the timestamps that proftpd uses? Answer: No. The TimesGMT directive only affects the timestamps as displayed to FTP clients in directory listings; it does not affect the timestamps used in log files. © Copyright 2017 The ProFTPD Project All Rights Reserved
Question: Why is the timestamp on my newly uploaded file wrong? Answer: If by "wrong" you mean "different from the timestamp of that file on my client machine", then that is the expected behavior.
The modification timestamp on a file is not part of the data uploaded over the data connection when uploading a file. Timestamps like that are metadata for that file, not part of the bytes of the file itself. FTP does not supporting sending of timestamps as part of the upload transfer process. See below for a common follow-up question.
Question: Does ProFTPD support changing the timestamp on a file using the MDTM command? That's what my client does. Answer: No.
MDTM
Why not? For several reasons:
If you want to set the modification time, you can use the MFMT command supported by the mod_facts module, or the mod_site_misc module's SITE UTIME command.
mod_facts
mod_site_misc
SITE UTIME
Question: I thought that the TimesGMT directive was affected the timestamps that proftpd uses? Answer: No. The TimesGMT directive only affects the timestamps as displayed to FTP clients in directory listings; it does not affect the timestamps used in log files.