0x3333/smbpasswd-web

Error reported in Chrome after changing smb password

Closed this issue · 2 comments

Hi,

When I tried to use smbpasswd-web to change a smb password with Chrome I've noticed that I always get an error reported, even when the password was successfully set.
Analyzing the issue, I found that the cause for it was not setting the Content-type header on api_set_password. The following patch fixes that issue:

--- a/app.py
+++ b/app.py
@@ -149,6 +149,8 @@ class SmbpasswdRequestHandler(http.server.SimpleHTTPRequestHandler):
             if self._call_smbpasswd(username, entries[1]) == True:
                 self.remove_token(entries[0])
                 self.send_response(200)
+                self.send_header("Content-type", "text/plain")
+                self.end_headers()
                 self.wfile.write(json.dumps("OK").encode())
                 return
             else:

I tested only on Firefox, I should have tested on chrome, will give it a try and report back to you. Thanks!

Nice catch. I just used application/json as content type, as it is the effective return. Fixed on master.