[Bug 3421] New: sftp issue with different timezone client and server

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Wed Apr 13 01:36:39 AEST 2022


https://bugzilla.mindrot.org/show_bug.cgi?id=3421

            Bug ID: 3421
           Summary: sftp issue with different timezone client and server
           Product: Portable OpenSSH
           Version: 8.0p1
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: sftp
          Assignee: unassigned-bugs at mindrot.org
          Reporter: gdelross at redhat.com

Description of problem:

When the client and the server use different timezone, the output of
this commands is different

ls -la 
ls -la *


Version-Release:
openssh-clients-8.0p1-10.el8.x86_64

The openssh-server is totally irrelevant, the issue is client side.

The issue is present also in the previous 7.9 version


How reproducible:
always

Steps to Reproduce:
1.Set the server with a different time zone of the client, for example
: 

$ timedatectl 
               Local time: Tue 2022-04-12 08:06:07 EDT
           Universal time: Tue 2022-04-12 12:06:07 UTC
                 RTC time: Tue 2022-04-12 12:06:07
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no


2. Set the client with a different time zone of the server, for example
:

$ timedatectl 
      Local time: Tue 2022-04-12 21:07:30 KST
  Universal time: Tue 2022-04-12 12:07:30 UTC
        RTC time: Tue 2022-04-12 12:07:29
       Time zone: Asia/Seoul (KST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

3.run sftp with this two command:

$ sftp x.x.x.x
Connected to x.x.x.x

sftp> ls -la
drwx------    3 admin    admin          67 Apr 12 08:04 .
drwxr-xr-x    4 root     root           35 Jan 25 11:19 ..
-rw-rw-r--    1 admin    admin           0 Apr 11 04:54
testfile_Us_Ny.txt

sftp> ls -la *
-rw-rw-r--    0 1000     1000            0 Apr 11 17:54
testfile_Us_Ny.txt


Actual results:

the command ls -al report the file atime of the server.
Apr 11 04:54 testfile_Us_Ny.txt

the command ls -al * convert the atime with the localtime of the
client.
Apr 11 17:54 testfile_Us_Ny.txt

Expected results:

the same atime

Additional info:

I debugged the sftp.c code and relative files, and i hope to find the
bug. Sorry on advanced if the analysis is wrong.


The "ls" sftp command is managed by the function
"parse_dispatch_command" in the sftp.c code:

1412 static int
1413 parse_dispatch_command(struct sftp_conn *conn, const char *cmd,
char **pwd,
1414     int err_abort)

..skip..
         case I_LS:
1521                 if (!path1) {
1522                         do_ls_dir(conn, *pwd, *pwd, lflag);     
1523                         break;
1524                 }
1525 
1526                 /* Strip pwd off beginning of non-absolute paths
*/
1527                 tmp = NULL;
1528                 if (*path1 != '/')
1529                         tmp = *pwd;
1530 
1531                 path1 = make_absolute(path1, *pwd);
1532                 err = do_globbed_ls(conn, path1, tmp, lflag);
1533                 break;

If the "ls" command is without additional arguments ( like the * in the
previous example) the "do_ls_dir" is called.
In the case with additional arguments,  the "do_globbed_ls" is runned.

The "do_globbed_ls" call different functions until the "ls_file" in the
sftp-common.c file:

214 ls_file(const char *name, const struct stat *st, int remote, int
si_units)
215 {
216         int ulen, glen, sz = 0;
217         struct tm *ltime = localtime(&st->st_mtime);

Here the ltime struct is initialized with the localtime timezone.

The optimization don't permit to check *ltime values.

I hope that analysis can help to understand the behavior of the
application.

Best Regards and thanks

Giancarlo del Rossi

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list