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

smb: Use the correct error code if opening the file was denied #4095

Conversation

juergenhoetzel
Copy link
Contributor

I was puzzled by the error code i got when trying to download a protected file over smb:

curl   -u "kodi:$KODI_PW" -v  smb://localhost/kodi/notreadable.txt
...
curl: (78) Remote file not found

While tshark reports:

tshark -i lo -Y smb
...
   16 0.008405497          ::1 → ::1          SMB 189 NT Create AndX Request, Path: notreadable.txt
   18 0.008770106          ::1 → ::1          SMB 125 NT Create AndX Response, Error: Access denied

With this commit:

./src/curl   -u "kodi:$KODI_PW" -v  smb://localhost/kodi/notreadable.txt
curl: (9) Access denied to remote resource

@juergenhoetzel juergenhoetzel force-pushed the smb-open-handle-permission-denied branch from 78254c8 to 2020584 Compare July 7, 2019 15:40
@@ -785,6 +785,8 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
case SMB_OPEN:
if(h->status || smbc->got < sizeof(struct smb_nt_create_response)) {
req->result = CURLE_REMOTE_FILE_NOT_FOUND;
if(h->status == smb_swap32(SMB_ERR_NOACCESS))
req->result = CURLE_REMOTE_ACCESS_DENIED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very reasonable, and match how we handle other similar errors. It would be nice if our smbserver.py testserver could simulate these types of errors, but that's for another PR.

@jay jay closed this in ac3d19a Jul 11, 2019
@jay
Copy link
Member

jay commented Jul 11, 2019

Thanks

caraitto pushed a commit to caraitto/curl that referenced this pull request Jul 23, 2019
- Return CURLE_REMOTE_ACCESS_DENIED for SMB access denied on file open.

Prior to this change CURLE_REMOTE_FILE_NOT_FOUND was returned instead.

Closes curl#4095
@lock lock bot locked as resolved and limited conversation to collaborators Oct 9, 2019
@bagder bagder added the SMB label May 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants