From c7d87ae077f51895dfcdd1b19628a09121d78e52 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 1 Jan 2013 16:20:35 +0000 Subject: Replace subprocess.popen with modelfunctions.run_executable --- chrony-model.lua | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'chrony-model.lua') 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 -- cgit v1.2.3