summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-06-27 14:11:48 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-06-27 14:11:48 +0000
commite2dd594c3827c67c72e12a19ee38bf893bd3f10c (patch)
treef83256c18939a2282d54124cc4a3d5238c98e9d4 /libs
parentb1617b3718c3819a4eeeef5db62b9e05ffc96812 (diff)
libs/sys: fix login with empty password after previous commit
Diffstat (limited to 'libs')
-rw-r--r--libs/sys/luasrc/sys.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua
index 18c79119f7..573d730245 100644
--- a/libs/sys/luasrc/sys.lua
+++ b/libs/sys/luasrc/sys.lua
@@ -596,13 +596,14 @@ user.getuser = nixio.getpw
--- Retrieve the current user password hash.
-- @param username String containing the username to retrieve the password for
-- @return String containing the hash or nil if no password is set.
+-- @return Password database entry
function user.getpasswd(username)
local pwe = nixio.getsp and nixio.getsp(username) or nixio.getpw(username)
local pwh = pwe and (pwe.pwdp or pwe.passwd)
if not pwh or #pwh < 1 or pwh == "!" or pwh == "x" then
- return nil
+ return nil, pwe
else
- return pwh
+ return pwh, pwe
end
end
@@ -611,9 +612,9 @@ end
-- @param pass String containing the password to compare
-- @return Boolean indicating wheather the passwords are equal
function user.checkpasswd(username, pass)
- local pwh = user.getpasswd(username)
- if pwh then
- return (nixio.crypt(pass, pwh) == pwh)
+ local pwh, pwe = user.getpasswd(username)
+ if pwe then
+ return (pwh == nil or nixio.crypt(pass, pwh) == pwh)
end
return false
end