summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-26 15:53:09 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-26 15:53:09 -0500
commite3ff067d9b2797f1878b0cd2c10a8d22a3a94c22 (patch)
tree2935e609698d6dc66a07e0c74b77bbbbaa5a114b /src
parentb511a3d195b13b722171550138d74e05540ad6a8 (diff)
downloadbcfg2-e3ff067d9b2797f1878b0cd2c10a8d22a3a94c22.tar.gz
bcfg2-e3ff067d9b2797f1878b0cd2c10a8d22a3a94c22.tar.bz2
bcfg2-e3ff067d9b2797f1878b0cd2c10a8d22a3a94c22.zip
fixed core syncdb in non-daemon contexts (e.g., bcfg2-info)
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Core.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index 76fdbc4af..9a9061a51 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -180,10 +180,11 @@ class BaseCore(object):
#: backend for plugins that have that capability
self._database_available = False
if Bcfg2.settings.HAS_DJANGO:
- db = Bcfg2.settings.DATABASES['default']
- if (self.setup['daemon'] and self.setup['daemon_uid'] and
- db['ENGINE'].endswith(".sqlite3") and
- not os.path.exists(db['NAME'])):
+ db_settings = Bcfg2.settings.DATABASES['default']
+ if ('daemon' in self.setup and 'daemon_uid' in self.setup and
+ self.setup['daemon'] and self.setup['daemon_uid'] and
+ db_settings['ENGINE'].endswith(".sqlite3") and
+ not os.path.exists(db_settings['NAME'])):
# syncdb will create the sqlite database, and we're
# going to daemonize, dropping privs to a non-root
# user, so we need to chown the database after
@@ -207,13 +208,13 @@ class BaseCore(object):
if do_chown and self._database_available:
try:
- os.chown(db['NAME'],
+ os.chown(db_settings['NAME'],
self.setup['daemon_uid'],
self.setup['daemon_gid'])
except OSError:
err = sys.exc_info()[1]
self.logger.error("Failed to set ownership of database "
- "at %s: %s" % (db['NAME'], err))
+ "at %s: %s" % (db_settings['NAME'], err))
if '' in setup['plugins']:
setup['plugins'].remove('')