summaryrefslogtreecommitdiffstats
path: root/openssh-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-20 00:42:26 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-20 00:42:26 +0000
commit55af840c552e9d86797d4c53b6628351f0350b26 (patch)
treef330bdbec1169b6a64b005ded41b00a8a52ddc71 /openssh-model.lua
parent739a930c1f1825131d31d1ee7220fdfb83ad2538 (diff)
downloadacf-openssh-55af840c552e9d86797d4c53b6628351f0350b26.tar.bz2
acf-openssh-55af840c552e9d86797d4c53b6628351f0350b26.tar.xz
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition. This was also helpful in revealing places where the code relied on the global environment.
Diffstat (limited to 'openssh-model.lua')
-rw-r--r--openssh-model.lua34
1 files changed, 18 insertions, 16 deletions
diff --git a/openssh-model.lua b/openssh-model.lua
index 4c81417..8eb946b 100644
--- a/openssh-model.lua
+++ b/openssh-model.lua
@@ -1,4 +1,4 @@
-module(..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -46,27 +46,27 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
-function get_startstop(self, clientdata)
+function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(processname)
end
-function startstop_service(self, startstop, action)
+function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
-function getstatus()
+function mymodule.getstatus()
return modelfunctions.getstatus(processname, packagename, header .. " status")
end
-function getconfigfile()
+function mymodule.getconfigfile()
return modelfunctions.getfiledetails(configfile)
end
-function setconfigfile(self, filedetails)
+function mymodule.setconfigfile(self, filedetails)
return modelfunctions.setfiledetails(self, filedetails, {configfile})
end
-function read_config()
+function mymodule.read_config()
local output = {}
output.Port = cfe({ value=22, label="Port", seq=1 })
output.ListenAddress = cfe({ value="0.0.0.0", label="Listen address", seq=2 })
@@ -86,7 +86,7 @@ function read_config()
return cfe({ type="group", value=output, label="OpenSSH Config" })
end
-function update_config(self, config)
+function mymodule.update_config(self, config)
local success, config = validate_config(config)
if success then
@@ -123,12 +123,12 @@ function update_config(self, config)
return config
end
-function list_conn_peers()
+function mymodule.list_conn_peers()
local output = {}
local netstat = {}
local ps = {}
local who = {}
- config = read_config()
+ config = mymodule.read_config()
local f = modelfunctions.run_executable({"netstat", "-lnaW"})
local flines = format.search_for_lines(f, "ESTABLISHED")
local g = modelfunctions.run_executable({"netstat", "-laW"})
@@ -179,7 +179,7 @@ function list_conn_peers()
return output
end
-function list_users()
+function mymodule.list_users()
local users = {"root"}
-- The only users we're going to worry about in this ACF are root and ones with home directories
for user in posix.files("/home") do
@@ -206,7 +206,7 @@ local function parseauthline(line)
return retval
end
-function list_auths(user)
+function mymodule.list_auths(user)
user = user or "root"
local cmdresult = cfe({ type="group", value={}, label="Authorized Key List" })
cmdresult.value.user = cfe({ value=user, label="User" })
@@ -225,14 +225,14 @@ function list_auths(user)
return cmdresult
end
-function get_delete_auth(self, clientdata)
+function mymodule.get_delete_auth(self, clientdata)
local retval = {}
retval.user = cfe({ value=clientdata.user or "root", label="User" })
retval.auth = cfe({ value=clientdata.auth or "", label="Authorized Key" })
return cfe({ type="group", value=retval, label="Delete Authorized Key" })
end
-function delete_auth(self, delauth)
+function mymodule.delete_auth(self, delauth)
local user = delauth.value.user.value
delauth.value.user.errtxt = "User not found"
delauth.errtxt = "Failed to delete key"
@@ -262,7 +262,7 @@ function delete_auth(self, delauth)
return delauth
end
-function get_auth(user)
+function mymodule.get_auth(user)
local cmdresult = cfe({ type="group", value={}, label="Authorized Key List" })
cmdresult.value.user = cfe({ value=user or "root", label="User", seq=1 })
if user then
@@ -272,7 +272,7 @@ function get_auth(user)
return cmdresult
end
-function create_auth(self, authstr)
+function mymodule.create_auth(self, authstr)
authstr.value.user.value = authstr.value.user.value or "root"
local success = true
if not authstr.value.user.value == "root" and (string.find(authstr.value.user.value, "/") or not fs.is_dir("/home/"..authstr.value.user.value)) then
@@ -334,3 +334,5 @@ function create_auth(self, authstr)
end
return authstr
end
+
+return mymodule