{"action":"created","issue":{"url":"https://api.github.com/repos/pkg/sftp/issues/291","repository_url":"https://api.github.com/repos/pkg/sftp","labels_url":"https://api.github.com/repos/pkg/sftp/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/pkg/sftp/issues/291/comments","events_url":"https://api.github.com/repos/pkg/sftp/issues/291/events","html_url":"https://github.com/pkg/sftp/issues/291","id":448757828,"node_id":"MDU6SXNzdWU0NDg3NTc4Mjg=","number":291,"title":"Wrong value of S_IFMT mask when converting sftp filemode bits to os.FileMode","user":{"login":"cyrilcourvoisier","id":51077690,"node_id":"MDQ6VXNlcjUxMDc3Njkw","avatar_url":"https://avatars2.githubusercontent.com/u/51077690?v=4","gravatar_id":"","url":"https://api.github.com/users/cyrilcourvoisier","html_url":"https://github.com/cyrilcourvoisier","followers_url":"https://api.github.com/users/cyrilcourvoisier/followers","following_url":"https://api.github.com/users/cyrilcourvoisier/following{/other_user}","gists_url":"https://api.github.com/users/cyrilcourvoisier/gists{/gist_id}","starred_url":"https://api.github.com/users/cyrilcourvoisier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyrilcourvoisier/subscriptions","organizations_url":"https://api.github.com/users/cyrilcourvoisier/orgs","repos_url":"https://api.github.com/users/cyrilcourvoisier/repos","events_url":"https://api.github.com/users/cyrilcourvoisier/events{/privacy}","received_events_url":"https://api.github.com/users/cyrilcourvoisier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-05-27T09:31:22Z","updated_at":"2019-05-27T15:13:50Z","closed_at":null,"author_association":"NONE","body":"I encountered this issue when synchronizing a directory using rclone (with sftp) to a server running AIX. Rclone was sending a SSH_FXP_STAT request to test if a directory is, well, a directory.\r\n\r\nThe STAT request was giving the directory's status as 'not a directory' despite being one.\r\nThe problem was in the toFileMode function in attrs.go\r\n\r\n```\r\ninput filemode bits are                  1 0100 0011 1111 1111‬\r\nsyscall.S_IFMT mask bits are             1 1111 0000 0000 0000\r\n```\r\n\r\n\r\nThe different values tested are:\r\n\r\n> \r\n\r\n```\r\n S_IFBLK                                 0 0110 0000 0000 0000\r\n S_IFCHR                                 0 0010 0000 0000 0000\r\n S_IFDIR                                 0 0100 0000 0000 0000\r\n S_IFIFO                                 0 0001 0000 0000 0000\r\n S_IFLNK                                 0 1010 0000 0000 0000\r\n S_IFREG                                 0 1000 0000 0000 0000\r\n S_IFSOCK                                0 1100 0000 0000 0000\r\n```\r\n\r\n\r\nAs you can see, none of the values matchs the input, and the leftmost bit is not used by any value. \r\nThe input would match S_IFDIR if the S_IFMT mask didn't test the leftmost bit.\r\n\r\nI have searched the value of S_IFMT mask in other sftp implentations and in the ones I have found, they define S_IFMT as: 1111 0000 0000 0000\r\n\r\nfor example, the python implementation of stat:\r\nhttps://github.com/python/cpython/blob/2.7/Lib/stat.py\r\n\r\nOr this javascript implementation of sftp:\r\nhttp://maverick-ng-javadocs.s3-website-eu-west-1.amazonaws.com/constant-values.html#com.sshtools.client.sftp.SftpFileAttributes.S_IFMT\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pkg/sftp/issues/comments/496243668","html_url":"https://github.com/pkg/sftp/issues/291#issuecomment-496243668","issue_url":"https://api.github.com/repos/pkg/sftp/issues/291","id":496243668,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5NjI0MzY2OA==","user":{"login":"puellanivis","id":10839126,"node_id":"MDQ6VXNlcjEwODM5MTI2","avatar_url":"https://avatars2.githubusercontent.com/u/10839126?v=4","gravatar_id":"","url":"https://api.github.com/users/puellanivis","html_url":"https://github.com/puellanivis","followers_url":"https://api.github.com/users/puellanivis/followers","following_url":"https://api.github.com/users/puellanivis/following{/other_user}","gists_url":"https://api.github.com/users/puellanivis/gists{/gist_id}","starred_url":"https://api.github.com/users/puellanivis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puellanivis/subscriptions","organizations_url":"https://api.github.com/users/puellanivis/orgs","repos_url":"https://api.github.com/users/puellanivis/repos","events_url":"https://api.github.com/users/puellanivis/events{/privacy}","received_events_url":"https://api.github.com/users/puellanivis/received_events","type":"User","site_admin":false},"created_at":"2019-05-27T15:13:50Z","updated_at":"2019-05-27T15:13:50Z","author_association":"NONE","body":"Both windows and plan9 versions of these constants contain:\r\n```\r\n\t// Invented values to support what package os expects.\r\n```\r\nSo, it looks like someone made a typo bringing the code over, and _neither_ of them actually cares about that extra bit."}}
{"actor":{"display_login":"puellanivis"}}