Fix a bug preventing login in non-shadow environments
This commit is contained in:
parent
fb2f4af1fb
commit
07a8c9c43d
1 changed files with 11 additions and 5 deletions
|
@ -440,11 +440,17 @@ 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
|
||||||
for l in io.lines("/etc/shadow") do
|
if luci.fs.stat("/etc/shadow") then
|
||||||
shadowpw = l:match("^%s:([^:]+)" % username)
|
if not pcall(function()
|
||||||
if shadowpw then
|
for l in io.lines("/etc/shadow") do
|
||||||
pwd = shadowpw
|
shadowpw = l:match("^%s:([^:]+)" % username)
|
||||||
break
|
if shadowpw then
|
||||||
|
pwd = shadowpw
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end) then
|
||||||
|
return nil, "Unable to access shadow-file"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue