diff options
author | Steven Barth <steven@midlink.org> | 2008-09-29 16:02:54 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-29 16:02:54 +0000 |
commit | a63363130730a543c1a7291f18068f027b83c9ed (patch) | |
tree | 7472c85bc8369c73d58b133e37be9fe439ef8633 /libs/sys | |
parent | 40540257aec8d0a32ef68b499ea2fe6416199a19 (diff) |
Added support for shadow passwords
Diffstat (limited to 'libs/sys')
-rw-r--r-- | libs/sys/luasrc/sys.lua | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index b3155c8c8..4bf294678 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -437,11 +437,23 @@ function user.checkpasswd(username, password) local account = user.getuser(username) if account then - if account.passwd == "!" then + local pwd = account.passwd + if pwd == "!" then return true - else - return (account.passwd == posix.crypt(password, account.passwd)) + elseif pwd == "x" then + 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 + + return (pwd == posix.crypt(password, pwd)) end end |