X-Git-Url: http://git.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fcore%2Fluasrc%2Fsys.lua;h=17caa782412a326f6626543efc7bd47a7264b202;hp=0399d0e5f0a972fb362e6a75136673dec179ba25;hb=eae0e447989a1a37ce6cb8df9f1f353738aab4f6;hpb=d35a620e9f5665a94967f4bd02c93581a1dd7e00 diff --git a/libs/core/luasrc/sys.lua b/libs/core/luasrc/sys.lua index 0399d0e5f0..17caa78241 100644 --- a/libs/core/luasrc/sys.lua +++ b/libs/core/luasrc/sys.lua @@ -75,6 +75,9 @@ function flash(image, kpattern) return os.execute(cmd) end +-- Returns the enivornment +getenv = posix.getenv + -- Returns the hostname function hostname() return io.lines("/proc/sys/kernel/hostname")() @@ -263,6 +266,14 @@ end user = {} -- returns user information to a given uid 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)) + end +end -- Changes the user password of given user function user.setpasswd(user, pwd) @@ -368,4 +379,4 @@ function _parse_mixed_record(cnt) end return data -end \ No newline at end of file +end