aboutsummaryrefslogtreecommitdiff
path: root/ca
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-02-13 01:51:42 +0000
committerRob Austein <sra@hactrn.net>2016-02-13 01:51:42 +0000
commitdb83816ceb92fe1fae2aad1aa83230e47fc8639d (patch)
tree0df6e8221d3962f652c91f633fe47c5c4aaaaa83 /ca
parent7efae58be1aa009dda9bc63172636986ed1d2cd8 (diff)
Add back some logging.
svn path=/branches/tk705/; revision=6253
Diffstat (limited to 'ca')
-rwxr-xr-xca/rpki-sql-setup40
1 files changed, 27 insertions, 13 deletions
diff --git a/ca/rpki-sql-setup b/ca/rpki-sql-setup
index 31f0bd51..94e9d3ae 100755
--- a/ca/rpki-sql-setup
+++ b/ca/rpki-sql-setup
@@ -64,6 +64,8 @@ class MySQL_Driver(Abstract_Driver):
def _initialize(self):
if not self._initialized:
+ if self.args.verbose:
+ print "Initializing MySQL driver"
if self.args.mysql_defaults:
mysql_cfg = rpki.config.parser(set_filename = self.args.mysql_defaults, section = "client")
self._db = self.driver.connect(db = "mysql",
@@ -142,21 +144,33 @@ class PostgreSQL_Driver(Abstract_Driver):
self._pw = pwd.getpwnam(args.postgresql_root_username)
else:
self._pw = None
+ if self.args.verbose:
+ print "Initialized PostgreSQL driver, pw {!r}".format(pw)
def _execute(self, *sql_commands):
- pid = None if self._pw is None else os.fork()
- if pid == 0:
- os.setgid(self._pw.pw_gid)
- os.setuid(self._pw.pw_uid)
- if not pid:
- with self.driver.connect(database = self.args.postgresql_root_database) as db:
- with db.cursor() as cur:
- for sql_command in sql_commands:
- cur.execute(command)
- if pid == 0:
- os._exit(0)
- if pid:
- os.waitpid(pid, 0)
+ try:
+ pid = None if self._pw is None else os.fork()
+ if self.args.verbose:
+ print "PostgreSQL driver fork {}".format(pid)
+ if pid == 0:
+ os.setgid(self._pw.pw_gid)
+ os.setuid(self._pw.pw_uid)
+ if not pid:
+ with self.driver.connect(database = self.args.postgresql_root_database) as db:
+ with db.cursor() as cur:
+ for sql_command in sql_commands:
+ if self.args.verbose:
+ print "PostgreSQL driver executing {!r}".format(sql_command)
+ cur.execute(command)
+ if pid == 0:
+ os._exit(0)
+ elif pid:
+ os.waitpid(pid, 0)
+ except Exception as e:
+ if self.args.verbose:
+ print "PostgreSQL driver exception {!s}".format(e)
+ if pid == 0:
+ os._exit(1)
def _accessible_test(self, udb):
self.driver.connect(database = udb.database, user = udb.username , password = usb.password).close()