diff options
Diffstat (limited to 'src/ffluci/sys.lua')
-rw-r--r-- | src/ffluci/sys.lua | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/ffluci/sys.lua b/src/ffluci/sys.lua index 4ed2262c8b..97a926b0b1 100644 --- a/src/ffluci/sys.lua +++ b/src/ffluci/sys.lua @@ -25,7 +25,7 @@ limitations under the License. ]]-- module("ffluci.sys", package.seeall) -require("ffluci.fs") +require("posix") -- Returns the hostname function hostname() @@ -38,11 +38,40 @@ function loadavg() return loadavg:match("^(.-) (.-) (.-) (.-) (.-)$") end + +group = {} +group.getgroup = posix.getgroup + +net = {} -- Returns all available network interfaces -function net_devices() +function net.devices() local devices = {} for line in io.lines("/proc/net/dev") do table.insert(devices, line:match(" *(.-):")) end return devices +end + +process = {} +process.info = posix.getpid + +-- Sets the gid of a process +function process.setgroup(pid, gid) + return posix.setpid("g", pid, gid) +end + +-- Sets the uid of a process +function process.setuser(pid, uid) + return posix.setpid("u", pid, uid) +end + +user = {} +-- returns user information to a given uid +user.getuser = posix.getpasswd + +-- Changes the user password of given user +function user.setpasswd(user, pwd1, pwd2) + local cmd = "(echo '"..pwd1.."';sleep 1;echo '"..pwd2.."')|" + cmd = cmd .. "passwd "..user.." 2>&1" + return ffluci.util.exec(cmd) end
\ No newline at end of file |