Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about sshFxpOpendirPacket packet #585

Open
ior308 opened this issue Apr 26, 2024 · 4 comments
Open

Question about sshFxpOpendirPacket packet #585

ior308 opened this issue Apr 26, 2024 · 4 comments

Comments

@ior308
Copy link

ior308 commented Apr 26, 2024

Dear, I noticed that the SFTP server bundle in the library uses an sshFxpOpenPacket to respond to an sshFxpOpendirPacket. Since I need to handle files and directories differently, I replaced the response packet with sshFxpOpenDPacket.

It seems to be working well, but I would like to ask you if this change could cause any issues.

Regards

@puellanivis
Copy link
Collaborator

This package has two separate server implementations. I’m confused about which precisely you’re talking about.

Maybe if you give an example of the code you changed, I could give you some feedback.

@ior308
Copy link
Author

ior308 commented Apr 29, 2024

Dear,

I changed a line in the server.go:

case *sshFxpOpendirPacket:
lp := s.toLocalPath(p.Path)

              s.logQueue <- logmodel.LogMsg{
                      Level: "INFO",
                      Stdo:  false,
                      Uuid:  s.cUuid,
                      Msg:   fmt.Sprintf("BROWSE folder: %s", lp)}

              if stat, err := os.Stat(lp); err != nil {
                      rpkt = statusFromError(p.ID, err)
              } else if !stat.IsDir() {
                      rpkt = statusFromError(p.ID, &os.PathError{
                              Path: lp, Err: syscall.ENOTDIR,
                      })
              } else {
                      //rpkt = (&sshFxpOpenPacket{  <========= Original line
                      rpkt = (&sshFxpOpenDPacket{
                              ID:     p.ID,
                              Path:   p.Path,
                              Pflags: sshFxfRead,
                      }).respond(s)
              }

Regards

@puellanivis
Copy link
Collaborator

This is where my confusion is coming from: there is not defined an OpenDPacket. No less, the corresponding packet name SSH_FXP_OPEN_D_PACKET does not exist in the standard: https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-3

This code also appears to be in the server.go which is the direct local-filesystem implementation, where ReadDir operates on the *os.File type https://pkg.go.dev/os@go1.22.2#File.ReadDir and therefore, its functionality should be properly performed by sshFxpOpenPacket

@ior308
Copy link
Author

ior308 commented Apr 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants