summaryrefslogtreecommitdiffhomepage
path: root/libs/core/luasrc
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-06-28 16:03:54 +0000
committerSteven Barth <steven@midlink.org>2008-06-28 16:03:54 +0000
commit00aceaf624d8e5da2a8f3df161d52599aae2ac41 (patch)
treec18d8c411f8d4a02762a478348fd8a86b4f56f5a /libs/core/luasrc
parent7f56bf947599b20e2cf50018e160e602d5516e5f (diff)
* libs/web: Switched from HTTP-Basic-Auth to Session-Auth
* Updated Makefiles for better testing environment integration * Fixed libs/sgi-luci
Diffstat (limited to 'libs/core/luasrc')
-rw-r--r--libs/core/luasrc/fs.lua3
-rw-r--r--libs/core/luasrc/sys.lua16
2 files changed, 15 insertions, 4 deletions
diff --git a/libs/core/luasrc/fs.lua b/libs/core/luasrc/fs.lua
index 5c1f2a051b..415e8e567c 100644
--- a/libs/core/luasrc/fs.lua
+++ b/libs/core/luasrc/fs.lua
@@ -28,6 +28,9 @@ module("luci.fs", package.seeall)
require("posix")
+-- Access
+access = posix.access
+
-- Glob
glob = posix.glob
diff --git a/libs/core/luasrc/sys.lua b/libs/core/luasrc/sys.lua
index 54c4e06137..540a636fb8 100644
--- a/libs/core/luasrc/sys.lua
+++ b/libs/core/luasrc/sys.lua
@@ -285,10 +285,18 @@ user = {}
user.getuser = posix.getpasswd
-- checks whether a string matches the password of a certain system user
-function user.checkpasswd(user, password)
- local account = user.getuser(user)
- if posix.crypt and account then
- return (account.passwd == posix.crypt(account.passwd, password))
+function user.checkpasswd(username, password)
+ local account = user.getuser(username)
+
+ -- FIXME: detect testing environment
+ if luci.fs.isfile("/etc/shadow") and not luci.fs.access("/etc/shadow", "r") then
+ return true
+ elseif account then
+ if account.passwd == "!" then
+ return true
+ else
+ return (account.passwd == posix.crypt(account.passwd, password))
+ end
end
end