-
Notifications
You must be signed in to change notification settings - Fork 380
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
"File does not exist" every time when using OpenFile #212
Comments
Both OpenFile() and Open() use the exact same underlying call. The only difference is that Open() has the readonly flag hardcoded in where OpenFile() requires you pass the flags. So my best guess with the information available is that you are calling it with a bad flag. You should be passing in flags from the os package. Eg. |
@ericcancil Just pinging you in case you didn't see my previous post. I'm not sure if you get emailed notifications of my reply w/ vs w/o mentioning you. |
@eikenb I'm writing the file as follows
Then in the future I am trying to write to it as such
I'm using Any ideas? |
Which SFTP server is your client connecting to? Testing your code with my local OpenSSH/SFTP server and it works. |
When I test locally with docker it works as well. When i connect to any remote sftp server You don't see anything funny as far as my code? Thanks for answering back so quickly. Really appreciate it. |
Your code looks fine and should work. Does the checkForLogFile() call return the error as well, or just the writeLogFile() call? Have you tried different flags, maybe leave off os.O_TRUNC? My guess is the server doesn't handle the flags correctly. You could also try hitting it with this command, if available, it might tell you which server it is.
|
I tried with just os.O_TRUNC with same results Here are the results of nmap
|
If i send os.O_RDONLY it works, even tho I'm writing it as |
If that nmap system detect is right, the it doesn't look like I'll be able to replicate this. Are you able to upload files using openssh's sftp client? It sounds like you have a workaround. That if you open the file with os.O_RDONLY it gives you the filehandle and lets you write to it? |
writing fails with a does not exist error. Very strange. |
When using openssh's sftp client? |
Works when using all clients except the library |
Can you tell me anything more about the server? I'll have to look at what the client lib does in comparison to openssh's version. Look for differences. But it would be a lot easier if I could reproduce the issue somehow. |
One difference is that openssh's function to upload a file sends an open packet with the flags;
Where our client always sends;
You could replicate what openssh does by calling OpenFile() like so...
|
unfortunately the same thing. Going to try and skip this feature right now as we are backing things up in s3 and we have versioning turned on. THanks a lot for your help |
If there is anything more you can tell me about the server it might be helpful. I'll spend a bit more time looking over what openssh does to see if any more differences jump out at me. |
You could try specifying a MaxPacket size to something smaller than default. I found this in the openssh code...
To set this using our code...
The normal default is 32768. |
@eikenb Thank for the "SSH2_FXF_WRITE | SSH2_FXF_CREAT | SSH2_FXF_TRUNC" flags for OpenFile, it solved my problem with one strange SFTP server. |
I get the same error. I tried both #212 (comment) and #212 (comment) your solutions but none of them worked.
========== UPDATE ==========
|
@ilovelinux What server are you using? Openssh? |
Yes, the version I sent is the server's OpenSSH version. Client runs in a clear installation of Windows XP |
Can you provide a small program that re-creates the problem? I test against OpenSSH manually fairly often and the client integration tests also test against OpenSSH. So I'm not sure if I'll be able to reproduce it, but with a self-contained example maybe we can find help from someone with Windows 10 access to verify the issue. Thanks. |
Gosh! I found the bug! It was my fault! |
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 |
As i said in the title, I get "File does not exist" every time when using OpenFile. I can successfully call Open on the same file without any error, and am wondering what is causing this issue.
Thank you
The text was updated successfully, but these errors were encountered: