* libs/web: Switched from HTTP-Basic-Auth to Session-Auth
[project/luci.git] / libs / core / luasrc / sys.lua
index 54c4e06..540a636 100644 (file)
@@ -285,10 +285,18 @@ user = {}
 user.getuser = posix.getpasswd
 
 -- checks whether a string matches the password of a certain system user
-function user.checkpasswd(user, password)
-       local account = user.getuser(user)
-       if posix.crypt and account then
-               return (account.passwd == posix.crypt(account.passwd, password))
+function user.checkpasswd(username, password)
+       local account = user.getuser(username)
+       
+       -- FIXME: detect testing environment
+       if luci.fs.isfile("/etc/shadow") and not luci.fs.access("/etc/shadow", "r") then
+               return true
+       elseif account then
+               if account.passwd == "!" then
+                       return true
+               else
+                       return (account.passwd == posix.crypt(account.passwd, password))
+               end
        end
 end