Bug 2106 - When TZ isn't explicitly set ls can give different time stamps
Summary: When TZ isn't explicitly set ls can give different time stamps
Status: CLOSED WORKSFORME
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 5.3p1
Hardware: Other Linux
: P5 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-17 01:04 AEST by Dave Clarke
Modified: 2020-02-14 15:59 AEDT (History)
2 users (show)

See Also:


Attachments
call tzset() for sftp-server and before chroot in sshd (1.23 KB, patch)
2013-07-12 10:56 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Clarke 2013-05-17 01:04:03 AEST
When I do an ls -ltr with no arguments I get a listing for a file saying something like

sftp> ls -ltr
:
-rw-rw-rw-   1 user     group       10466 May 14 20:42 P1.XXXX
:

However when I list the file explicitly

sftp> ls -ltr P1.XXXXX
-rw-rw-rw-    0 0        0           10466 May 14 15:42 P1.XXXXX

sftp> ls -l P1.XXXXX
-rw-rw-rw-    0 0        0           10466 May 14 15:42 P1.XXXXX

The SFTP Server and Client are both in CDT timezone though the TZ environment variable isn't set and the 20:42 is obviously the UT time
Comment 1 Darren Tucker 2013-06-04 06:25:09 AEST
reproduced with 6.2p2.

also the uid->name lookups and link counts are broken in the second example.
Comment 2 Damien Miller 2013-07-12 10:56:09 AEST
Created attachment 2312 [details]
call tzset() for sftp-server and before chroot in sshd

The difference between "ls -ltr" and "ls -ltr FILENAME" is that the first uses the longname from the server and the second synthesises the line on the client. 

uid->name and link counts aren't supported by our dialect of the sftp protocol. They are only listed in the "longname" element in the sftp dirent struct, so they are expected to be wrong in the locally-generated version.

The time shouldn't be wrong though - the server generates the longname's time using localtime() and strftime(). Perhaps it needs a tzset() first? Someone has reported a similar problem a while ago on for chrooted sftp and IIRC a similar patch to this helped.
Comment 3 Damien Miller 2013-07-25 12:18:07 AEST
Retarget to openssh-6.4
Comment 4 Damien Miller 2013-07-25 12:21:07 AEST
Retarget 6.3 -> 6.4
Comment 5 Damien Miller 2013-09-19 11:28:33 AEST
btw, I'm not going to apply this patch until someone reports that it solves their problems.
Comment 6 Damien Miller 2014-02-06 10:18:17 AEDT
Retarget incomplete bugs / feature requests to 6.6 release
Comment 7 Damien Miller 2014-02-06 10:20:28 AEDT
Retarget incomplete bugs / feature requests to 6.6 release
Comment 8 Damien Miller 2014-04-12 14:49:47 AEST
Retarget to 6.7 release, since 6.6 was mostly bugfixing.
Comment 9 Damien Miller 2014-04-12 14:54:27 AEST
Remove from 6.6 tracking bug
Comment 10 Damien Miller 2014-07-07 18:12:39 AEST
remove target until someone who can replicate this tests the fine patch.
Comment 11 Damien Miller 2019-01-23 20:16:34 AEDT
No followup for 5 years == no bug
Comment 12 Damien Miller 2020-02-14 15:59:18 AEDT
Closing all resolved bug with release of openssh-8.2