[dunfell] [openssh] Issue in sftp-perm regression test from openssh-ptest


akash hadke
 

Hello,

I am trying to execute openssh-ptest but sftp-perm regression test is getting failed. It checks the file permissions by using the sftp-server.

After analysing the code and the logs it is found that the test is blacklisting read permission on the server then the client sends a request to read a file but due to the blacklisted read permission server sends the permission denied status after that server closes the file and sends a success status for closing the file. The test is expecting a permission denied message but ends up getting a success message and hence the test is getting failed.

Test Source Code: openssh-8.2p1/regress/sftp-perm.sh

Below are the logs of client and server communication for open and read permission.

Pass Case:

Client Logs

debug2: Remote version: 3
debug2: Server supports extension "posix-rename@..." revision 1
debug2: Server supports extension "statvfs@..." revision 2
debug2: Server supports extension "fstatvfs@..." revision 2
debug2: Server supports extension "hardlink@..." revision 1
debug2: Server supports extension "fsync@..." revision 1
debug2: Server supports extension "lsetstat@..." revision 1
debug3: Sent message fd 3 T:16 I:1
debug3: SSH_FXP_REALPATH . -> /usr/lib/openssh/ptest/regress size 0
sftp> get /usr/lib/openssh/ptest/regress/data /usr/lib/openssh/ptest/regress/copy
debug3: Looking up /usr/lib/openssh/ptest/regress/data
debug3: Sent message fd 3 T:7 I:2
debug3: Received stat reply T:105 I:2
debug3: Sent message fd 3 T:17 I:3
debug3: Received stat reply T:105 I:3
debug3: Sent message SSH2_FXP_OPEN I:4 P:/usr/lib/openssh/ptest/regress/data
remote open("/usr/lib/openssh/ptest/regress/data"): Permission denied
Server Logs

session opened for local user root from [160.48.199.121]
received client version 3
debug3: request 1: realpath
realpath "."
debug1: request 1: sent names count 1
debug3: request 2: lstat
lstat name "/usr/lib/openssh/ptest/regress/data"
debug1: request 2: sent attrib have 0xf
debug3: request 3: stat
stat name "/usr/lib/openssh/ptest/regress/data"
debug1: request 3: sent attrib have 0xf
Refusing blacklisted open request
debug3: request 4: sent status 3
sent status Permission denied
debug1: read eof
session closed for local user root from [160.48.199.121]

Fail Case:

Client Logs

debug2: Remote version: 3
debug2: Server supports extension "posix-rename@..." revision 1
debug2: Server supports extension "statvfs@..." revision 2
debug2: Server supports extension "fstatvfs@..." revision 2
debug2: Server supports extension "hardlink@..." revision 1
debug2: Server supports extension "fsync@..." revision 1
debug2: Server supports extension "lsetstat@..." revision 1
debug3: Sent message fd 3 T:16 I:1
debug3: SSH_FXP_REALPATH . -> /usr/lib/openssh/ptest/regress size 0
sftp> get /usr/lib/openssh/ptest/regress/data /usr/lib/openssh/ptest/regress/copy
debug3: Looking up /usr/lib/openssh/ptest/regress/data
debug3: Sent message fd 3 T:7 I:2
debug3: Received stat reply T:105 I:2
debug3: Sent message fd 3 T:17 I:3
debug3: Received stat reply T:105 I:3
debug3: Sent message SSH2_FXP_OPEN I:4 P:/usr/lib/openssh/ptest/regress/data
debug3: Request range 0 -> 32767 (0/1)
debug3: Received reply T:101 I:5 R:1
debug1: truncating at 0
Couldn't read from remote file "/usr/lib/openssh/ptest/regress/data" : Permission denied
debug3: Sent message SSH2_FXP_CLOSE I:6
debug3: SSH2_FXP_STATUS 0
Server Logs

session opened for local user root from [160.48.199.121]
received client version 3
debug3: request 1: realpath
realpath "."
debug1: request 1: sent names count 1
debug3: request 2: lstat
lstat name "/usr/lib/openssh/ptest/regress/data"
debug1: request 2: sent attrib have 0xf
debug3: request 3: stat
stat name "/usr/lib/openssh/ptest/regress/data"
debug1: request 3: sent attrib have 0xf
debug3: request 4: open flags 1
open "/usr/lib/openssh/ptest/regress/data" flags READ mode 0666
debug1: request 4: sent handle handle 0
Refusing blacklisted read request
debug3: request 5: sent status 3
sent status Permission denied
debug3: request 6: close handle 0
close "/usr/lib/openssh/ptest/regress/data" bytes read 0 written 0
debug3: request 6: sent status 0
sent status Success
debug1: read eof
session closed for local user root from [160.48.199.121]

Is anyone facing a similar issue? Whether my understanding of the test is correct? Or is this a bug in sftp code?