* luci-0.8: backport password authentication fixes
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 12 Oct 2008 00:13:50 +0000 (00:13 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 12 Oct 2008 00:13:50 +0000 (00:13 +0000)
libs/sys/luasrc/sys.lua

index bd072ee..56c1384 100644 (file)
@@ -35,7 +35,7 @@ luci.util   = require "luci.util"
 luci.fs     = require "luci.fs"
 luci.ip     = require "luci.ip"
 
-local tonumber, ipairs, pairs = tonumber, ipairs, pairs
+local tonumber, ipairs, pairs, pcall = tonumber, ipairs, pairs, pcall
 
 
 --- LuCI Linux and POSIX system utilities.
@@ -491,8 +491,12 @@ function user.checkpasswd(username, password)
                        end
                end
 
-               return (pwd == posix.crypt(password, pwd))
+               if pwd and #pwd > 0 and password and #password > 0 then
+                       return (pwd == posix.crypt(password, pwd))
+               end
        end
+
+       return false
 end
 
 --- Change the password of given user.