Subject: bin/6448: ftp(1) fails to restore file modification time
To: None <gnats-bugs@gnats.netbsd.org>
From: None <yasufu-i@is.aist-nara.ac.jp>
List: netbsd-bugs
Date: 11/16/1998 04:11:02
>Number: 6448
>Category: bin
>Synopsis: ftp(1) fails to restore file modification time
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Nov 15 11:20:01 1998
>Last-Modified:
>Originator: ITOH Yasufumi
>Organization:
Nara Institute of Science and Technology, Nara, Japan
>Release: 1.3H (Nov. 15, 1998)
>Environment:
System: NetBSD acha.my.domain 1.3H NetBSD 1.3H (UVM) #0: Mon Nov 9 10:35:43 JST 1998 itohy@myname.my.domain:/usr/src/sys/arch/x68k/compile/UVM x68k
>Description:
ftp(1) fails to set file modification time under certain condition.
The condition is:
1. local timezone has summer time, and
2. the time of a remote file in UTC can't be represented by
the local time (using the numerals, ignoring the name of timezone),
since it is skipped at the entrance to summer time.
By the way, we have no summer time in Japan :-).
I found this by inspecting the code.
>How-To-Repeat:
% mkdir /tmp/test
% env TZ=GMT touch -t 199804050000 /tmp/test/a
% env TZ=GMT touch -t 199804050100 /tmp/test/b
% env TZ=GMT touch -t 199804050200 /tmp/test/c
% env TZ=GMT touch -t 199804050300 /tmp/test/d
% env TZ=GMT ls -lT /tmp/test # original file time in UTC
total 0
-rw-r--r-- 1 itohy wheel 0 Apr 5 00:00:00 1998 a
-rw-r--r-- 1 itohy wheel 0 Apr 5 01:00:00 1998 b
-rw-r--r-- 1 itohy wheel 0 Apr 5 02:00:00 1998 c
-rw-r--r-- 1 itohy wheel 0 Apr 5 03:00:00 1998 d
% env TZ=US/Pacific ftp localhost # run ftp in US/Pacific timezone
Connected to localhost.
...
ftp> cd /tmp/test
250 CWD command successful.
ftp> mget *
...
ftp> qui
221 Goodbye.
% env TZ=GMT ls -lT # see ftp'ed file time
total 0
-rw-r--r-- 1 itohy wheel 0 Apr 5 00:00:00 1998 a
-rw-r--r-- 1 itohy wheel 0 Apr 5 01:00:00 1998 b
-rw-r--r-- 1 itohy wheel 0 Nov 15 06:14:09 1998 c # time is not restored
-rw-r--r-- 1 itohy wheel 0 Apr 5 03:00:00 1998 d
%
>Fix:
Choose one or some from :-)
1. Rewrite util.c::remotemodtime() using timegm(3) instead of mktime(3).
This is the cleanest fix but unfortunately the timegm() function
is no in standards and not portable.
2. Set local timezone to UTC, i.e. putenv("TZ=GMT"); at program startup.
This affects child processes and environ manipulation is not portable.
3. Calculate time_t value by hand.
Is it portable?
4. Don't mind, leave it unchanged.
5. Remove code for mtime preservation since no good implementation exists.
6. any other?
>Audit-Trail:
>Unformatted: