Issues w/ timezones on gssftpd

Philip Prindeville philipp at redfish-solutions.com
Tue Nov 28 00:17:59 EST 2006


Russ Allbery wrote:

>Philip Prindeville <philipp at redfish-solutions.com> writes:
>
>  
>
>>*** src/appl/gssftp/ftpd/ftpd.c.graylist	2006-11-27 13:36:38.000000000 -0700
>>--- src/appl/gssftp/ftpd/ftpd.c	2006-11-27 20:18:40.000000000 -0700
>>***************
>>*** 472,477 ****
>>--- 552,560 ----
>>  		if (ns > 2)
>>  		  (void) close(ns);
>>  	}
>>+ #if defined(__USE_POSIX)
>>+ 	tzset();
>>+ #endif
>>    
>>
>
>I'd like to try to understand more about what's going on here.  The basic
>problem is that gssftpd's logs don't have appropriate timestamps in your
>environment, and running tzset() fixes that?
>
>According to the Linux tzset man page:
>
>    This function is automatically called by the other time conversion
>    functions that depend on the time zone.
>
>This implies to me that you should never have to call tzset explicitly,
>and if you do, something else is wrong.
>  
>

Well, you can call ctime() before the chroot(), and it will call
_tzset_internal(), or you can call tzset() directly, and it will have
the same effect. It's a question of which is less obscure.


>I believe what it's doing in this case is initializing the TZ environment
>variable based on the contents of /etc/localtime, which is then used by
>child processes in a chroot to figure out the appropriate time zone in the
>absence of the normal configuration file (although I no longer have the
>original message that started this thread at hand, and may be
>misunderstanding).  If that's the case, why not just ensure that the
>localtime file exists in the chroot?  /etc/localtime is a fairly standard
>configuration file to have to copy into a chroot.
>
>  
>

Neither one touches the contents of "TZ", as it happens. It
uses the tz_name and tz_rules static variables instead.

As for why not copy the /etc/localtime file? Because some
people do some odd things, such as setting TZ in startup
scripts, wrappers, etc. before firing up ftpd. In that case,
if the copy of /etc/localtime in the chroot() environment
(such as /var/ftp) disagrees with the contents of "TZ", then
you're going to get unexpected and possibly undefined
behavior.

Calling tzset() before calling ctime()/localtime()/strftime()
*or* chroot() is the simplest solution that offers consistent
behavior in all scenarios.

-Philip





More information about the krbdev mailing list