X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=libs%2Fcore%2Fluasrc%2Fsys.lua;h=e5f19f20b82b51eca87a0b5cffaeb921c1710144;hb=b8240f3516945b5969bfcfeb1fcc057759f5dd4b;hp=54c4e061377ed222012c741f9126af36f5bd9f2a;hpb=7a4aa85dd64f72b9edcbf9310d0d95e59960d84e;p=project%2Fluci.git diff --git a/libs/core/luasrc/sys.lua b/libs/core/luasrc/sys.lua index 54c4e0613..e5f19f20b 100644 --- a/libs/core/luasrc/sys.lua +++ b/libs/core/luasrc/sys.lua @@ -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.stat("/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(password, account.passwd)) + end end end