Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2074532

Summary: sftp issue with different timezone client and server
Product: Red Hat Enterprise Linux 8 Reporter: Giancarlo del Rossi <gdelross>
Component: opensshAssignee: Dmitry Belyavskiy <dbelyavs>
Status: CLOSED MIGRATED QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: low    
Version: 8.5CC: jjelen, mhavrila, rmetrich, ssorce
Target Milestone: rcKeywords: MigratedToJIRA, Triaged, Upstream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-10-03 16:10:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Giancarlo del Rossi 2022-04-12 12:29:54 UTC
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) {
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 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

Comment 2 Dmitry Belyavskiy 2022-04-12 14:55:08 UTC
*** Bug 2074530 has been marked as a duplicate of this bug. ***

Comment 5 Giancarlo del Rossi 2022-04-12 15:40:37 UTC
Hello

opened a bug in the https://bugzilla.mindrot.org/


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

Best Regards

Comment 6 RHEL Program Management 2023-10-03 16:05:56 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 7 RHEL Program Management 2023-10-03 16:10:56 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.