-
Bug
-
Resolution: Won't Do
-
Minor
-
None
-
rhel-8.5.0
-
No
-
Moderate
-
rhel-security-crypto-diamonds
-
ssg_security
-
None
-
False
-
False
-
-
None
-
None
-
None
-
None
-
If docs needed, set a value
-
-
Unspecified
-
None
-
57,005
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 number of selected component (if applicable):
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 rhel 7.9 version
How reproducible:
always
Steps to Reproduce:
1.Set the server with a different time zone of the client, for example :
[admin@rhel85 ~]$ 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 :
[admin@rhel79 ~]$ 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 192.168.122.119
Connected to 192.168.122.119.
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
sftp>
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.
The ls 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)
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 other case 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