backend/common/rhnException.py | 2
backend/po/server.pot | 2
backend/server/rhnPackage.py | 9 -
backend/server/rhnPackageUpload.py | 56 +++++-----
backend/server/rhnServer/server_packages.py | 9 -
backend/upload_server/handlers/package_push/package_push.py | 14 +-
backend/upload_server/handlers/package_upload/package_upload.py | 14 +-
java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml | 2
8 files changed, 57 insertions(+), 51 deletions(-)
New commits:
commit 3aa4f56ccf90b9323b3a535dcec727640d7d66d3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 16:34:43 2009 +0200
fixed list of yum repo checksums in Create Software Channel
diff --git a/java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml b/java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml
index dea8be7..a95f1eb 100644
--- a/java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml
@@ -21,7 +21,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
</query>
<query name="ChecksumType.loadAllForYum">
<![CDATA[from com.redhat.rhn.domain.common.ChecksumType as t
- where t.label = 'sha-256' or t.label = 'sha1']]>
+ where t.label like 'sha%']]>
</query>
<query name="ChecksumType.findById">
<![CDATA[from com.redhat.rhn.domain.common.ChecksumType as t where t.id = :id]]>
commit eafffb374cee30d30d60417a5cc0b696de0eb7c7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 14:38:10 2009 +0200
fixed error message #501
diff --git a/backend/common/rhnException.py b/backend/common/rhnException.py
index a6a54fc..a91bd4f 100644
--- a/backend/common/rhnException.py
+++ b/backend/common/rhnException.py
@@ -223,7 +223,7 @@ maximum membership exceeded"),
# 500-599: Package Uploader errors
500: _("Missing HTTP header information"),
- 501: _("The package's md5sum signature does not match the header one"),
+ 501: _("The package's checksum signature does not match the header one"),
502: _("Header information does not match package metainformation"),
503: _("Package with a different signature already uploaded"),
504: _("Not an RPM package"),
diff --git a/backend/po/server.pot b/backend/po/server.pot
index b8be17e..33f28ff 100644
--- a/backend/po/server.pot
+++ b/backend/po/server.pot
@@ -938,7 +938,7 @@ msgid "Missing HTTP header information"
msgstr ""
#: ../common/rhnException.py:196
-msgid "The package's md5sum signature does not match the header one"
+msgid "The package's checksum signature does not match the header one"
msgstr ""
#: ../common/rhnException.py:197
commit 700a775f7a2b1e84d0d953e3b33b08164847e7ac
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 14:26:29 2009 +0200
changes in upload_server/handlers/package_upload/package_upload.py to reflect new rhnChecksum table
diff --git a/backend/upload_server/handlers/package_upload/package_upload.py b/backend/upload_server/handlers/package_upload/package_upload.py
index b087ca9..f8d22cc 100644
--- a/backend/upload_server/handlers/package_upload/package_upload.py
+++ b/backend/upload_server/handlers/package_upload/package_upload.py
@@ -45,17 +45,17 @@ class PackageUpload(basePackageUpload.BasePackageUpload):
try:
rhnPackageUpload.check_package_exists(self.package_path,
- self.file_md5sum, force=0)
+ self.file_checksum, force=0)
except rhnPackageUpload.AlreadyUploadedError:
log_debug(2, "Already exists", self.rel_package_path)
return apache.HTTP_CREATED
except rhnPackageUpload.PackageConflictError, e:
- log_error("Different md5sums", self.package_path)
+ log_error("Different checksums", self.package_path)
rhnFlags.set("apache-return-code", apache.HTTP_CONFLICT)
raise rhnFault(104,
"Package %s (%s) already exists, with checksum %s " %
(os.path.basename(self.package_path),
- self.file_md5sum, e.args[1]))
+ self.file_checksum, e.args[1]))
return apache.OK
@@ -70,13 +70,13 @@ class PackageUpload(basePackageUpload.BasePackageUpload):
log_debug(4, "Header length", len(req.headers_in[i]))
temp_stream = rhnPackageUpload.write_temp_file(req, buffer_size)
- header, payload_stream, md5sum, header_start, header_end = \
+ header, payload_stream, checksum, header_start, header_end = \
rhnPackageUpload.load_package(temp_stream)
temp_stream.close()
- if self.file_md5sum != md5sum:
+ if self.file_checksum != checksum:
raise rhnFault(501, "Uploaded: %s; filesystem: %s" %
- (self.file_md5sum, md5sum))
+ (self.file_checksum, checksum))
if not rhnPackageUpload.source_match(self.is_source, header.is_source):
# Unexpected rpm package type
@@ -107,7 +107,7 @@ class PackageUpload(basePackageUpload.BasePackageUpload):
if not header.is_signed:
rhnFlags.set("apache-return-code", apache.HTTP_CONFLICT)
raise rhnFault(103, "Package %s (%s) is not signed" %
- (os.path.basename(self.package_path), self.file_md5sum))
+ (os.path.basename(self.package_path), self.file_checksum))
payload_stream.seek(0, 0)
dirname = os.path.dirname(self.package_path)
commit f8751ac28846a999a79d49109cf608a8303ba7c6
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 14:25:00 2009 +0200
changes in upload_server/handlers/package_push/package_push.py to reflect new rhnChecksum table
diff --git a/backend/upload_server/handlers/package_push/package_push.py b/backend/upload_server/handlers/package_push/package_push.py
index 2115ada..1894409 100644
--- a/backend/upload_server/handlers/package_push/package_push.py
+++ b/backend/upload_server/handlers/package_push/package_push.py
@@ -114,13 +114,13 @@ class PackagePush(basePackageUpload.BasePackageUpload):
temp_stream = rhnPackageUpload.write_temp_file(req, 16384)
- header, payload_stream, md5sum, header_start, header_end = \
+ header, payload_stream, checksum, header_start, header_end = \
rhnPackageUpload.load_package(temp_stream)
# Sanity check - removed, the package path can no longer be determined
# without the header
self.rel_package_path = rhnPackageUpload.relative_path_from_header(
- header, org_id=self.org_id, md5sum=md5sum)
+ header, org_id=self.org_id, checksum=checksum)
self.package_path = os.path.join(CFG.MOUNT_POINT,
self.rel_package_path)
# XXX need to clean this up
@@ -132,15 +132,15 @@ class PackagePush(basePackageUpload.BasePackageUpload):
# log_debug(1, "Mismatching paths", relative_path,
# self.rel_package_path)
# raise rhnFault(104, "Mismatching information")
- # Verify the md5sum of the bytes we downloaded against the md5sum
+ # Verify the checksum of the bytes we downloaded against the checksum
# presented by rhnpush in the HTTP headers
- if md5sum != self.file_md5sum:
- log_debug(1, "Mismatching md5sums: expected", self.file_md5sum,
- "; got:", md5sum)
+ if checksum != self.file_checksum:
+ log_debug(1, "Mismatching checksum: expected", self.file_checksum,
+ "; got:", checksum)
raise rhnFault(104, "Mismatching information")
package_dict, diff_level = rhnPackageUpload.push_package(header,
- payload_stream, md5sum, force=self.force,
+ payload_stream, checksum, force=self.force,
header_start=header_start, header_end=header_end,
relative_path=self.rel_package_path, org_id=self.org_id)
commit b7cfb72ef411048a7c97db9efbc4e31dcd2665a2
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 14:22:43 2009 +0200
changes in server/rhnServer/server_packages.py to reflect new rhnChecksum table
diff --git a/backend/server/rhnServer/server_packages.py b/backend/server/rhnServer/server_packages.py
index b5a5156..d026f46 100644
--- a/backend/server/rhnServer/server_packages.py
+++ b/backend/server/rhnServer/server_packages.py
@@ -374,7 +374,7 @@ def update_errata_cache(server_id):
# Return the number of changes
return changed
-def processPackageKeyAssociations(header, md5sum):
+def processPackageKeyAssociations(header, checksum):
provider_sql = rhnSQL.prepare("""
insert into rhnPackageKeyAssociation
(package_id, key_id) values
@@ -401,8 +401,9 @@ def processPackageKeyAssociations(header, md5sum):
lookup_pkgid_sql = rhnSQL.prepare("""
select id
- from rhnPackage
- where md5sum = :md5sum
+ from rhnPackage, rhnChecksum c
+ where c.checksum = :checksum
+ and p.checksum_id = c.id
""")
lookup_pkgkey_sql = rhnSQL.prepare("""
@@ -412,7 +413,7 @@ def processPackageKeyAssociations(header, md5sum):
and key_id = :key_id
""")
- lookup_pkgid_sql.execute(md5sum = md5sum)
+ lookup_pkgid_sql.execute(checksum = checksum)
pkg_id = lookup_pkgid_sql.fetchall_dict()
if not pkg_id:
commit 85c22ba75bb45820f53d9fea35c6ae5dc4ae90ee
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 14:20:01 2009 +0200
changes in server/rhnPackageUpload.py to reflect new rhnChecksum table
diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py
index 46b57a7..b01f98a 100644
--- a/backend/server/rhnPackageUpload.py
+++ b/backend/server/rhnPackageUpload.py
@@ -87,7 +87,7 @@ def _authenticate(authobj, channels, null_org, force):
return org_id, force
-def relative_path_from_header(header, org_id, md5sum):
+def relative_path_from_header(header, org_id, checksum):
nevra = importLib.get_nevra(header)
if header.is_source:
#4/18/05 wregglej. if 1051 is in the header's keys, then it's a nosrc package.
@@ -104,13 +104,13 @@ def relative_path_from_header(header, org_id, md5sum):
header["package_name"]:
rel_path = relative_path_from_nevra_without_package_name(nevra, org_id,
- md5sum=md5sum)
+ checksum=checksum)
return os.path.join(rel_path, header["package_name"])
return relative_path_from_nevra(nevra,
- org_id=org_id, package_type=header.packaging, md5sum=md5sum)
+ org_id=org_id, package_type=header.packaging, checksum=checksum)
-def relative_path_from_nevra(nevra, org_id, package_type=None, md5sum=None):
+def relative_path_from_nevra(nevra, org_id, package_type=None, checksum=None):
#4/18/05 wregglej. if 1051 is in the header's keys, then it's a nosrc package.
if nevra[4] == 'src' or nevra[4] == 'nosrc':
is_source = 1
@@ -119,15 +119,15 @@ def relative_path_from_nevra(nevra, org_id, package_type=None, md5sum=None):
log_debug(4, nevra, is_source)
return get_package_path(nevra, org_id=org_id, source=is_source,
prepend=CFG.PREPENDED_DIR, omit_epoch=1, package_type=package_type,
- md5sum=md5sum)
+ checksum=checksum)
# bug #161989 - get the relative path from the nevra, but omit the package name
-def relative_path_from_nevra_without_package_name(nevra, org_id, md5sum=None):
+def relative_path_from_nevra_without_package_name(nevra, org_id, checksum=None):
log_debug(4, nevra, "no package name")
return get_package_path_without_package_name(nevra, org_id,
- prepend=CFG.PREPENDED_DIR, md5sum=md5sum)
+ prepend=CFG.PREPENDED_DIR, checksum=checksum)
-def push_package(header, payload_stream, md5sum, org_id=None, force=None,
+def push_package(header, payload_stream, checksum, org_id=None, force=None,
header_start=None, header_end=None, channels=[], relative_path=None):
"""Uploads an RPM package
"""
@@ -141,13 +141,13 @@ def push_package(header, payload_stream, md5sum, org_id=None, force=None,
# First write the package to the filesystem to final location
try:
importLib.copy_package(payload_stream.fileno(), basedir=CFG.MOUNT_POINT,
- relpath=relative_path, md5sum=md5sum, force=1)
+ relpath=relative_path, checksum=checksum, force=1)
except OSError, e:
raise rhnFault(50, "Package upload failed: %s" % e)
except importLib.FileConflictError:
raise rhnFault(50, "File already exists")
- pkg = mpmSource.create_package(header, size=payload_size, md5sum=md5sum,
+ pkg = mpmSource.create_package(header, size=payload_size, checksum=checksum,
relpath=relative_path, org_id=org_id, header_start=header_start,
header_end=header_end, channels=channels)
@@ -206,7 +206,7 @@ def push_package(header, payload_stream, md5sum, org_id=None, force=None,
#case 1:check if the path exists in the db and also on the file system.
#if it does then no need to copy
#case2: file exists on file system but path not in db.then add the
- #realtive path in the db based on md5sum of the pkg
+ #realtive path in the db based on checksum of the pkg
#case3: if no file on file system but path exists.then we write the
#file to file system
#case4:no file exists on FS and no path in db .then we write both.
@@ -219,9 +219,11 @@ def push_package(header, payload_stream, md5sum, org_id=None, force=None,
h_path = rhnSQL.prepare("""
select ps.path path
- from rhnpackagesource ps
+ from rhnpackagesource ps,
+ rhnChecksum c
where
- ps.md5sum = :md5sum
+ c.checksum = :checksum
+ and ps.checksum_id = c.id
and (ps.org_id = :org_id or
(ps.org_id is null and :org_id is null)
)
@@ -229,14 +231,16 @@ def push_package(header, payload_stream, md5sum, org_id=None, force=None,
else:
h_path = rhnSQL.prepare("""
select rp.path path
- from rhnpackage rp
+ from rhnpackage rp,
+ rhnChecksum c
where
- rp.md5sum = :md5sum
+ c.checksum = :checksum
+ and rp.checksum_id = c.id
and (rp.org_id = :org_id or
(rp.org_id is null and :org_id is null)
)
""")
- h_path.execute(md5sum=md5sum, org_id = org_id)
+ h_path.execute(checksum=checksum, org_id = org_id)
rs_path = h_path.fetchall_dict()
path_dict = {}
@@ -249,16 +253,16 @@ def push_package(header, payload_stream, md5sum, org_id=None, force=None,
h_upd = rhnSQL.prepare("""
update rhnpackage
set path = :path
- where
- md5sum = :md5sum
+ where checksum_id = (
+ select id from rhnChecksum where checksum = :checksum)
""")
- h_upd.execute(path=relative_path, md5sum=md5sum)
+ h_upd.execute(path=relative_path, checksum=checksum)
# commit the transactions
rhnSQL.commit()
if not header.is_source:
# Process Package Key information
- server_packages.processPackageKeyAssociations(header, md5sum)
+ server_packages.processPackageKeyAssociations(header, checksum)
if not header.is_source:
errataCache.schedule_errata_cache_update(importer.affected_channels)
@@ -294,7 +298,7 @@ def load_package(package_stream):
except rhn_mpm.InvalidPackageError, e:
raise rhnFault(50, "Unable to load package", explain=0)
- md5sum = rhnLib.getFileMD5(file=payload_stream)
+ checksum = rhnLib.getFileMD5(file=payload_stream)
payload_stream.seek(0, 0)
if header.packaging == "mpm":
header.header_start = header.header_end = 0
@@ -303,7 +307,7 @@ def load_package(package_stream):
(header_start, header_end) = get_header_byte_range(payload_stream)
payload_stream.seek(0,0)
- return header, payload_stream, md5sum, header_start, header_end
+ return header, payload_stream, checksum, header_start, header_end
class AlreadyUploadedError(Exception):
pass
@@ -311,14 +315,14 @@ class AlreadyUploadedError(Exception):
class PackageConflictError(Exception):
pass
-def check_package_exists(package_path, package_md5sum, force=0):
+def check_package_exists(package_path, package_checksum, force=0):
if not os.path.exists(package_path):
return
# File exists, same MD5sum?
- md5sum = rhnLib.getFileMD5(package_path)
- if package_md5sum == md5sum and not force:
+ checksum = rhnLib.getFileMD5(package_path)
+ if package_checksum == checksum and not force:
raise AlreadyUploadedError(package_path)
if force:
return
- raise PackageConflictError(package_path, md5sum)
+ raise PackageConflictError(package_path, checksum)
commit 37461dd0e6f48a088bf427d520f148770f693d7e
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Oct 14 14:10:20 2009 +0200
changes in server/rhnPackage.py to reflect new rhnChecksum table
diff --git a/backend/server/rhnPackage.py b/backend/server/rhnPackage.py
index 0b7ac08..e57ec50 100644
--- a/backend/server/rhnPackage.py
+++ b/backend/server/rhnPackage.py
@@ -432,17 +432,18 @@ def get_channels_for_package(pkg):
return []
return map(lambda c: c['label'], ret)
-def get_package_for_md5sum(org_id, md5sum):
+def get_package_for_md5sum(org_id, checksum):
statement = """
select
p.id
from
- rhnPackage p
+ rhnPackage p, rhnChecksum c
where p.org_id = :org_id
- and p.md5sum = :md5sum
+ and p.checksum_id = c.id
+ and p.checksum = :checksum
"""
h = rhnSQL.prepare(statement)
- h.execute(org_id=org_id, md5sum=md5sum)
+ h.execute(org_id=org_id, checksum=checksum)
ret = h.fetchone_dict()
if not ret:
return None