Added support for shadow passwords
This commit is contained in:
parent
40540257ae
commit
a633631307
1 changed files with 15 additions and 3 deletions
|
@ -437,11 +437,23 @@ function user.checkpasswd(username, password)
|
||||||
local account = user.getuser(username)
|
local account = user.getuser(username)
|
||||||
|
|
||||||
if account then
|
if account then
|
||||||
if account.passwd == "!" then
|
local pwd = account.passwd
|
||||||
|
if pwd == "!" then
|
||||||
return true
|
return true
|
||||||
else
|
elseif pwd == "x" then
|
||||||
return (account.passwd == posix.crypt(password, account.passwd))
|
pwd = nil
|
||||||
|
for l in io.lines("/etc/shadow") do
|
||||||
|
pwd = l:match("^%s:([^:]+)" % username)
|
||||||
|
if pwd then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not pwd then
|
||||||
|
return nil, "No shadow password for " .. username
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return (pwd == posix.crypt(password, pwd))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue