* Added support for CGI SGI
[project/luci.git] / libs / core / luasrc / sys.lua
index 0399d0e5f0a972fb362e6a75136673dec179ba25..17caa782412a326f6626543efc7bd47a7264b202 100644 (file)
@@ -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