summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2014-10-30 00:59:46 +0000
committerTed Trask <ttrask01@yahoo.com>2014-10-30 00:59:46 +0000
commit1b55948641c15d15ca01d09e2fb093b97f3cdb70 (patch)
treeccf91a884aa8ec78eeb6050bd4adb2a4184cb427
parent06c12c2ea537b6d33d5a649fd657afc604face4d (diff)
downloadacf-lib-1b55948641c15d15ca01d09e2fb093b97f3cdb70.tar.bz2
acf-lib-1b55948641c15d15ca01d09e2fb093b97f3cdb70.tar.xz
Use the specified user for db.lua listdatabases
-rw-r--r--db.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/db.lua b/db.lua
index adcc25a..2de44c3 100644
--- a/db.lua
+++ b/db.lua
@@ -166,7 +166,16 @@ end
export.listdatabases = function(dbobject)
local result = {}
if dbobject.engine == mymodule.engine.postgresql then
- local cmd = {"psql", "-U", "postgres", "-lt"}
+ local cmd = {"psql", "-lt", "-U"}
+ local stdin
+ if dbobject.user and dbobject.user ~= "" then
+ cmd[#cmd+1] = dbobject.user
+ else
+ cmd[#cmd+1] = "postgres"
+ end
+ if dbobject.password and dbobject.password ~= "" then
+ -- Have never seen a need to use password
+ end
if dbobject.host and dbobject.host ~= "" then
cmd[#cmd+1] = "-h"
cmd[#cmd+1] = dbobject.host
@@ -176,7 +185,6 @@ export.listdatabases = function(dbobject)
cmd[#cmd+1] = dbobject.port
end
cmd["stderr"]=subprocess.STDOUT
-APP.logevent("calling: "..table.concat(cmd, " "))
local code, cmdresult = subprocess.call_capture(cmd)
if code ~= 0 then
error(cmdresult, 0)