client/tools rel-eng/packages
by Michael Mraka
client/tools/rhnpush/rhnpush.spec | 6 +++++-
rel-eng/packages/rhnpush | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
New commits:
commit dafc824909846dfccd4749432226fa74fe8f9b8d
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 14:16:11 2009 +0100
Automatic commit of package [rhnpush] release [5.4.6-1].
diff --git a/client/tools/rhnpush/rhnpush.spec b/client/tools/rhnpush/rhnpush.spec
index bef3125..2eaf69b 100644
--- a/client/tools/rhnpush/rhnpush.spec
+++ b/client/tools/rhnpush/rhnpush.spec
@@ -5,7 +5,7 @@ Summary: Common programs needed to be installed on the RHN servers/proxies
Group: Applications/System
License: GPLv2
URL: http://fedorahosted.org/spacewalk
-Version: 5.4.5
+Version: 5.4.6
Release: 1%{?dist}
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -50,6 +50,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man8/solaris2mpm.8*
%changelog
+* Thu Dec 10 2009 Michael Mraka <michael.mraka(a)redhat.com> 5.4.6-1
+- added support for SHA256 rpms
+- fixed namespace for rhn_rpm
+
* Mon Dec 07 2009 Michael Mraka <michael.mraka(a)redhat.com> 5.4.5-1
- moved code from rhnlib to spacewalk-backend-libs
diff --git a/rel-eng/packages/rhnpush b/rel-eng/packages/rhnpush
index 98e3759..dd0e93c 100644
--- a/rel-eng/packages/rhnpush
+++ b/rel-eng/packages/rhnpush
@@ -1 +1 @@
-5.4.5-1 client/tools/rhnpush/
+5.4.6-1 client/tools/rhnpush/
14 years, 4 months
19 commits - backend/server backend/spacewalk backend/spacewalk-backend.spec backend/upload_server client/tools
by Michael Mraka
backend/server/basePackageUpload.py | 13 -
backend/server/handlers/app/packages.py | 125 +++++++---
backend/server/rhnPackageUpload.py | 10
backend/spacewalk-backend.spec | 1
backend/spacewalk/__init__.py | 14 +
backend/spacewalk/common/__init__.py | 14 +
backend/spacewalk/common/checksum.py | 86 ++++++
backend/upload_server/handlers/package_push/package_push.py | 12
backend/upload_server/handlers/package_upload/package_upload.py | 24 +
client/tools/rhnpush/connection.py | 76 ------
client/tools/rhnpush/rhnpush.py | 68 ++---
client/tools/rhnpush/rpm2mpm.py | 2
client/tools/rhnpush/solaris2mpm.py | 2
client/tools/rhnpush/uploadLib.py | 64 +----
14 files changed, 310 insertions(+), 201 deletions(-)
New commits:
commit 2de90497e2090486e029c3d1906694f0af17f8f5
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 13:58:04 2009 +0100
fixed syntax error
diff --git a/backend/server/basePackageUpload.py b/backend/server/basePackageUpload.py
index 6f316ee..bdba0e3 100644
--- a/backend/server/basePackageUpload.py
+++ b/backend/server/basePackageUpload.py
@@ -55,7 +55,7 @@ class BasePackageUpload:
md5sum_header = "%s-%s" % (self.header_prefix, "File-MD5sum")
if req.headers_in.has_key(md5sum_header):
req.headers_in["%s-%s" % (self.header_prefix, "File-Checksum-Type")] = 'md5'
- req.headers_in["%s-%s" % (self.header_prefix, "File-Checksum")] =
+ req.headers_in["%s-%s" % (self.header_prefix, "File-Checksum")] = \
req.headers_in[md5sum_header]
for f in self.required_fields:
commit e57af2b704986f5257a8f31b2e5f73f100626b31
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 13:55:02 2009 +0100
let's backend understand File-Checksum* headers
diff --git a/backend/server/basePackageUpload.py b/backend/server/basePackageUpload.py
index 542fdfa..6f316ee 100644
--- a/backend/server/basePackageUpload.py
+++ b/backend/server/basePackageUpload.py
@@ -35,7 +35,8 @@ class BasePackageUpload:
"Package-Version",
"Package-Release",
"Package-Arch",
- "File-MD5sum",
+ "File-Checksum",
+ "File-Checksum-Type",
]
self.field_data = UserDictCase()
self.org_id = None
@@ -50,6 +51,13 @@ class BasePackageUpload:
#Header string. This is what the Auth-Session field will look like in the header.
session_header = "%s-%s" % (self.header_prefix, "Auth-Session")
+ # legacy rhnpush sends File-MD5sum; translate it into File-Checksum
+ md5sum_header = "%s-%s" % (self.header_prefix, "File-MD5sum")
+ if req.headers_in.has_key(md5sum_header):
+ req.headers_in["%s-%s" % (self.header_prefix, "File-Checksum-Type")] = 'md5'
+ req.headers_in["%s-%s" % (self.header_prefix, "File-Checksum")] =
+ req.headers_in[md5sum_header]
+
for f in self.required_fields:
hf = "%s-%s" % (self.header_prefix, f)
if not req.headers_in.has_key(hf):
@@ -78,7 +86,8 @@ class BasePackageUpload:
self.package_version = self.field_data["Package-Version"]
self.package_release = self.field_data["Package-Release"]
self.package_arch = self.field_data["Package-Arch"]
- self.file_md5sum = self.field_data["File-MD5sum"]
+ self.file_checksum = (self.field_data["File-Checksum-Type"],
+ self.field_data["File-Checksum"] )
#4/18/05 wregglej. if 1051 is in the header's keys, then it's a nosrc package.
self.is_source = (self.package_arch == 'src' or self.package_arch == 'nosrc')
return apache.OK
diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py
index a16671d..dfc9c63 100644
--- a/backend/server/rhnPackageUpload.py
+++ b/backend/server/rhnPackageUpload.py
@@ -309,14 +309,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:
+ # File exists, same checksum?
+ checksum = rhnLib.getFileChecksum(package_checksum[0], 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)
diff --git a/backend/upload_server/handlers/package_push/package_push.py b/backend/upload_server/handlers/package_push/package_push.py
index 3784123..cf052bf 100644
--- a/backend/upload_server/handlers/package_push/package_push.py
+++ b/backend/upload_server/handlers/package_push/package_push.py
@@ -114,17 +114,17 @@ class PackagePush(basePackageUpload.BasePackageUpload):
# Sanity check - removed, the package path can no longer be determined
# without the header
- md5sum = rhnLib.getFileMD5(file=temp_stream)
- checksum = ('md5', md5sum) # FIXME sha256
+ checksum = (header.checksum_type(),
+ rhnLib.getFileChecksum(header.checksum_type(), file=temp_stream))
self.rel_package_path = rhnPackageUpload.relative_path_from_header(
header, org_id=self.org_id, checksum=checksum)
self.package_path = os.path.join(CFG.MOUNT_POINT,
self.rel_package_path)
- # 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 checksums: expected", self.file_checksum,
+ "; got:", checksum)
raise rhnFault(104, "Mismatching information")
package_dict, diff_level = rhnPackageUpload.push_package(header,
diff --git a/backend/upload_server/handlers/package_upload/package_upload.py b/backend/upload_server/handlers/package_upload/package_upload.py
index 1f221c5..44e2477 100644
--- a/backend/upload_server/handlers/package_upload/package_upload.py
+++ b/backend/upload_server/handlers/package_upload/package_upload.py
@@ -45,17 +45,18 @@ 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 " %
+ "Package %s (%s: %s) already exists, with checksum (%s: %s) " %
(os.path.basename(self.package_path),
- self.file_md5sum, e.args[1]))
+ self.file_checksum[0], self.file_checksum[1],
+ e.args[1][0], e.args[1][1]))
return apache.OK
@@ -72,12 +73,14 @@ class PackageUpload(basePackageUpload.BasePackageUpload):
temp_stream = rhnPackageUpload.write_temp_file(req, buffer_size)
header, payload_stream, header_start, header_end = \
rhnPackageUpload.load_package(temp_stream)
- md5sum = rhnLib.getFileMD5(file=temp_stream)
+ checksum = (header.checksum_type(),
+ rhnLib.getFileChecksum(header.checksum_type(), file=temp_stream))
temp_stream.close()
- if self.file_md5sum != md5sum:
- raise rhnFault(501, "Uploaded: %s; filesystem: %s" %
- (self.file_md5sum, md5sum))
+ if self.file_checksum != checksum:
+ raise rhnFault(501, "Uploaded: (%s: %s); filesystem: (%s: %s)" %
+ (self.file_checksum[0], self.file_checksum[1],
+ checksum[0], checksum[1]))
if not rhnPackageUpload.source_match(self.is_source, header.is_source):
# Unexpected rpm package type
@@ -107,8 +110,9 @@ class PackageUpload(basePackageUpload.BasePackageUpload):
# XXX
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))
+ raise rhnFault(103, "Package %s (%s: %s) is not signed" %
+ (os.path.basename(self.package_path),
+ self.file_checksum[0], self.file_checksum[1]))
payload_stream.seek(0, 0)
dirname = os.path.dirname(self.package_path)
commit 413b07f0df39969dea91582b44d8f7379870661e
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 12:22:44 2009 +0100
missing digest is (empty) tuple not string now
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index eceebaf..13c24b9 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -357,7 +357,7 @@ class UploadClass(uploadLib.UploadClass):
self.warn(1, "Package %s already exists on the RHN Server-- Skipping Upload...." % pkg)
continue
- elif server_digest == "":
+ elif server_digest == ():
self.warn(1,"Package %s Not Found on RHN Server -- Uploading" % pkg)
elif server_digest == "on-disk" and not self.options.force:
commit 1c66e329c65e37451cbc4fb3202ddb7ead2e49c4
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 12:16:24 2009 +0100
let's rhnpush understand sha256
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 993b683..eceebaf 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -344,7 +344,7 @@ class UploadClass(uploadLib.UploadClass):
pkg_key = (pkg.strip()).split('/')[-1]
if checkpkgflag :
- #Its Newer Satellite. compute md5sum checks on client.
+ # it's newer satellite, compute checksum checks on client.
if not server_digest_hash.has_key(pkg_key):
continue
@@ -375,11 +375,12 @@ class UploadClass(uploadLib.UploadClass):
self.warn(0, msg)
continue
else:
- #Its an older satellite(< 4.1.0). Just do the push the usual old way,
- #without md5sum pre-check.
+ # it's an older satellite(< 4.1.0). Just do the push the usual old way,
+ # without checksum pre-check.
try:
f = open(pkg)
header, payload_stream = rhn_mpm.load(file=f)
+ checksum_type = header.checksum_type()
except rhn_mpm.InvalidPackageError, e:
if not self.options.tolerant:
self.die(-1, "ERROR: %s: This file doesn't appear to be a package" % pkg)
@@ -391,8 +392,8 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory available" % pkg)
continue
- # FIXME sha 256
- digest = ('md5', checksum.getFileChecksum('md5', file=payload_stream))
+ digest = (checksum_type,
+ checksum.getFileChecksum(checksum_type, file=payload_stream))
f.close()
for t in range(0, tries):
@@ -468,7 +469,7 @@ class UploadClass(uploadLib.UploadClass):
self.password, info)
return 0
- #does an existance check of the packages to be uploaded and returns their md5sum and other info
+ # does an existance check of the packages to be uploaded and returns their checksum and other info
def check_package_exists(self):
self.warn(2, "Computing checksum and package Info .This may take sometime ...")
pkg_hash = {}
@@ -486,6 +487,7 @@ class UploadClass(uploadLib.UploadClass):
try:
f = open(pkg)
header, payload_stream = rhn_mpm.load(file=f)
+ checksum_type = header.checksum_type()
except rhn_mpm.InvalidPackageError, e:
if not self.options.tolerant:
self.die(-1, "ERROR: %s: This file doesn't appear to be a package" % pkg)
@@ -497,8 +499,8 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory available" % pkg)
continue
- # FIXME sha 256
- digest_hash[pkg_key] = ('md5', checksum.getFileChecksum('md5', file=payload_stream))
+ digest_hash[pkg_key] = (checksum_type,
+ checksum.getFileChecksum(checksum_type, file=payload_stream))
f.close()
for tag in ('name', 'version', 'release', 'epoch', 'arch'):
@@ -530,19 +532,19 @@ class UploadClass(uploadLib.UploadClass):
'org_id' : orgid,
'force' : self.options.force or 0
}
- #rpc call to get md5sum info for all the packages to be uploaded
+ # rpc call to get checksum info for all the packages to be uploaded
if not self.options.source:
if self.new_sat_test():
- #computing md5sum and other info is expensive process and session
- #could have expired.Make sure its re-authenticated.
+ # computing checksum and other info is expensive process and session
+ # could have expired.Make sure its re-authenticated.
self.authenticate()
checksum_data = uploadLib.getPackageChecksumBySession(self.server, self.session.getSessionString(), info)
else:
checksum_data = uploadLib.getPackageChecksum(self.server, self.username, self.password, info)
else:
if self.new_sat_test():
- #computing md5sum and other info is expensive process and session
- #could have expired.Make sure its re-authenticated.
+ # computing checksum and other info is expensive process and session
+ # could have expired.Make sure its re-authenticated.
self.authenticate()
checksum_data = uploadLib.getSourcePackageChecksumBySession(self.server, self.session.getSessionString(), info)
else:
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 20bf0d0..0fa466f 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -485,7 +485,7 @@ def _processFile(filename, relativeDir=None, source=None, nosig=None):
Returns a hash containing:
header
packageSize
- md5sum
+ checksum
relativePath
nvrea
"""
@@ -500,12 +500,14 @@ def _processFile(filename, relativeDir=None, source=None, nosig=None):
size = os.path.getsize(filename)
# Open the file
f = open(filename, "r")
- digest = checksum.getFileChecksum('md5', file=f)
- # Rewind the file
- f.seek(0, 0)
# Read the header
h = get_header(None, f.fileno(), source)
(header_start, header_end) = get_header_byte_range(f);
+ # Rewind the file
+ f.seek(0, 0)
+ # Compute digest
+ digest = (h.checksum_type(),
+ checksum.getFileChecksum(h.checksum_type(), file=f))
f.close()
if h is None:
raise UploadError("%s is not a valid RPM file" % filename)
@@ -531,7 +533,7 @@ def _processFile(filename, relativeDir=None, source=None, nosig=None):
# Build the header hash to be sent
hash = { 'header' : Binary(h.unload()),
- 'md5sum' : digest,
+ 'checksum' : digest,
'packageSize' : size,
'header_start' : header_start,
'header_end' : header_end}
commit 20a6a94e477d9b256b0aefecab0d8babcea26468
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 11:32:49 2009 +0100
added forgotten import
diff --git a/backend/server/handlers/app/packages.py b/backend/server/handlers/app/packages.py
index 4174dcc..8a76f7a 100644
--- a/backend/server/handlers/app/packages.py
+++ b/backend/server/handlers/app/packages.py
@@ -21,6 +21,7 @@
import os
import string
import tempfile
+from types import TupleType
from common import RPC_Base, rhnFault, log_debug, log_error, CFG, rhnLib
commit 5359befde83627402089a11d120764487bbd8846
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 11:08:53 2009 +0100
fixed data type
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index a772d1a..993b683 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -349,7 +349,7 @@ class UploadClass(uploadLib.UploadClass):
continue
digest = digest_hash[pkg_key]
- server_digest = server_digest_hash[pkg_key]
+ server_digest = tuple(server_digest_hash[pkg_key])
# compare checksums for existance check
if server_digest == digest and not self.options.force:
commit be51f3bdd2180e68bd412eb7e2cb5caba4fe198a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 11:03:38 2009 +0100
comprare general checksums
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index c6c0a2b..a772d1a 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -335,8 +335,7 @@ class UploadClass(uploadLib.UploadClass):
#If not use the normal way to talk to older satellites(< 4.1.0).
if headerinfo.getheader('X-RHN-Check-Package-Exists'):
checkpkgflag = 1
- # FIXME sha 256
- (md5pkgdata, pkgs_info, digest_hash) = self.check_package_exists()
+ (server_digest_hash, pkgs_info, digest_hash) = self.check_package_exists()
for pkg in self.files:
ret = None #pkilambi:errors off as not initialized.this fixes it.
@@ -346,26 +345,27 @@ class UploadClass(uploadLib.UploadClass):
if checkpkgflag :
#Its Newer Satellite. compute md5sum checks on client.
- if not md5pkgdata.has_key(pkg_key):
+ if not server_digest_hash.has_key(pkg_key):
continue
digest = digest_hash[pkg_key]
+ server_digest = server_digest_hash[pkg_key]
- #compare md5's for existance check
- if md5pkgdata[pkg_key] == digest[1] and not self.options.force:
+ # compare checksums for existance check
+ if server_digest == digest and not self.options.force:
channel_packages.append(pkgs_info[pkg_key])
self.warn(1, "Package %s already exists on the RHN Server-- Skipping Upload...." % pkg)
continue
- elif md5pkgdata[pkg_key] == "":
+ elif server_digest == "":
self.warn(1,"Package %s Not Found on RHN Server -- Uploading" % pkg)
- elif md5pkgdata[pkg_key] == "on-disk" and not self.options.force:
+ elif server_digest == "on-disk" and not self.options.force:
channel_packages.append(pkgs_info[pkg_key])
self.warn(0,"Package on disk but not on db -- Skipping Upload "%pkg)
continue
- elif md5pkgdata[pkg_key] != digest[1]:
+ elif server_digest != digest:
if self.options.force:
self.warn(1,"Package checksum %s mismatch -- Forcing Upload"% pkg)
else:
commit e09f5557a27f47bfc0e3627ab349a2e36a5428d0
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 10:33:15 2009 +0100
fixed number of params
added debug logging
diff --git a/backend/server/handlers/app/packages.py b/backend/server/handlers/app/packages.py
index baabc2e..4174dcc 100644
--- a/backend/server/handlers/app/packages.py
+++ b/backend/server/handlers/app/packages.py
@@ -566,7 +566,8 @@ class Packages(RPC_Base):
if pkg_infos[pkg].has_key('md5sum'):
pkg_infos[pkg]['checksum'] = ('md5', pkg_infos[pkg]['md5sum'])
- def _Checksum2MD5sum_list(checksum_list):
+ def _Checksum2MD5sum_list(self, checksum_list):
+ log_debug(5)
row_list = {}
for k in checksum_list.keys():
if checksum_list[k] == '' or checksum_list[k] == 'on-disk':
commit c57e0799e0577a755efe82891c2879e10a1be530
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Dec 10 10:31:06 2009 +0100
pkginfo is only package name, we have to use whole data structure
diff --git a/backend/server/handlers/app/packages.py b/backend/server/handlers/app/packages.py
index a08d804..baabc2e 100644
--- a/backend/server/handlers/app/packages.py
+++ b/backend/server/handlers/app/packages.py
@@ -562,11 +562,9 @@ class Packages(RPC_Base):
def _MD5sum2Checksum_info(self, info):
log_debug(5)
pkg_infos = info.get('packages')
- for pkginfo in info.get('packages'):
- if pkginfo.has_key('md5sum'):
- pkginfo['checksum'] = ('md5', pkginfo['md5sum'])
-
- return
+ for pkg in pkg_infos.keys():
+ if pkg_infos[pkg].has_key('md5sum'):
+ pkg_infos[pkg]['checksum'] = ('md5', pkg_infos[pkg]['md5sum'])
def _Checksum2MD5sum_list(checksum_list):
row_list = {}
commit d5c618ef2a9a80e74c320ef6c855d3bb4f0d5025
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 16:57:46 2009 +0100
added getPackageChecksum* API calls
old getPackageMD5sum* rataind for compatibility and (re)implemented via
appropriate getPackageChecksum* calls
diff --git a/backend/server/handlers/app/packages.py b/backend/server/handlers/app/packages.py
index 731c608..a08d804 100644
--- a/backend/server/handlers/app/packages.py
+++ b/backend/server/handlers/app/packages.py
@@ -70,6 +70,11 @@ class Packages(RPC_Base):
self.functions.append('test_check_session')
self.functions.append('login')
self.functions.append('check_session')
+ self.functions.append('getPackageChecksum')
+ self.functions.append('getPackageChecksumBySession')
+ self.functions.append('getSourcePackageChecksum')
+ self.functions.append('getSourcePackageChecksumBySession')
+ # old MD5 compatibility functions
self.functions.append('getPackageMD5sum')
self.functions.append('getPackageMD5sumBySession')
self.functions.append('getSourcePackageMD5sum')
@@ -409,17 +414,17 @@ class Packages(RPC_Base):
row = h.fetchone_dict()
return row['server_count']
- def getPackageMD5sum(self, username, password, info):
- """ bug#177762 gives md5sum info of available packages.
+ def getPackageChecksum(self, username, password, info):
+ """ returns checksum info of available packages
also does an existance check on the filesystem.
"""
log_debug(3)
-
+
pkg_infos = info.get('packages')
channels = info.get('channels', [])
force = info.get('force', 0)
orgid = info.get('org_id')
-
+
if orgid == 'null':
null_org=1
else:
@@ -428,16 +433,25 @@ class Packages(RPC_Base):
channels=channels,
null_org=null_org,
force=force)
- return self._getPackageMD5sum(org_id, pkg_infos, info)
-
- def getPackageMD5sumBySession(self, session_string, info):
+ return self._getPackageChecksum(org_id, pkg_infos)
+
+ def getPackageMD5sum(self, username, password, info):
+ """ bug#177762 gives md5sum info of available packages.
+ also does an existance check on the filesystem.
+ """
+ log_debug(3)
+ self._MD5sum2Checksum_info(info)
+ return self._Checksum2MD5sum_list(
+ self.getPackageChecksum(username, password, info))
+
+ def getPackageChecksumBySession(self, session_string, info):
log_debug(3)
pkg_infos = info.get('packages')
channels = info.get('channels', [])
force = info.get('force', 0)
orgid = info.get('org_id')
-
+
try:
if orgid == 'null':
null_org=1
@@ -449,19 +463,26 @@ class Packages(RPC_Base):
raise rhnFault(33)
except rhnSession.ExpiredSessionError:
raise rhnFault(34)
-
- return self._getPackageMD5sum(org_id, pkg_infos, info)
-
+
+ return self._getPackageChecksum(org_id, pkg_infos)
+
+ def getPackageMD5sumBySession(self, session_string, info):
+ log_debug(3)
+ self._MD5sum2Checksum_info(info)
+ return self._Checksum2MD5sum_list(
+ self.getPackageChecksumBySession(session_string, info))
+
_get_pkg_info_query = """
select
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
p.path path
from
rhnPackageEVR pe,
rhnPackageName pn,
rhnPackage p,
rhnPackageArch pa,
- rhnChecksum c
+ rhnChecksumView c
where
pn.name = :pkg_name
and ( pe.epoch = :pkg_epoch or
@@ -480,32 +501,34 @@ class Packages(RPC_Base):
%s
"""
- def _getPackageMD5sum(self, org_id, pkg_infos, info):
+ def _getPackageChecksum(self, org_id, pkg_infos):
log_debug(3)
row_list = {}
- md5sum_exists = 0
+ checksum_exists = 0
for pkg in pkg_infos.keys():
pkg_info = pkg_infos[pkg]
- _md5sum_sql_filter = ""
- if pkg_info.has_key('md5sum') and CFG.ENABLE_NVREA:
- md5sum_exists = 1
- _md5sum_sql_filter = """and c.checksum = :md5sum"""
+ _checksum_sql_filter = ""
+ if pkg_info.has_key('checksum') and CFG.ENABLE_NVREA:
+ checksum_exists = 1
+ _checksum_sql_filter = """and c.checksum = :checksum
+ and c.checksum_type = :checksum_type"""
- h = rhnSQL.prepare(self._get_pkg_info_query % _md5sum_sql_filter)
+ h = rhnSQL.prepare(self._get_pkg_info_query % _checksum_sql_filter)
pkg_epoch = None
if pkg_info['epoch'] != '':
pkg_epoch = pkg_info['epoch']
- if md5sum_exists:
+ if checksum_exists:
h.execute(pkg_name=pkg_info['name'],
pkg_epoch=pkg_epoch,
pkg_version=pkg_info['version'],
pkg_rel=pkg_info['release'],
pkg_arch=pkg_info['arch'],
orgid = org_id,
- md5sum = pkg_info['md5sum'] )
+ checksum_type = pkg_info['checksum'][0],
+ checksum = pkg_info['checksum'][1])
else:
h.execute(pkg_name=pkg_info['name'],
pkg_epoch=pkg_epoch,
@@ -522,8 +545,8 @@ class Packages(RPC_Base):
if row.has_key('path'):
filePath = os.path.join(CFG.MOUNT_POINT, row['path'])
if os.access(filePath, os.R_OK):
- if row.has_key('md5sum'):
- row_list[pkg] = row['md5sum']
+ if row.has_key('checksum'):
+ row_list[pkg] = (row['checksum_type'], row['checksum'])
else:
row_list[pkg] = 'on-disk'
else:
@@ -536,7 +559,27 @@ class Packages(RPC_Base):
return row_list
- def getSourcePackageMD5sum(self, username, password, info):
+ def _MD5sum2Checksum_info(self, info):
+ log_debug(5)
+ pkg_infos = info.get('packages')
+ for pkginfo in info.get('packages'):
+ if pkginfo.has_key('md5sum'):
+ pkginfo['checksum'] = ('md5', pkginfo['md5sum'])
+
+ return
+
+ def _Checksum2MD5sum_list(checksum_list):
+ row_list = {}
+ for k in checksum_list.keys():
+ if checksum_list[k] == '' or checksum_list[k] == 'on-disk':
+ row_list[k] = checksum_list[k]
+ elif type(checksum_list[k]) == TupleType and checksum_list[k][0] == 'md5':
+ row_list[k] = checksum_list[k][1]
+ else:
+ row_list[k] = ''
+ return row_list
+
+ def getSourcePackageChecksum(self, username, password, info):
""" Uploads an RPM package """
log_debug(3)
@@ -555,9 +598,15 @@ class Packages(RPC_Base):
channels=channels,
force=force)
- return self._getSourcePackageMD5sum(org_id, pkg_infos, info)
+ return self._getSourcePackageChecksum(org_id, pkg_infos)
- def getSourcePackageMD5sumBySession(self, session_string, info):
+ def getSourcePackageMD5sum(self, username, password, info):
+ log_debug(3)
+ self._MD5sum2Checksum_info(info)
+ return self._Checksum2MD5sum_list(
+ self.getSourcePackageChecksum(username, password, info))
+
+ def getSourcePackageChecksumBySession(self, session_string, info):
log_debug(3)
pkg_infos = info.get('packages')
@@ -577,10 +626,16 @@ class Packages(RPC_Base):
except rhnSession.ExpiredSessionError:
raise rhnFault(34)
- return self._getSourcePackageMD5sum(org_id, pkg_infos, info)
+ return self._getSourcePackageChecksum(org_id, pkg_infos)
- def _getSourcePackageMD5sum(self, org_id, pkg_infos, info):
- """ Gives md5sum info of available source packages.
+ def getSourcePackageMD5sumBySession(self, session_string, info):
+ log_debug(3)
+ self._MD5sum2Checksum_info(info)
+ return self._Checksum2MD5sum_list(
+ self.getSourcePackageChecksumBySession(session_string, info))
+
+ def _getSourcePackageChecksum(self, org_id, pkg_infos):
+ """ Gives checksum info of available source packages.
Also does an existance check on the filesystem.
"""
@@ -589,11 +644,12 @@ class Packages(RPC_Base):
statement = """
select
ps.path path,
- c.checksum md5sum
+ c.checksum,
+ c.checksum_type
from
rhnSourceRpm sr,
rhnPackageSource ps,
- rhnChecksum c
+ rhnChecksumView c
where
sr.name = :name
and ps.source_rpm_id = sr.id
@@ -616,8 +672,8 @@ class Packages(RPC_Base):
if row.has_key('path'):
filePath = os.path.join(CFG.MOUNT_POINT, row['path'])
if os.access(filePath, os.R_OK):
- if row.has_key('md5sum'):
- row_list[pkg] = row['md5sum']
+ if row.has_key('checksum'):
+ row_list[pkg] = (row['checksum_type'], row['checksum'])
else:
row_list[pkg] = 'on-disk'
else:
@@ -630,7 +686,6 @@ class Packages(RPC_Base):
return row_list
-
# XXX Are these still used anywhere?
# XXX To be moved
commit 0422dcdb83b83cb9f4ea987c3761a119cdaaad83
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 16:00:21 2009 +0100
replaced MD5 functions with Checksum funcs
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 9816512..c6c0a2b 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -536,19 +536,19 @@ class UploadClass(uploadLib.UploadClass):
#computing md5sum and other info is expensive process and session
#could have expired.Make sure its re-authenticated.
self.authenticate()
- md5data = uploadLib.getPackageMD5sumBySession(self.server, self.session.getSessionString(), info)
+ checksum_data = uploadLib.getPackageChecksumBySession(self.server, self.session.getSessionString(), info)
else:
- md5data = uploadLib.getPackageMD5sum(self.server, self.username, self.password, info)
+ checksum_data = uploadLib.getPackageChecksum(self.server, self.username, self.password, info)
else:
if self.new_sat_test():
#computing md5sum and other info is expensive process and session
#could have expired.Make sure its re-authenticated.
self.authenticate()
- md5data = uploadLib.getSourcePackageMD5sumBySession(self.server, self.session.getSessionString(), info)
+ checksum_data = uploadLib.getSourcePackageChecksumBySession(self.server, self.session.getSessionString(), info)
else:
- md5data = uploadLib.getSourcePackageMD5sum(self.server, self.username, self.password, info)
+ checksum_data = uploadLib.getSourcePackageChecksum(self.server, self.username, self.password, info)
- return (md5data, pkg_hash, digest_hash)
+ return (checksum_data, pkg_hash, digest_hash)
def package(self, package, FileChecksum):
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 642e679..20bf0d0 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -665,17 +665,17 @@ def listMissingSourcePackages(server, username, password, channels):
def listMissingSourcePackagesBySession(server, session_string, channels):
return call(server.packages.listMissingSourcePackagesBySession, channels, session_string)
-def getPackageMD5sumBySession(server, session_string, info):
- return call(server.packages.getPackageMD5sumBySession, session_string, info)
+def getPackageChecksumBySession(server, session_string, info):
+ return call(server.packages.getPackageChecksumBySession, session_string, info)
-def getSourcePackageMD5sumBySession(server, session_string, info):
- return call(server.packages.getSourcePackageMD5sumBySession, session_string, info)
+def getSourcePackageChecksumBySession(server, session_string, info):
+ return call(server.packages.getSourcePackageChecksumBySession, session_string, info)
-def getPackageMD5sum(server, username, password, info):
- return call(server.packages.getPackageMD5sum, username, password, info)
+def getPackageChecksum(server, username, password, info):
+ return call(server.packages.getPackageChecksum, username, password, info)
-def getSourcePackageMD5sum(server, username, password, info):
- return call(server.packages.getSourcePackageMD5sum, username, password, info)
+def getSourcePackageChecksum(server, username, password, info):
+ return call(server.packages.getSourcePackageChecksum, username, password, info)
def getServer(uri, proxy=None, username=None, password=None, ca_chain=None):
commit ecde9b9ee71c558964906d89562726641b6c7077
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 15:11:31 2009 +0100
replaced computeMD5sum() with common getFileChecksum()
and then removed unnecessary computeMD5sum()
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 65e4742..9816512 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -45,6 +45,7 @@ except ImportError:
from optik import Option, OptionParser
from rhn import rpclib
from spacewalk.common import rhn_mpm
+from spacewalk.common import checksum
import uploadLib
import rhnpush_v2
@@ -391,7 +392,7 @@ class UploadClass(uploadLib.UploadClass):
continue
# FIXME sha 256
- digest = ('md5', uploadLib.computeMD5sum(None, payload_stream))
+ digest = ('md5', checksum.getFileChecksum('md5', file=payload_stream))
f.close()
for t in range(0, tries):
@@ -497,7 +498,7 @@ class UploadClass(uploadLib.UploadClass):
continue
# FIXME sha 256
- digest_hash[pkg_key] = ('md5', uploadLib.computeMD5sum(None, payload_stream))
+ digest_hash[pkg_key] = ('md5', checksum.getFileChecksum('md5', file=payload_stream))
f.close()
for tag in ('name', 'version', 'release', 'epoch', 'arch'):
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index cd03cf9..642e679 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -22,20 +22,7 @@ import getpass
import rhnpush_cache
import struct
from spacewalk.common import rhn_mpm
-
-try:
- import hashlib
-except ImportError:
- import md5
- class hashlib:
- @staticmethod
- def new(checksum):
- # Add sha1 if needed.
- if checksum == 'md5':
- return md5.new()
- # if not md5 or sha1, its invalid
- if checksum not in ['md5', 'sha1']:
- raise ValueError, "Incompatible checksum type"
+from spacewalk.common import checksum
try:
from rhn import rpclib
@@ -513,7 +500,7 @@ def _processFile(filename, relativeDir=None, source=None, nosig=None):
size = os.path.getsize(filename)
# Open the file
f = open(filename, "r")
- digest = computeMD5sum(None, f)
+ digest = checksum.getFileChecksum('md5', file=f)
# Rewind the file
f.seek(0, 0)
# Read the header
@@ -573,23 +560,6 @@ def _processBatch(batch, relativeDir, source, verbose, nosig=None):
headersList.append(hash)
return sentPackages, headersList
-def computeMD5sum(filename=None, f=None):
- if f is None:
- fd = open(filename, "r")
- else:
- fd = f
- fd.seek(0, 0)
- md5sum = hashlib.new('md5')
- while 1:
- buf = fd.read(BUFFER_SIZE)
- if not buf:
- break
- md5sum.update(buf)
- if not f:
- fd.close()
- return string.join(map(lambda x: "%02x" % ord(x), md5sum.digest()), '')
-
-
def readStdin():
# Reads the standard input lines and returns a list
l = []
commit 7cc06071a2becddaf813e7d2641391e5f4cd5984
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 14:59:10 2009 +0100
replaced md5 with checksum
diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py
index 93e40f5..4216ee3 100644
--- a/client/tools/rhnpush/connection.py
+++ b/client/tools/rhnpush/connection.py
@@ -169,7 +169,7 @@ class PackageUpload:
return self._response
- def upload(self, file, FileMD5sum):
+ def upload(self, file, FileChecksum):
"""
Uploads a file.
Returns (http_error_code, error_message)
@@ -209,8 +209,8 @@ class PackageUpload:
self.nvra = nvra
- #use the precomputed passed md5sum.
- self.md5sum = FileMD5sum
+ # use the precomputed passed checksum
+ self.checksum = FileChecksum
# Set headers
self.set_header("Content-Type", "application/x-rpm")
@@ -222,7 +222,11 @@ class PackageUpload:
self.set_header("%s-%s" % (prefix, "Package-Release"), nvra[2])
self.set_header("%s-%s" % (prefix, "Package-Arch"), nvra[3])
self.set_header("%s-%s" % (prefix, "Packaging"), self.packaging)
- self.set_header("%s-%s" % (prefix, "File-MD5sum"), self.md5sum)
+ if self.checksum[0] == 'md5':
+ self.set_header("%s-%s" % (prefix, "File-MD5sum"), self.checksum[1])
+ else:
+ self.set_header("%s-%s" % (prefix, "File-Checksum-Type"), self.checksum[0])
+ self.set_header("%s-%s" % (prefix, "File-Checksum"), self.checksum[1])
self._response = self.send_http('POST', stream_body=f)
f.close()
@@ -241,9 +245,9 @@ class PackageUpload:
return status, "OK"
if status == 201:
# Created
- return (status, "%s: %s-%s-%s.%s.rpm already uploaded" % (
- self.md5sum, self.nvra[0], self.nvra[1], self.nvra[2],
- self.nvra[3]))
+ return (status, "%s %s: %s-%s-%s.%s.rpm already uploaded" % (
+ self.checksum[0], self.checksum[1],
+ self.nvra[0], self.nvra[1], self.nvra[2], self.nvra[3]))
if status in (404, 409):
# Conflict
errstring = self.get_error_message(self._resp_headers)
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 0a45268..65e4742 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -334,6 +334,7 @@ class UploadClass(uploadLib.UploadClass):
#If not use the normal way to talk to older satellites(< 4.1.0).
if headerinfo.getheader('X-RHN-Check-Package-Exists'):
checkpkgflag = 1
+ # FIXME sha 256
(md5pkgdata, pkgs_info, digest_hash) = self.check_package_exists()
for pkg in self.files:
@@ -350,7 +351,7 @@ class UploadClass(uploadLib.UploadClass):
digest = digest_hash[pkg_key]
#compare md5's for existance check
- if md5pkgdata[pkg_key] == digest and not self.options.force:
+ if md5pkgdata[pkg_key] == digest[1] and not self.options.force:
channel_packages.append(pkgs_info[pkg_key])
self.warn(1, "Package %s already exists on the RHN Server-- Skipping Upload...." % pkg)
continue
@@ -363,7 +364,7 @@ class UploadClass(uploadLib.UploadClass):
self.warn(0,"Package on disk but not on db -- Skipping Upload "%pkg)
continue
- elif md5pkgdata[pkg_key] != digest:
+ elif md5pkgdata[pkg_key] != digest[1]:
if self.options.force:
self.warn(1,"Package checksum %s mismatch -- Forcing Upload"% pkg)
else:
@@ -389,7 +390,8 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory available" % pkg)
continue
- digest = uploadLib.computeMD5sum(None, payload_stream)
+ # FIXME sha 256
+ digest = ('md5', uploadLib.computeMD5sum(None, payload_stream))
f.close()
for t in range(0, tries):
@@ -467,7 +469,7 @@ class UploadClass(uploadLib.UploadClass):
#does an existance check of the packages to be uploaded and returns their md5sum and other info
def check_package_exists(self):
- self.warn(2, "Computing md5sum and package Info .This may take sometime ...")
+ self.warn(2, "Computing checksum and package Info .This may take sometime ...")
pkg_hash = {}
digest_hash = {}
@@ -494,7 +496,8 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory available" % pkg)
continue
- digest_hash[pkg_key] = uploadLib.computeMD5sum(None, payload_stream)
+ # FIXME sha 256
+ digest_hash[pkg_key] = ('md5', uploadLib.computeMD5sum(None, payload_stream))
f.close()
for tag in ('name', 'version', 'release', 'epoch', 'arch'):
@@ -511,7 +514,7 @@ class UploadClass(uploadLib.UploadClass):
pkg_info['arch'] = 'nosrc'
else:
pkg_info['arch'] = 'src'
- pkg_info['md5sum'] = digest_hash[pkg_key]
+ pkg_info['checksum'] = digest_hash[pkg_key]
pkg_hash[pkg_key] = pkg_info
if self.options.nullorg:
@@ -547,7 +550,7 @@ class UploadClass(uploadLib.UploadClass):
return (md5data, pkg_hash, digest_hash)
- def package(self, package, FileMD5sum):
+ def package(self, package, FileChecksum):
self.warn(1, "Uploading package %s" % package)
if not os.access(package, os.R_OK):
self.die(-1, "Could not read file %s" % package)
@@ -570,7 +573,7 @@ class UploadClass(uploadLib.UploadClass):
try:
if self.ping_status == 200:
- ret = self._push_package_v2(package, FileMD5sum)
+ ret = self._push_package_v2(package, FileChecksum)
else:
ret = self._push_package_xmlrpc(package, h, packaging)
except UploadError, e:
@@ -600,7 +603,7 @@ class UploadClass(uploadLib.UploadClass):
return ret
- def _push_package_v2(self, package, FileMD5sum):
+ def _push_package_v2(self, package, FileChecksum):
self.warn(1, "Using POST request")
pu = rhnpush_v2.PackageUpload(self.url_v2)
@@ -611,7 +614,7 @@ class UploadClass(uploadLib.UploadClass):
pu.set_force(self.options.force)
pu.set_null_org(self.options.nullorg)
- status, msgstr = pu.upload(package, FileMD5sum)
+ status, msgstr = pu.upload(package, FileChecksum)
ret = {}
for tag in ('name', 'version', 'release', 'epoch', 'arch'):
@@ -620,7 +623,7 @@ class UploadClass(uploadLib.UploadClass):
val = ''
ret[tag] = val
- ret['md5sum'] = FileMD5sum
+ ret['checksum'] = FileChecksum
if status == 400:
# Bad request - something bad happened
try:
commit a8b9b3014b1a155b523bc5630dc0b8b541781ae3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 14:25:54 2009 +0100
removed unnecessary imports
diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py
index 8889b97..93e40f5 100644
--- a/client/tools/rhnpush/connection.py
+++ b/client/tools/rhnpush/connection.py
@@ -13,28 +13,12 @@
# in this software or its documentation.
#
-import os
import socket
import string
import base64
import urllib
import urlparse
-try:
- import hashlib
-except ImportError:
- import md5
- class hashlib:
- @staticmethod
- def new(checksum):
- # Add sha1 if needed.
- if checksum == 'md5':
- return md5.new()
- # if not md5 or sha1, its invalid
- if checksum not in ['md5', 'sha1']:
- raise ValueError, "Incompatible checksum type"
-
-
from types import ListType, TupleType, IntType
from rhn import connections, rpclib
commit ff1b604df9f6a084b63c8133908dfe161f7503ed
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 13:55:47 2009 +0100
added missing init files
diff --git a/backend/spacewalk/__init__.py b/backend/spacewalk/__init__.py
new file mode 100644
index 0000000..849af9b
--- /dev/null
+++ b/backend/spacewalk/__init__.py
@@ -0,0 +1,14 @@
+#
+# Copyright (c) 2009 Red Hat, Inc.
+#
+# This software is licensed to you under the GNU General Public License,
+# version 2 (GPLv2). There is NO WARRANTY for this software, express or
+# implied, including the implied warranties of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+# along with this software; if not, see
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+#
+# Red Hat trademarks are not licensed under GPLv2. No permission is
+# granted to use or replicate Red Hat trademarks that are incorporated
+# in this software or its documentation.
+#
diff --git a/backend/spacewalk/common/__init__.py b/backend/spacewalk/common/__init__.py
new file mode 100644
index 0000000..849af9b
--- /dev/null
+++ b/backend/spacewalk/common/__init__.py
@@ -0,0 +1,14 @@
+#
+# Copyright (c) 2009 Red Hat, Inc.
+#
+# This software is licensed to you under the GNU General Public License,
+# version 2 (GPLv2). There is NO WARRANTY for this software, express or
+# implied, including the implied warranties of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+# along with this software; if not, see
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+#
+# Red Hat trademarks are not licensed under GPLv2. No permission is
+# granted to use or replicate Red Hat trademarks that are incorporated
+# in this software or its documentation.
+#
commit f79380b73bc6c34f79055f5754d179a9e6041da7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 13:44:03 2009 +0100
removed unused getFileMD5()
diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py
index 4da91e6..8889b97 100644
--- a/client/tools/rhnpush/connection.py
+++ b/client/tools/rhnpush/connection.py
@@ -289,43 +289,3 @@ class PackageUpload:
text = string.join(text, '\n')
text = base64.decodestring(text)
return text
-
-
-def getFileMD5(filename=None, fd=None, file=None, buffer_size=None):
- """ Compute a file's md5sum
- Used by rotateFile()
- """
-
- # python's md5 lib sucks. hexdigest() doesn't show up until 2.0,
- # and there's no way to directly import a file.
- if buffer_size is None:
- buffer_size = 65536
-
- if filename is None and fd is None and file is None:
- raise ValueError("no file specified");
- if file:
- f = file
- elif fd is not None:
- f = os.fdopen(os.dup(fd), "r")
- else:
- f = open(filename, "r")
- # Rewind it
- f.seek(0, 0)
- m = hashlib.new('md5')
- while 1:
- buffer = f.read(buffer_size)
- if not buffer:
- break
- m.update(buffer)
-
- # cleanup time
- if file is not None:
- file.seek(0, 0)
- else:
- f.close()
- return hexify_string(m.digest())
-
-def hexify_string(s):
- """ Used by getStringMD5() and getFileMD5() """
- return ("%02x" * len(s)) % tuple(map(ord, s))
-
commit b8c3cba5ba88fdcc73e5afc4fa2755c10137f043
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 13:32:17 2009 +0100
added checksum routines to common library
diff --git a/backend/spacewalk/common/checksum.py b/backend/spacewalk/common/checksum.py
new file mode 100644
index 0000000..261d4ca
--- /dev/null
+++ b/backend/spacewalk/common/checksum.py
@@ -0,0 +1,86 @@
+#
+# Copyright (c) 2009 Red Hat, Inc.
+#
+# This software is licensed to you under the GNU General Public License,
+# version 2 (GPLv2). There is NO WARRANTY for this software, express or
+# implied, including the implied warranties of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+# along with this software; if not, see
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+#
+# Red Hat trademarks are not licensed under GPLv2. No permission is
+# granted to use or replicate Red Hat trademarks that are incorporated
+# in this software or its documentation.
+#
+
+import os
+try:
+ import hashlib
+except ImportError:
+ import md5
+ import sha
+ from Crypto.Hash import SHA256 as sha256
+ class hashlib:
+ @staticmethod
+ def new(checksum):
+ if checksum == 'md5':
+ return md5.new()
+ elif checksum == 'sha1':
+ return sha.new()
+ elif checksum == 'sha256':
+ return sha256.new()
+ else:
+ raise ValueError, "Incompatible checksum type"
+
+
+def getFileMD5(filename=None, fd=None, file=None, buffer_size=None):
+ """ Compute a file's md5sum
+ Used by rotateFile()
+ """
+ return getFileChecksum('md5', filename, fd, file, buffer_size)
+
+def getFileChecksum(hashtype, filename=None, fd=None, file=None, buffer_size=None):
+ """ Compute a file's checksum
+ Used by rotateFile()
+ """
+
+ # python's md5 lib sucks
+ # there's no way to directly import a file.
+ if buffer_size is None:
+ buffer_size = 65536
+
+ if filename is None and fd is None and file is None:
+ raise ValueError("no file specified")
+ if file:
+ f = file
+ elif fd is not None:
+ f = os.fdopen(os.dup(fd), "r")
+ else:
+ f = open(filename, "r")
+ # Rewind it
+ f.seek(0, 0)
+ m = hashlib.new(hashtype)
+ while 1:
+ buffer = f.read(buffer_size)
+ if not buffer:
+ break
+ m.update(buffer)
+
+ # cleanup time
+ if file is not None:
+ file.seek(0, 0)
+ else:
+ f.close()
+ return m.hexdigest()
+
+
+def getStringMD5(s):
+ """ compute md5sum of an arbitrary string """
+ return getStringChecksum(s)
+
+def getStringChecksum(hashtype, s):
+ """ compute checksum of an arbitrary string """
+ ctx = hashlib.new(hashtype, s)
+ return ctx.hexdigest()
+
+
commit 94d3db1c25b0f8465c5f81c3ce33d251fc90fa86
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 11:55:21 2009 +0100
fixed namespace for rhn_rpm
diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py
index 5a434ad..4da91e6 100644
--- a/client/tools/rhnpush/connection.py
+++ b/client/tools/rhnpush/connection.py
@@ -39,7 +39,7 @@ from types import ListType, TupleType, IntType
from rhn import connections, rpclib
-from rhn.common import rhn_mpm
+from spacewalk.common import rhn_mpm
class ConnectionError(Exception):
pass
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index cb50127..0a45268 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -44,7 +44,7 @@ try:
except ImportError:
from optik import Option, OptionParser
from rhn import rpclib
-from rhn.common import rhn_mpm
+from spacewalk.common import rhn_mpm
import uploadLib
import rhnpush_v2
diff --git a/client/tools/rhnpush/rpm2mpm.py b/client/tools/rhnpush/rpm2mpm.py
index a6105b3..5c75a6a 100644
--- a/client/tools/rhnpush/rpm2mpm.py
+++ b/client/tools/rhnpush/rpm2mpm.py
@@ -20,7 +20,7 @@ from types import ListType, TupleType, DictType
import gzip
import cStringIO
-from rhn.common import rhn_rpm, rhn_mpm
+from spacewalk.common import rhn_rpm, rhn_mpm
def main():
packages = sys.argv[1:]
diff --git a/client/tools/rhnpush/solaris2mpm.py b/client/tools/rhnpush/solaris2mpm.py
index 411dfe7..77b4cef 100644
--- a/client/tools/rhnpush/solaris2mpm.py
+++ b/client/tools/rhnpush/solaris2mpm.py
@@ -39,7 +39,7 @@ except ImportError:
if checksum not in ['md5', 'sha1']:
raise ValueError, "Incompatible checksum type"
-from rhn.common import rhn_mpm
+from spacewalk.common import rhn_mpm
from archive import get_archive_parser
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 52b3215..cd03cf9 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -21,7 +21,7 @@ import fnmatch
import getpass
import rhnpush_cache
import struct
-from rhn.common import rhn_mpm
+from spacewalk.common import rhn_mpm
try:
import hashlib
@@ -731,7 +731,7 @@ def packageCompare(pkg1, pkg2, is_mpm=None):
if is_mpm:
func = rhn_mpm.labelCompare
else:
- from rhn.common import rhn_rpm
+ from spacewalk.common import rhn_rpm
func = rhn_rpm.labelCompare
return func(packages[0], packages[1])
commit 4323a62a6c710fa931a46315be3a6fe2f1b6f914
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 15:49:55 2009 +0100
fixed rpm build error
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)
error: Bad exit status from /var/tmp/rpm-tmp.B9PUXq (%install)
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 9bf4921..eebbba0 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -206,6 +206,7 @@ Requires: %{name}-app = %{version}-%{release}
Requires: %{name}
Requires: spacewalk-certs-tools
Requires: spacewalk-admin >= 0.1.1-0
+Requires: python-devel
Requires: python-gzipstream
Requires: python-hashlib
Requires: PyXML
14 years, 4 months
backend/satellite_tools
by Tomas Lestach
backend/satellite_tools/disk_dumper/iss.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
New commits:
commit 9b0ba911bb84ad384f1b822a02e3589562848661
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Thu Dec 10 11:55:21 2009 +0100
541078 - Satellite 5.3.0 - rhn-satellite-exporter --start-date and --end-date issues
differentiating one common error message that is misleading for some cases
diff --git a/backend/satellite_tools/disk_dumper/iss.py b/backend/satellite_tools/disk_dumper/iss.py
index d464780..509362b 100644
--- a/backend/satellite_tools/disk_dumper/iss.py
+++ b/backend/satellite_tools/disk_dumper/iss.py
@@ -196,7 +196,10 @@ class Dumper(dumper.XML_Dumper):
ch_info = ch_data.fetchall_dict()
if not ch_info:
- raise ISSError("Error: Channel %s not found." % ids, "")
+ if self.start_date:
+ raise ISSError("Error: No %s channel information found within specified time frame." % ids, "")
+ else:
+ raise ISSError("Error: Channel %s not found." % ids, "")
self.channel_ids = self.channel_ids + ch_info
except ISSError:
14 years, 4 months
Changes to 'refs/tags/spacewalk-backend-0.8.5-1'
by Michael Mraka
Tag 'spacewalk-backend-0.8.5-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2009-12-09 14:12 +0000
Tagging package [spacewalk-backend] version [0.8.5-1] in directory [backend/].
Changes since spacewalk-backend-0.8.4-1:
Justin Sherrill (2):
fixing errata files to correctly use Checksum objects for their checksum, also having Checksum use the correct sequence
unit test fixes
Michael Mraka (6):
removed duplicated code from syncLib
516767 - create files with default repository owner/group/permissions
fixed syntax error
fixed two more rhn_mpm imports
fixed logging in rhnLib.py
Automatic commit of package [spacewalk-backend] release [0.8.5-1].
---
backend/common/rhnLib.py | 13
backend/satellite_tools/syncLib.py | 156 ----------
backend/server/importlib/importLib.py | 9
backend/server/rhnPackageUpload.py | 3
backend/spacewalk-backend.spec | 6
java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java | 2
java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java | 10
java/code/src/com/redhat/rhn/domain/common/Checksum.hbm.xml | 12
java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java | 5
java/code/src/com/redhat/rhn/domain/errata/ErrataFile.java | 5
java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrataFile.java | 7
java/code/src/com/redhat/rhn/frontend/action/systems/test/ErrataConfirmSetupActionTest.java | 1
java/code/src/com/redhat/rhn/frontend/servlets/test/AuthFilterTest.java | 3
java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java | 4
java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 2
java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java | 2
rel-eng/packages/spacewalk-backend | 2
17 files changed, 51 insertions(+), 191 deletions(-)
---
14 years, 4 months
backend/spacewalk-backend.spec rel-eng/packages
by Michael Mraka
backend/spacewalk-backend.spec | 6 +++++-
rel-eng/packages/spacewalk-backend | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 7c43b6159050bb2fa359094715760144c77abee1
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 15:12:18 2009 +0100
Automatic commit of package [spacewalk-backend] release [0.8.5-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index f0a691a..9bf4921 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -8,7 +8,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2
-Version: 0.8.4
+Version: 0.8.5
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -597,6 +597,10 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$
%changelog
+* Wed Dec 09 2009 Michael Mraka <michael.mraka(a)redhat.com> 0.8.5-1
+- 516767 - create files with default repository owner/group/permissions
+- removed duplicated code from syncLib
+
* Tue Dec 08 2009 Michael Mraka <michael.mraka(a)redhat.com> 0.8.4-1
- fixed file glob for -libs
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index c783dee..02cbd9f 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-0.8.4-1 backend/
+0.8.5-1 backend/
14 years, 4 months
4 commits - backend/common backend/server
by Michael Mraka
backend/common/rhnLib.py | 13 +++++++------
backend/server/importlib/importLib.py | 9 +++++----
backend/server/rhnPackageUpload.py | 3 ++-
3 files changed, 14 insertions(+), 11 deletions(-)
New commits:
commit 8b82c31351821e1099ea682553751efe6933f34f
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 15:09:49 2009 +0100
fixed logging in rhnLib.py
diff --git a/backend/common/rhnLib.py b/backend/common/rhnLib.py
index da3fa71..18a6260 100644
--- a/backend/common/rhnLib.py
+++ b/backend/common/rhnLib.py
@@ -24,6 +24,8 @@ import string
import popen2
import select
import urlparse
+from common import log_debug, log_error
+
try:
import hashlib
except ImportError:
@@ -512,7 +514,7 @@ def startswith(s, prefix):
def setPermsPath(path, user='apache', group='root', chmod=0750):
"""chown user.group and set permissions to chmod"""
if not os.path.exists(path):
- log(-1, "*** ERROR: Path doesn't exist (can't set permissions): %s" % path, stream=sys.stderr)
+ log_error("*** ERROR: Path doesn't exist (can't set permissions): %s" % path)
sys.exit(-1)
# If non-root, don't bother to change owners
@@ -522,18 +524,17 @@ def setPermsPath(path, user='apache', group='root', chmod=0750):
gc = GecosCache()
uid = gc.getuid(user)
if uid is None:
- log(-1, messages.missing_user % user, stream=sys.stderr)
+ log_error(messages.missing_user % user)
sys.exit(-1)
gid = gc.getgid(group)
if gid is None:
- log(-1, messages.missing_group % group, stream=sys.stderr)
+ log_error(messages.missing_group % group)
sys.exit(-1)
uid_, gid_ = os.stat(path)[4:6]
if uid_ != uid or gid_ != gid:
- log(3, " Performing 'chown %s.%s %s'" % (user, group, path),
- stream=sys.stderr)
+ log_debug(3, " Performing 'chown %s.%s %s'" % (user, group, path))
os.chown(path, uid, gid)
os.chmod(path, chmod)
@@ -645,7 +646,7 @@ def createPath(path, user='apache', group='root', chmod=0755, logging=1):
path = cleanupAbsPath(path)
if not os.path.exists(path):
if logging:
- log(4, " Creating path: %s" % path, stream=sys.stderr)
+ log_debug(4, " Creating path: %s" % path)
makedirs(path, mode=chmod, user=user, group=group)
elif not os.path.isdir(path):
raise ValueError, "ERROR: createPath('%s'): path doesn't lead to a directory" % str(path)
commit b802c0dc304ea75e871bfc2df6036af243d21ce7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 14:18:26 2009 +0100
fixed two more rhn_mpm imports
diff --git a/backend/server/importlib/importLib.py b/backend/server/importlib/importLib.py
index 6c9e2b4..b8ccdee 100644
--- a/backend/server/importlib/importLib.py
+++ b/backend/server/importlib/importLib.py
@@ -22,10 +22,11 @@ from types import IntType, StringType, InstanceType
from UserDict import UserDict
from UserList import UserList
-from common import log_debug, rhn_mpm
+from common import log_debug
from common.rhnLib import maketemp, getFileChecksum, createPath, setPermsPath
from server.rhnLib import get_package_path
+from spacewalk.common import rhn_mpm
# no-op class, used to define the type of an attribute
class DateType:
diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py
index 547bbf4..a16671d 100644
--- a/backend/server/rhnPackageUpload.py
+++ b/backend/server/rhnPackageUpload.py
@@ -18,7 +18,8 @@
import os
import tempfile
-from common import CFG, log_debug, rhnFault, rhn_mpm, rhnLib, UserDictCase
+from common import CFG, log_debug, rhnFault, rhnLib, UserDictCase
+from spacewalk.common import rhn_mpm
from spacewalk.common.rhn_rpm import get_header_byte_range
from server import rhnSQL
commit c2b56b7e01c305277eb737b6338a3f88bb3946b3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 14:39:47 2009 +0100
fixed syntax error
diff --git a/backend/common/rhnLib.py b/backend/common/rhnLib.py
index 82c4c1c..da3fa71 100644
--- a/backend/common/rhnLib.py
+++ b/backend/common/rhnLib.py
@@ -532,7 +532,7 @@ def setPermsPath(path, user='apache', group='root', chmod=0750):
uid_, gid_ = os.stat(path)[4:6]
if uid_ != uid or gid_ != gid:
- log(3, " Performing 'chown %s.%s %s'" % (user, group, path))
+ log(3, " Performing 'chown %s.%s %s'" % (user, group, path),
stream=sys.stderr)
os.chown(path, uid, gid)
os.chmod(path, chmod)
commit fd48c14fa88f53c59ea117e235f93c7010fc79a3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 14:35:35 2009 +0100
516767 - create files with default repository owner/group/permissions
rather than root.root
diff --git a/backend/server/importlib/importLib.py b/backend/server/importlib/importLib.py
index 3d9f5f4..6c9e2b4 100644
--- a/backend/server/importlib/importLib.py
+++ b/backend/server/importlib/importLib.py
@@ -23,7 +23,7 @@ from UserDict import UserDict
from UserList import UserList
from common import log_debug, rhn_mpm
-from common.rhnLib import maketemp, getFileChecksum
+from common.rhnLib import maketemp, getFileChecksum, createPath, setPermsPath
from server.rhnLib import get_package_path
@@ -848,7 +848,7 @@ def copy_package(fd, basedir, relpath, checksum, force=None):
dir = os.path.dirname(packagePath)
# Create the directory where the file will reside
if not os.path.exists(dir):
- os.makedirs(dir)
+ createPath(dir)
pkgfd = os.open(packagePath, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
os.lseek(fd, 0, 0)
while 1:
@@ -862,7 +862,7 @@ def copy_package(fd, basedir, relpath, checksum, force=None):
n, len(buffer), packagePath)
os.close(pkgfd)
# set the path perms readable by all users
- os.chmod(packagePath, 0644)
+ setPermsPath(packagePath, chmod=0644)
# Assuming packageData is an RPM package, writes it on the disk
14 years, 4 months
backend/common backend/satellite_tools
by Michael Mraka
backend/common/rhnLib.py | 4
backend/satellite_tools/syncLib.py | 156 -------------------------------------
2 files changed, 3 insertions(+), 157 deletions(-)
New commits:
commit 979ac2e22ff9545021955585cab1b7db94840750
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 14:26:35 2009 +0100
removed duplicated code from syncLib
and restored loging in rhnLib.setPermsPath
diff --git a/backend/common/rhnLib.py b/backend/common/rhnLib.py
index e11670b..82c4c1c 100644
--- a/backend/common/rhnLib.py
+++ b/backend/common/rhnLib.py
@@ -532,8 +532,8 @@ def setPermsPath(path, user='apache', group='root', chmod=0750):
uid_, gid_ = os.stat(path)[4:6]
if uid_ != uid or gid_ != gid:
- #log(1, " Performing 'chown %s.%s %s'" % (user, group, path))
- #stream=sys.stderr)
+ log(3, " Performing 'chown %s.%s %s'" % (user, group, path))
+ stream=sys.stderr)
os.chown(path, uid, gid)
os.chmod(path, chmod)
diff --git a/backend/satellite_tools/syncLib.py b/backend/satellite_tools/syncLib.py
index d44e13a..2d25a9f 100644
--- a/backend/satellite_tools/syncLib.py
+++ b/backend/satellite_tools/syncLib.py
@@ -200,7 +200,7 @@ class FileManip:
fout = open(self.full_path, 'wb')
# setting file permissions; NOTE: rhnpush uses apache to write to disk,
# hence the 6 setting.
- setPermsPath(self.full_path, user='apache', group='apache', chmod=0644)
+ rhnLib.setPermsPath(self.full_path, user='apache', group='apache', chmod=0644)
size = 0
try:
while 1:
@@ -256,160 +256,6 @@ class RpmManip(FileManip):
return tuple(map(lambda x, s=self: s.pdict[x],
['name', 'version', 'release', 'epoch', 'arch']))
-def setPermsPath(path, user='apache', group='root', chmod=0750):
- """chown user.group and set permissions to chmod"""
- if not os.path.exists(path):
- log(-1, "*** ERROR: Path doesn't exist (can't set permissions): %s" % path, stream=sys.stderr)
- sys.exit(-1)
-
- # If non-root, don't bother to change owners
- if os.getuid() != 0:
- return
-
- gc = GecosCache()
- uid = gc.getuid(user)
- if uid is None:
- log(-1, messages.missing_user % user, stream=sys.stderr)
- sys.exit(-1)
-
- gid = gc.getgid(group)
- if gid is None:
- log(-1, messages.missing_group % group, stream=sys.stderr)
- sys.exit(-1)
-
- uid_, gid_ = os.stat(path)[4:6]
- if uid_ != uid or gid_ != gid:
- log(3, " Performing 'chown %s.%s %s'" % (user, group, path),
- stream=sys.stderr)
- os.chown(path, uid, gid)
- os.chmod(path, chmod)
-
-
-class GecosCache:
- "Cache getpwnam() and getgrnam() calls"
- __shared_data = {}
-
- def __init__(self):
- self.__dict__ = self.__shared_data
- if len(self.__shared_data.keys()) == 0:
- # Not initialized
- self._users = {}
- self._groups = {}
-
- def getuid(self, name):
- "Return the UID of the user by name"
- if self._users.has_key(name):
- return self._users[name]
- try:
- uid = pwd.getpwnam(name)[2]
- except KeyError:
- # XXX misa: gripe? taw: I think we need to do something!
- sys.stderr.write("XXX: User %s does not exist\n" % name)
- return None
- self._users[name] = uid
- return uid
-
- def getgid(self, name):
- "Return the GID of the group by name"
- if self._groups.has_key(name):
- return self._groups[name]
- try:
- gid = grp.getgrnam(name)[2]
- except KeyError:
- # XXX misa: gripe?
- sys.stderr.write("XXX: Group %s does not exist\n" % name)
- return None
- self._groups[name] = gid
- return gid
-
- def reset(self):
- self.__shared_data.clear()
- self.__init__()
-
-
-def getUidGid(user=None, group=None):
- "return uid, gid given user and group"
-
- gc = GecosCache()
- uid = os.getuid()
- if uid != 0:
- # Don't bother to change the owner, it will fail anyway
- # group ownership may work though
- user=None
- else:
- uid = gc.getuid(user)
-
- if group:
- gid = gc.getgid(group)
- else:
- gid = None
-
- if gid is None:
- gid = os.getgid()
- return uid, gid
-
-
-def makedirs(path, mode=0755, user=None, group=None):
- "makedirs function that also changes the owners"
-
- dirs_to_create = []
- dirname = path
-
- uid, gid = getUidGid(user, group)
-
- while 1:
- if os.path.isdir(dirname):
- # We're done with this step
- break
- # We have to create this directory
- dirs_to_create.append(dirname)
- dirname, last = os.path.split(dirname)
- if not last:
- # We reached the top directory
- break
-
- # Now create the directories
- while dirs_to_create:
- dirname = dirs_to_create.pop()
- try:
- os.mkdir(dirname, mode)
- except OSError, e:
- if e.errno != 17: # File exists
- raise
- # Ignore the error
- try:
- os.chown(dirname, uid, gid)
- except OSError:
- # Changing permissions failed; ignore the error
- sys.stderr.write("Changing owner for %s failed\n" % dirname)
-
-
-def createPath(path, user='apache', group='root', chmod=0755, logging=1):
- """advanced makedirs
-
- Will create the path if necessary.
- Will chmod, and chown that path properly.
-
- Uses the above makedirs() function.
- """
-
- path = rhnLib.cleanupAbsPath(path)
- if not os.path.exists(path):
- if logging:
- log(4, " Creating path: %s" % path, stream=sys.stderr)
- makedirs(path, mode=chmod, user=user, group=group)
- elif not os.path.isdir(path):
- raise ValueError, "ERROR: createPath('%s'): path doesn't lead to a directory" % str(path)
- else:
- os.chmod(path, chmod)
- uid, gid = getUidGid(user, group)
- try:
- os.chown(path, uid, gid)
- except OSError:
- # Changing permissions failed; ignore the error
- sys.stderr.write("Changing owner for %s failed\n" % path)
-
-
def intersection(seq0, seq1):
"""return the intersection of two sequences
returns three lists (common, unique in first seq, unique in second seq)
14 years, 4 months
java/code
by Justin Sherrill
java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java | 2 +-
java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java | 10 +++++-----
java/code/src/com/redhat/rhn/frontend/action/systems/test/ErrataConfirmSetupActionTest.java | 1 -
java/code/src/com/redhat/rhn/frontend/servlets/test/AuthFilterTest.java | 3 +++
java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java | 4 ++--
java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 2 +-
java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java | 2 +-
7 files changed, 13 insertions(+), 11 deletions(-)
New commits:
commit f58202116cb231298783720578f55d3b6b94b0c3
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Dec 8 11:54:43 2009 -0500
unit test fixes
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
index 18e3ae6..0ded30d 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
@@ -582,7 +582,7 @@ public class ChannelFactory extends HibernateFactory {
* @param checksum checksum label
* @return ChecksumType instance for given label
*/
- public static ChecksumType findChecksumByLabel(String checksum) {
+ public static ChecksumType findChecksumTypeByLabel(String checksum) {
Map params = new HashMap();
params.put("label", checksum);
return (ChecksumType)
diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
index 61b5a95..2e05906 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
@@ -388,15 +388,15 @@ public class ChannelFactoryTest extends RhnBaseTestCase {
public void testfindChecksumByLabel() {
assertNull("Checksum found for null label",
- ChannelFactory.findChecksumByLabel(null));
+ ChannelFactory.findChecksumTypeByLabel(null));
assertNull("Checksum found for invalid label",
- ChannelFactory.findChecksumByLabel("some-invalid_checksum"));
+ ChannelFactory.findChecksumTypeByLabel("some-invalid_checksum"));
- ChecksumType ct = ChannelFactory.findChecksumByLabel("sha-256");
+ ChecksumType ct = ChannelFactory.findChecksumTypeByLabel("sha256");
assertNotNull(ct);
- assertEquals("sha-256", ct.getLabel());
+ assertEquals("sha256", ct.getLabel());
- ChecksumType ct2 = ChannelFactory.findChecksumByLabel("sha1");
+ ChecksumType ct2 = ChannelFactory.findChecksumTypeByLabel("sha1");
assertNotNull(ct2);
assertEquals("sha1", ct2.getLabel());
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/test/ErrataConfirmSetupActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/systems/test/ErrataConfirmSetupActionTest.java
index eb7f7d1..fde328f 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/test/ErrataConfirmSetupActionTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/test/ErrataConfirmSetupActionTest.java
@@ -35,7 +35,6 @@ public class ErrataConfirmSetupActionTest extends RhnMockStrutsTestCase {
//Note: 2 invocations of getParameter("use_date") will be called by DatePicker
addRequestParameter(DatePicker.USE_DATE, "true");
actionPerform();
- assertNotNull(request.getAttribute("pageList"));
assertNotNull(request.getAttribute("system"));
Server server2 = (Server) request.getAttribute("system");
assertEquals(server, server2);
diff --git a/java/code/src/com/redhat/rhn/frontend/servlets/test/AuthFilterTest.java b/java/code/src/com/redhat/rhn/frontend/servlets/test/AuthFilterTest.java
index c76701d..f0f80f6 100644
--- a/java/code/src/com/redhat/rhn/frontend/servlets/test/AuthFilterTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/servlets/test/AuthFilterTest.java
@@ -21,6 +21,8 @@ import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
import org.jmock.core.Constraint;
+import java.util.Vector;
+
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -78,6 +80,7 @@ public class AuthFilterTest extends MockObjectTestCase {
mockRequest.stubs().method("getRequestDispatcher").withAnyArguments().will(
returnValue((RequestDispatcher)mockDispatcher.proxy()));
+ mockRequest.stubs().method("getHeaders").will(returnValue(new Vector().elements()));
filter.setAuthenticationService((AuthenticationService)mockAuthService.proxy());
}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java
index fc2e77a..bc71360 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java
@@ -518,7 +518,7 @@ public class ChannelSoftwareHandlerTest extends BaseHandlerTestCase {
ChannelSoftwareHandler csh = new ChannelSoftwareHandler();
addRole(admin, RoleFactory.CHANNEL_ADMIN);
int i = csh.create(adminKey, "api-test-checksum-chan-label",
- "apiTestCSChanName", "apiTestSummary", "channel-ia32", null, "sha-256");
+ "apiTestCSChanName", "apiTestSummary", "channel-ia32", null, "sha256");
assertEquals(1, i);
Channel c = ChannelFactory.lookupByLabel(admin.getOrg(),
"api-test-checksum-chan-label");
@@ -529,7 +529,7 @@ public class ChannelSoftwareHandlerTest extends BaseHandlerTestCase {
assertNotNull(ca);
assertNotNull(c.getChannelArch());
assertEquals(ca.getLabel(), c.getChannelArch().getLabel());
- assertEquals(c.getChecksumType(), "sha-256");
+ assertEquals(c.getChecksumType(), "sha256");
}
public void testCreateUnauthUser() {
diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
index e6f9d0c..5564a40 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@ -260,7 +260,7 @@ public class CreateChannelCommand {
throw new IllegalArgumentException("Invalid architecture label");
}
- ChecksumType ct = ChannelFactory.findChecksumByLabel(checksum);
+ ChecksumType ct = ChannelFactory.findChecksumTypeByLabel(checksum);
Channel c = ChannelFactory.createChannel();
diff --git a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
index 9300ae9..aabdbb2 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
@@ -67,7 +67,7 @@ public class UpdateChannelCommand extends CreateChannelCommand {
throw new IllegalArgumentException("Invalid architecture label");
}
- ChecksumType ct = ChannelFactory.findChecksumByLabel(checksum);
+ ChecksumType ct = ChannelFactory.findChecksumTypeByLabel(checksum);
if (!ct.getLabel().equals(c.getChecksum().getLabel()) && c.getPackageCount() > 0) {
// schedule repo re generation if the checksum type changed
14 years, 4 months
java/code
by Justin Sherrill
java/code/src/com/redhat/rhn/domain/common/Checksum.hbm.xml | 12 +++++-----
java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java | 5 ++--
java/code/src/com/redhat/rhn/domain/errata/ErrataFile.java | 5 ++--
java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrataFile.java | 7 +++--
4 files changed, 17 insertions(+), 12 deletions(-)
New commits:
commit ff46bce93acf830eac7f8d82b722e3871a41d08b
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Dec 8 10:44:28 2009 -0500
fixing errata files to correctly use Checksum objects for their checksum, also having Checksum use the correct sequence
diff --git a/java/code/src/com/redhat/rhn/domain/common/Checksum.hbm.xml b/java/code/src/com/redhat/rhn/domain/common/Checksum.hbm.xml
index eefc001..f984359 100644
--- a/java/code/src/com/redhat/rhn/domain/common/Checksum.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/common/Checksum.hbm.xml
@@ -2,12 +2,14 @@
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
+<hibernate-mapping default-access="property">
<class name="com.redhat.rhn.domain.common.Checksum"
- table="rhnChecksum" mutable="false">
- <id name="id" type="long" column="id">
- <meta attribute="scope-set">protected</meta>
- <generator class="assigned" />
+ table="rhnChecksum" >
+ <id name="id" type="long" column="id" >
+
+ <generator class="sequence">
+ <param name="sequence">rhnChecksum_seq</param>
+ </generator>
</id>
<property name="checksum" type="string" column="checksum" />
<many-to-one
diff --git a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
index 5eb202c..d3097cb 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
@@ -21,6 +21,7 @@ import com.redhat.rhn.common.hibernate.HibernateFactory;
import com.redhat.rhn.common.hibernate.HibernateRuntimeException;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.common.ChecksumFactory;
import com.redhat.rhn.domain.errata.impl.PublishedBug;
import com.redhat.rhn.domain.errata.impl.PublishedClonedErrata;
import com.redhat.rhn.domain.errata.impl.PublishedErrata;
@@ -505,7 +506,7 @@ public class ErrataFactory extends HibernateFactory {
Set packages) {
ErrataFile file = new UnpublishedErrataFile();
file.setFileType(ft);
- file.setChecksum(cs);
+ file.setChecksum(ChecksumFactory.safeCreate(cs, "md5"));
file.setFileName(name);
file.setPackages(packages);
return file;
@@ -538,7 +539,7 @@ public class ErrataFactory extends HibernateFactory {
Set packages) {
ErrataFile file = new PublishedErrataFile();
file.setFileType(ft);
- file.setChecksum(cs);
+ file.setChecksum(ChecksumFactory.safeCreate(cs, "md5"));
file.setFileName(name);
file.setPackages(packages);
return file;
diff --git a/java/code/src/com/redhat/rhn/domain/errata/ErrataFile.java b/java/code/src/com/redhat/rhn/domain/errata/ErrataFile.java
index 8bb304d..01f259b 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/ErrataFile.java
+++ b/java/code/src/com/redhat/rhn/domain/errata/ErrataFile.java
@@ -14,6 +14,7 @@
*/
package com.redhat.rhn.domain.errata;
+import com.redhat.rhn.domain.common.Checksum;
import com.redhat.rhn.domain.rhnpackage.Package;
import java.util.Date;
@@ -54,13 +55,13 @@ public interface ErrataFile {
* MD5 checksum
* @param cs checksums
*/
- void setChecksum(String cs);
+ void setChecksum(Checksum cs);
/**
* MD5 checksum
* @return checksum
*/
- String getChecksum();
+ Checksum getChecksum();
/**
* File name
diff --git a/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrataFile.java b/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrataFile.java
index d26a504..690b8d3 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrataFile.java
+++ b/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrataFile.java
@@ -16,6 +16,7 @@ package com.redhat.rhn.domain.errata.impl;
import com.redhat.rhn.domain.BaseDomainHelper;
import com.redhat.rhn.domain.channel.Channel;
+import com.redhat.rhn.domain.common.Checksum;
import com.redhat.rhn.domain.errata.Errata;
import com.redhat.rhn.domain.errata.ErrataFile;
import com.redhat.rhn.domain.errata.ErrataFileType;
@@ -34,7 +35,7 @@ public class PublishedErrataFile extends BaseDomainHelper implements ErrataFile
protected ErrataFileType fileType;
- protected String checksum;
+ protected Checksum checksum;
protected String fileName;
@@ -110,7 +111,7 @@ public class PublishedErrataFile extends BaseDomainHelper implements ErrataFile
* MD5 checksum
* @param cs checksums
*/
- public void setChecksum(String cs) {
+ public void setChecksum(Checksum cs) {
checksum = cs;
}
@@ -118,7 +119,7 @@ public class PublishedErrataFile extends BaseDomainHelper implements ErrataFile
* MD5 checksum
* @return checksum
*/
- public String getChecksum() {
+ public Checksum getChecksum() {
return checksum;
}
14 years, 4 months
Changes to 'refs/tags/spacewalk-backend-0.8.4-1'
by Michael Mraka
Tag 'spacewalk-backend-0.8.4-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2009-12-08 10:11 +0000
Tagging package [spacewalk-backend] version [0.8.4-1] in directory [backend/].
Changes since spacewalk-certs-tools-0.8.2-1:
Justin Sherrill (3):
updating PackageFile to support new sha256 work
checkstyle fix
checkstyle fix
Michael Mraka (2):
fixed file glob for -libs
Automatic commit of package [spacewalk-backend] release [0.8.4-1].
Milan Zazrivec (5):
533283 - don't restart crond if it wasn't running before
543980 - remove report_uuid.py
543980 - remove scripts/rhn-virtualization-guest script
543980 - get rid of rhn-virtualization-guest package
543980 - remove rhn-virtualization-guest script from Makefile
---
backend/spacewalk-backend.spec | 8
client/tools/rhn-virtualization/rhn-virtualization.spec | 35 ---
client/tools/rhn-virtualization/scripts/Makefile | 2
client/tools/rhn-virtualization/scripts/rhn-virtualization-guest | 28 --
client/tools/rhn-virtualization/virtualization/report_uuid.py | 99 ----------
java/code/src/com/redhat/rhn/domain/rhnpackage/PackageFile.hbm.xml | 4
java/code/src/com/redhat/rhn/domain/rhnpackage/PackageFile.java | 32 +--
java/code/src/com/redhat/rhn/domain/rhnpackage/test/PackageTest.java | 2
rel-eng/packages/spacewalk-backend | 2
9 files changed, 34 insertions(+), 178 deletions(-)
---
14 years, 4 months