142 end |
142 end |
143 end |
143 end |
144 |
144 |
145 do -- Lua to shell calls. |
145 do -- Lua to shell calls. |
146 local function shell_escape(s) |
146 local function shell_escape(s) |
147 return s:gsub("'",[['\'']]); |
147 return "'" .. tostring(s):gsub("'",[['\'']]) .. "'"; |
148 end |
148 end |
149 |
149 |
150 local function serialize(f,o) |
150 local function serialize(f,o) |
151 local r = {"openssl", f}; |
151 local r = {"openssl", f}; |
152 for k,v in pairs(o) do |
152 for k,v in pairs(o) do |
153 if type(k) == "string" then |
153 if type(k) == "string" then |
154 t_insert(r, ("-%s"):format(k)); |
154 t_insert(r, ("-%s"):format(k)); |
155 if v ~= true then |
155 if v ~= true then |
156 t_insert(r, ("'%s'"):format(shell_escape(tostring(v)))); |
156 t_insert(r, shell_escape(v)); |
157 end |
157 end |
158 end |
158 end |
159 end |
159 end |
160 for _,v in ipairs(o) do |
160 for _,v in ipairs(o) do |
161 t_insert(r, ("'%s'"):format(shell_escape(tostring(v)))); |
161 t_insert(r, shell_escape(v)); |
162 end |
162 end |
163 return t_concat(r, " "); |
163 return t_concat(r, " "); |
164 end |
164 end |
165 |
165 |
166 local os_execute = os.execute; |
166 local os_execute = os.execute; |