summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-10-01 15:43:12 +0000
committerSteven Barth <steven@midlink.org>2008-10-01 15:43:12 +0000
commit07a8c9c43ddecbad508096b8bb1c86bb92c869d1 (patch)
tree0e71ae811c0f96a1934e0b7bf75b7d04476ad8df
parentfb2f4af1fbc0170827b7ed17be681a30fc0fca86 (diff)
Fix a bug preventing login in non-shadow environments
-rw-r--r--libs/sys/luasrc/sys.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua
index 0bf92e9da..0c18a3636 100644
--- a/libs/sys/luasrc/sys.lua
+++ b/libs/sys/luasrc/sys.lua
@@ -440,11 +440,17 @@ function user.checkpasswd(username, password)
local pwd = account.passwd
local shadowpw
if #pwd == 1 then
- for l in io.lines("/etc/shadow") do
- shadowpw = l:match("^%s:([^:]+)" % username)
- if shadowpw then
- pwd = shadowpw
- break
+ if luci.fs.stat("/etc/shadow") then
+ if not pcall(function()
+ for l in io.lines("/etc/shadow") do
+ shadowpw = l:match("^%s:([^:]+)" % username)
+ if shadowpw then
+ pwd = shadowpw
+ break
+ end
+ end
+ end) then
+ return nil, "Unable to access shadow-file"
end
end