[tahoe-dev] sftp with hashed passwords (patch fragment)
news4 at mystrobl.de
Tue Mar 27 08:58:50 UTC 2012
Hi. Last week I asked whether the sftp client is supposed to support hashed passwords in private/ftp.accounts. My current need is solved by the patch below (it needs an additional "import crypt" somewhere at the beginning).
With that modification applied to frontends/auth.py, encrypted passwords (and only those) are supported by the sftp frontend.
Usage: create a hash by using htpasswd/htpasswd2 from Apache (or google
for htpasswd.py), replace the cleartext password in ftp.accounts by that hash.
Adding ".. or cleartext == cryptedpasswd" to the "if crypt.crypt(..." line
would be necessary for backward compatibility (i.e. still supporting
cleartext passwords), but there's no need for that, in my case.
- def requestAvatarId(self, credentials):
- if credentials.username in self.passwords:
- d = defer.maybeDeferred(credentials.checkPassword,
- d.addCallback(self._cbPasswordMatch, str(credentials.username))
- return d
- return defer.fail(error.UnauthorizedLogin())
+ def requestAvatarId(self, c):
+ if username in self.passwords:
+ up = credentials.IUsernamePassword(c, None)
+ if crypt.crypt(cleartext, cryptedpasswd) == cryptedpasswd:
+ d = defer.succeed(username)
+ d.addCallback(self._cbPasswordMatch, username)
+ return d
+ return defer.fail(error.UnauthorizedLogin())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 1361 bytes
Desc: ?ffentlicher PGP-Schl?ssel
More information about the tahoe-dev