summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-01-01 16:20:35 +0000
committerTed Trask <ttrask01@yahoo.com>2013-01-01 16:20:35 +0000
commitc7d87ae077f51895dfcdd1b19628a09121d78e52 (patch)
treee2454d4ef37c71ffa573248995c8e978a4bda39e
parentd7460a8bd3b2fd106957434e2c1ae5135f72fddd (diff)
downloadacf-chrony-c7d87ae077f51895dfcdd1b19628a09121d78e52.tar.bz2
acf-chrony-c7d87ae077f51895dfcdd1b19628a09121d78e52.tar.xz
Replace subprocess.popen with modelfunctions.run_executable
-rw-r--r--chrony-model.lua29
1 files changed, 1 insertions, 28 deletions
diff --git a/chrony-model.lua b/chrony-model.lua
index d63ec63..80a59e3 100644
--- a/chrony-model.lua
+++ b/chrony-model.lua
@@ -6,7 +6,6 @@ format = require("acf.format")
fs = require("acf.fs")
validator = require("acf.validator")
processinfo = require("acf.processinfo")
-require("subprocess")
require("posix")
-- Set variables
@@ -15,8 +14,6 @@ local processname = "chronyd"
local packagename = "chrony"
local keyfile = "/etc/chrony/chrony.keys"
-local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
-
-- ################################################################################
-- LOCAL FUNCTIONS
@@ -91,31 +88,7 @@ function startstop_service(self, startstop, action)
if not password then
startstop.errtxt = "Could not find password in key file"
else
- local res, err = pcall(function()
- -- For security, set the path
- posix.setenv("PATH", "/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin")
-
- local args = {"chronyc", "-m", "password", lower}
- args.stdin = subprocess.PIPE
- args.stdout = subprocess.PIPE
- args.stderr = "/dev/null"
- local proc, errmsg, errno = subprocess.popen(args)
- if proc then
- proc.stdin:write(password.."\n")
- proc.stdin:close()
- proc:wait()
- startstop.descr = proc.stdout:read("*a")
- if proc.exitcode ~= 0 then
- startstop.errtxt = startstop.descr
- startstop.descr = nil
- end
- else
- startstop.errtxt = errmsg or "Unknown failure"
- end
- end)
- if not res or err then
- startstop.errtxt = err or "Unknown failure"
- end
+ startstop.descr, startstop.errtxt = modelfunctions.run_executable({"chronyc", "-m", "password", lower}, false, password.."\n")
end
end
else