Fix a bug preventing login in non-shadow environments

This commit is contained in:
Steven Barth 2008-10-01 15:43:12 +00:00
parent fb2f4af1fb
commit 07a8c9c43d

View file

@ -440,6 +440,8 @@ function user.checkpasswd(username, password)
local pwd = account.passwd local pwd = account.passwd
local shadowpw local shadowpw
if #pwd == 1 then if #pwd == 1 then
if luci.fs.stat("/etc/shadow") then
if not pcall(function()
for l in io.lines("/etc/shadow") do for l in io.lines("/etc/shadow") do
shadowpw = l:match("^%s:([^:]+)" % username) shadowpw = l:match("^%s:([^:]+)" % username)
if shadowpw then if shadowpw then
@ -447,6 +449,10 @@ function user.checkpasswd(username, password)
break break
end end
end end
end) then
return nil, "Unable to access shadow-file"
end
end
if pwd == "!" then if pwd == "!" then
return true return true