|
|
5e9bef |
commit 1c557629752d26dca86948c5e933d8f31448818d
|
|
|
5e9bef |
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
|
|
|
5e9bef |
Date: Thu Apr 17 16:15:22 2014 +0200
|
|
|
5e9bef |
|
|
|
5e9bef |
Fix traceback when the history dir is empty. BZ 875610
|
|
|
5e9bef |
|
|
|
5e9bef |
diff --git a/yum/history.py b/yum/history.py
|
|
|
5e9bef |
index 3f20128..2f423d9 100644
|
|
|
5e9bef |
--- a/yum/history.py
|
|
|
5e9bef |
+++ b/yum/history.py
|
|
|
5e9bef |
@@ -697,7 +697,9 @@ class YumHistory:
|
|
|
5e9bef |
break
|
|
|
5e9bef |
|
|
|
5e9bef |
if self._db_file is None:
|
|
|
5e9bef |
- self._create_db_file()
|
|
|
5e9bef |
+ if not self._create_db_file():
|
|
|
5e9bef |
+ # Couldn't create a db file
|
|
|
5e9bef |
+ return
|
|
|
5e9bef |
|
|
|
5e9bef |
# make an addon path for where we're going to stick
|
|
|
5e9bef |
# random additional history info - probably from plugins and what-not
|
|
|
5e9bef |
@@ -1603,8 +1605,10 @@ class YumHistory:
|
|
|
5e9bef |
if os.path.exists(_db_file + '-journal'):
|
|
|
5e9bef |
os.rename(_db_file + '-journal', _db_file + '-journal.old')
|
|
|
5e9bef |
self._db_file = _db_file
|
|
|
5e9bef |
+ if not self.conf.writable:
|
|
|
5e9bef |
+ return False
|
|
|
5e9bef |
|
|
|
5e9bef |
- if self.conf.writable and not os.path.exists(self._db_file):
|
|
|
5e9bef |
+ if not os.path.exists(self._db_file):
|
|
|
5e9bef |
# make them default to 0600 - sysadmin can change it later
|
|
|
5e9bef |
# if they want
|
|
|
5e9bef |
fo = os.open(self._db_file, os.O_CREAT, 0600)
|
|
|
5e9bef |
@@ -1659,6 +1663,7 @@ class YumHistory:
|
|
|
5e9bef |
for op in self._update_ops_3:
|
|
|
5e9bef |
cur.execute(op)
|
|
|
5e9bef |
self._commit()
|
|
|
5e9bef |
+ return True
|
|
|
5e9bef |
|
|
|
5e9bef |
# Pasted from sqlitesack
|
|
|
5e9bef |
_FULL_PARSE_QUERY_BEG = """
|
|
|
5e9bef |
commit 8c6cd83a4825155d1ee9ddcd29b023682944e3e6
|
|
|
5e9bef |
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
|
|
|
5e9bef |
Date: Wed Mar 12 15:41:30 2014 +0100
|
|
|
5e9bef |
|
|
|
5e9bef |
Fix traceback when history files don't exist and user is not root.
|
|
|
5e9bef |
|
|
|
5e9bef |
diff --git a/yum/history.py b/yum/history.py
|
|
|
5e9bef |
index 6f60f54..3f20128 100644
|
|
|
5e9bef |
--- a/yum/history.py
|
|
|
5e9bef |
+++ b/yum/history.py
|
|
|
5e9bef |
@@ -668,6 +668,7 @@ class YumHistory:
|
|
|
5e9bef |
|
|
|
5e9bef |
self.releasever = releasever
|
|
|
5e9bef |
|
|
|
5e9bef |
+ self._db_file = None
|
|
|
5e9bef |
if not os.path.exists(self.conf.db_path):
|
|
|
5e9bef |
try:
|
|
|
5e9bef |
os.makedirs(self.conf.db_path)
|
|
|
5e9bef |
@@ -680,7 +681,6 @@ class YumHistory:
|
|
|
5e9bef |
self.conf.writable = True
|
|
|
5e9bef |
|
|
|
5e9bef |
DBs = glob.glob('%s/history-*-*-*.sqlite' % self.conf.db_path)
|
|
|
5e9bef |
- self._db_file = None
|
|
|
5e9bef |
for d in reversed(sorted(DBs)):
|
|
|
5e9bef |
fname = os.path.basename(d)
|
|
|
5e9bef |
fname = fname[len("history-"):-len(".sqlite")]
|
|
|
5e9bef |
diff --git a/yumcommands.py b/yumcommands.py
|
|
|
5e9bef |
index 4e72a71..75b3ce2 100644
|
|
|
5e9bef |
--- a/yumcommands.py
|
|
|
5e9bef |
+++ b/yumcommands.py
|
|
|
5e9bef |
@@ -3051,7 +3051,7 @@ class HistoryCommand(YumCommand):
|
|
|
5e9bef |
if extcmds and extcmds[0] in ('repeat', 'redo', 'undo', 'rollback', 'new'):
|
|
|
5e9bef |
checkRootUID(base)
|
|
|
5e9bef |
checkGPGKey(base)
|
|
|
5e9bef |
- elif not os.access(base.history._db_file, os.R_OK):
|
|
|
5e9bef |
+ elif not (base.history._db_file and os.access(base.history._db_file, os.R_OK)):
|
|
|
5e9bef |
base.logger.critical(_("You don't have access to the history DB."))
|
|
|
5e9bef |
raise cli.CliError
|
|
|
5e9bef |
|