1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
From 5b79e28bd70a0ec5b34c5ff19b66cbbdd1e48835 Mon Sep 17 00:00:00 2001
From: Haiqing Bai <Haiqing.Bai@windriver.com>
Date: Fri, 18 Mar 2016 13:34:07 +0800
Subject: [PATCH] Make smartpm to support check signatures of rpmv5.
The original support for 'rpm-check-signatures' has been
disabled for the RPMv5 does not support '_RPMVSF_NOSIGNATURES'
now. This fix replaces the '_RPMVSF_NOSIGNATURES' with
rpm VS flags set:RPMVSF_NODSAHEADER|RPMVSF_NORSAHEADER|
RPMVSF_NODSA|RPMVSF_NORSA.
Upstream-Status: Pending
Signed-off-by: Haiqing Bai <Haiqing.Bai@windriver.com>
---
smart/backends/rpm/base.py | 43 +++++++++++++++++++++++++++++++----------
smart/backends/rpm/pm.py | 2 +-
smart/plugins/yumchannelsync.py | 5 +++--
3 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/smart/backends/rpm/base.py b/smart/backends/rpm/base.py
index 85f4d49..dbd6165 100644
--- a/smart/backends/rpm/base.py
+++ b/smart/backends/rpm/base.py
@@ -63,11 +63,23 @@ def getTS(new=False):
if sysconf.get("rpm-dbpath"):
rpm.addMacro('_dbpath', "/" + sysconf.get("rpm-dbpath"))
getTS.ts = rpm.ts(getTS.root)
- if not sysconf.get("rpm-check-signatures", False):
- if hasattr(rpm, '_RPMVSF_NOSIGNATURES'):
- getTS.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
- else:
- raise Error, _("rpm requires checking signatures")
+
+ # _RPMVSF_NOSIGNATURES is not supported in RPMv5, so here uses
+ # RPMVSF_NODSAHEADER|RPMVSF_NORSAHEADER|RPMVSF_NODSA|RPMVSF_NORSA
+ # to replace '_RPMVSF_NOSIGNATURES' to continue to support check
+ # rpm signatures
+
+ #if not sysconf.get("rpm-check-signatures", False):
+ # if hasattr(rpm, '_RPMVSF_NOSIGNATURES'):
+ # getTS.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
+ # else:
+ # raise Error, _("rpm requires checking signatures")
+ if sysconf.get("rpm-check-signatures") == False:
+ getTS.ts.setVSFlags(rpm.RPMVSF_NODSAHEADER|rpm.RPMVSF_NORSAHEADER|\
+ rpm.RPMVSF_NODSA|rpm.RPMVSF_NORSA)
+ else:
+ getTS.ts.setVSFlags(0)
+
rpm_dbpath = sysconf.get("rpm-dbpath", "var/lib/rpm")
dbdir = rpm_join_dbpath(getTS.root, rpm_dbpath)
if not os.path.isdir(dbdir):
@@ -89,11 +101,22 @@ def getTS(new=False):
if sysconf.get("rpm-dbpath"):
rpm.addMacro('_dbpath', "/" + sysconf.get("rpm-dbpath"))
ts = rpm.ts(getTS.root)
- if not sysconf.get("rpm-check-signatures", False):
- if hasattr(rpm, '_RPMVSF_NOSIGNATURES'):
- ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
- else:
- raise Error, _("rpm requires checking signatures")
+
+ # _RPMVSF_NOSIGNATURES is not supported in RPMv5, so here uses
+ # RPMVSF_NODSAHEADER|RPMVSF_NORSAHEADER|RPMVSF_NODSA|RPMVSF_NORSA
+ # to replace '_RPMVSF_NOSIGNATURES' to continue to support check
+ # rpm signatures
+
+ #if not sysconf.get("rpm-check-signatures", False):
+ # if hasattr(rpm, '_RPMVSF_NOSIGNATURES'):
+ # ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
+ # else:
+ # raise Error, _("rpm requires checking signatures")
+ if sysconf.get("rpm-check-signatures") == False:
+ ts.setVSFlags(rpm.RPMVSF_NODSAHEADER|rpm.RPMVSF_NORSAHEADER|\
+ rpm.RPMVSF_NODSA|rpm.RPMVSF_NORSA)
+ else:
+ ts.setVSFlags(0)
return ts
else:
return getTS.ts
diff --git a/smart/backends/rpm/pm.py b/smart/backends/rpm/pm.py
index b57a844..7b651b5 100644
--- a/smart/backends/rpm/pm.py
+++ b/smart/backends/rpm/pm.py
@@ -180,7 +180,7 @@ class RPMPackageManager(PackageManager):
fd = os.open(path, os.O_RDONLY)
try:
h = ts.hdrFromFdno(fd)
- if sysconf.get("rpm-check-signatures", False):
+ if sysconf.get("rpm-check-signatures", True):
if get_public_key(h) == '(none)':
raise rpm.error('package is not signed')
except rpm.error, e:
diff --git a/smart/plugins/yumchannelsync.py b/smart/plugins/yumchannelsync.py
index f8107e6..2dc5482 100644
--- a/smart/plugins/yumchannelsync.py
+++ b/smart/plugins/yumchannelsync.py
@@ -56,8 +56,9 @@ def _getreleasever():
rpmroot = sysconf.get("rpm-root", "/")
ts = rpmUtils.transaction.initReadOnlyTransaction(root=rpmroot)
- if hasattr(rpm, '_RPMVSF_NOSIGNATURES') and hasattr(rpm, '_RPMVSF_NODIGESTS'):
- ts.pushVSFlags(~(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
+ #_RPMVSF_NOSIGNATURES is not supported in RPMv5
+ #if hasattr(rpm, '_RPMVSF_NOSIGNATURES') and hasattr(rpm, '_RPMVSF_NODIGESTS'):
+ # ts.pushVSFlags(~(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
releasever = None
# HACK: we're hard-coding the most used distros, will add more if needed
idx = ts.dbMatch('provides', 'fedora-release')
--
1.9.1
|