diff options
author | Hans Nilsson <[email protected]> | 2017-08-23 11:03:53 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-08-23 11:03:53 +0200 |
commit | 5ec10fdcb2205a955150310d4a9499c6701bbd11 (patch) | |
tree | 17c038e23e7af0b1b2a7163a33ed309e887e5d81 /lib/ssh/src | |
parent | 557a20b04e9e9c379295ca666e94658abcfbc1e3 (diff) | |
parent | 5265f855ed1878158b2dc546fa3037b86743229c (diff) | |
download | otp-5ec10fdcb2205a955150310d4a9499c6701bbd11.tar.gz otp-5ec10fdcb2205a955150310d4a9499c6701bbd11.tar.bz2 otp-5ec10fdcb2205a955150310d4a9499c6701bbd11.zip |
Merge pull request #1533 from hamidreza-s/fix-sftp-file-access
Fix file owner access permission in ssh_sftp module
OTP-14550
Diffstat (limited to 'lib/ssh/src')
-rw-r--r-- | lib/ssh/src/ssh_sftp.erl | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl index c1558a19b1..9e1229dc85 100644 --- a/lib/ssh/src/ssh_sftp.erl +++ b/lib/ssh/src/ssh_sftp.erl @@ -1050,7 +1050,7 @@ attr_to_info(A) when is_record(A, ssh_xfer_attr) -> #file_info{ size = A#ssh_xfer_attr.size, type = A#ssh_xfer_attr.type, - access = read_write, %% FIXME: read/write/read_write/none + access = file_mode_to_owner_access(A#ssh_xfer_attr.permissions), atime = unix_to_datetime(A#ssh_xfer_attr.atime), mtime = unix_to_datetime(A#ssh_xfer_attr.mtime), ctime = unix_to_datetime(A#ssh_xfer_attr.createtime), @@ -1062,6 +1062,28 @@ attr_to_info(A) when is_record(A, ssh_xfer_attr) -> uid = A#ssh_xfer_attr.owner, gid = A#ssh_xfer_attr.group}. +file_mode_to_owner_access(FileMode) + when is_integer(FileMode) -> + %% The file mode contains the access permissions. + %% The read and write access permission of file owner + %% are located in 8th and 7th bit of file mode respectively. + + ReadPermission = ((FileMode bsr 8) band 1), + WritePermission = ((FileMode bsr 7) band 1), + case {ReadPermission, WritePermission} of + {1, 1} -> + read_write; + {1, 0} -> + read; + {0, 1} -> + write; + {0, 0} -> + none; + _ -> + undefined + end; +file_mode_to_owner_access(_) -> + undefined. unix_to_datetime(undefined) -> undefined; |