backend/satellite_tools/repo_plugins/yum_src.py
| 30 ++++++++++
backend/satellite_tools/reposync.py
| 18 +++++-
rel-eng/packages/spacewalk-schema
| 2
schema/spacewalk/common/tables/rhnContentSourceSsl.sql
| 24 ++++++++
schema/spacewalk/oracle/triggers/rhnContentSourceSsl.sql
| 24 ++++++++
schema/spacewalk/postgres/triggers/rhnContentSourceSsl.sql
| 16 +++++
schema/spacewalk/spacewalk-schema.spec
| 6 +-
schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.oracle
| 24 ++++++++
schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.postgresql
| 25 ++++++++
schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.oracle
| 24 ++++++++
schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.postgresql
| 16 +++++
11 files changed, 206 insertions(+), 3 deletions(-)
New commits:
commit fcde8a0005fe1459db5f277d318a8a97c4c94a00
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 22 09:53:42 2013 +0100
Automatic commit of package [spacewalk-schema] release [1.9.13-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index 326f163..5600e81 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-1.9.12-1 schema/spacewalk/
+1.9.13-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec
b/schema/spacewalk/spacewalk-schema.spec
index a5ad7d7..bf49670 100644
--- a/schema/spacewalk/spacewalk-schema.spec
+++ b/schema/spacewalk/spacewalk-schema.spec
@@ -2,7 +2,7 @@ Name: spacewalk-schema
Group: Applications/Internet
Summary: Oracle SQL schema for Spacewalk server
-Version: 1.9.12
+Version: 1.9.13
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -68,6 +68,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-sql*
%changelog
+* Tue Jan 22 2013 Jan Pazdziora 1.9.13-1
+- Adding rhnContentSourceSsl, to hold certificates and keys to make
+ authenticated SSL connections.
+
* Fri Jan 18 2013 Jan Pazdziora 1.9.12-1
- Removing no longer used rhnChannelDownloads, rhnDownloads, and
rhnDownloadType.
commit 6f17b61d3e2bec74f87b7fa62ac61add0045f577
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Jan 7 17:05:22 2013 +0100
Use SSL options from rhncontentsourcessl during spacewalk-repo-sync.
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py
b/backend/satellite_tools/repo_plugins/yum_src.py
index c11c697..2bdab55 100644
--- a/backend/satellite_tools/repo_plugins/yum_src.py
+++ b/backend/satellite_tools/repo_plugins/yum_src.py
@@ -18,6 +18,8 @@ import shutil
import sys
import gzip
import os.path
+from shutil import rmtree
+from os import mkdir
import yum
from spacewalk.common import fileutils
@@ -246,3 +248,31 @@ class ContentSource(object):
except RepoMDError:
groups = None
return groups
+
+ def set_ssl_options(self, ca_cert, client_cert, client_key):
+ repo = self.repo
+ dir = os.path.join(repo.basecachedir, self.name, '.ssl-certs')
+ mkdir(dir, 0750)
+ repo.sslcacert = os.path.join(dir, 'ca.pem')
+ f = open(repo.sslcacert, "w")
+ f.write(str(ca_cert))
+ f.close
+ if client_cert is not None:
+ repo.sslclientcert = os.path.join(dir, 'cert.pem')
+ f = open(repo.sslclientcert, "w")
+ f.write(str(client_cert))
+ f.close
+ if client_key is not None:
+ repo.sslclientkey = os.path.join(dir, 'key.pem')
+ f = open(repo.sslclientkey, "w")
+ f.write(str(client_key))
+ f.close
+
+ def clear_ssl_cache(self):
+ return
+ repo = self.repo
+ dir = os.path.join(repo.basecachedir, self.name, '.ssl-certs')
+ try:
+ rmtree(dir)
+ except:
+ pass
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 29c1de6..e27d8b1 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -101,8 +101,23 @@ class RepoSync(object):
start_time = datetime.now()
for (repo_id, url) in self.urls:
self.print_msg("Repo URL: %s" % url)
+ plugin = None
try:
plugin = self.repo_plugin(url, self.channel_label)
+ if repo_id is not None:
+ keys = rhnSQL.fetchone_dict("""
+ select k1.key as ca_cert, k2.key as client_cert, k3.key as
client_key
+ from rhncontentsourcessl
+ join rhncryptokey k1
+ on rhncontentsourcessl.ssl_ca_cert_id = k1.id
+ left outer join rhncryptokey k2
+ on rhncontentsourcessl.ssl_client_cert_id = k2.id
+ left outer join rhncryptokey k3
+ on rhncontentsourcessl.ssl_client_key_id = k3.id
+ where rhncontentsourcessl.content_source_id = :repo_id
+ """, repo_id=int(repo_id))
+ if keys and keys.has_key('ca_cert'):
+ plugin.set_ssl_options(keys['ca_cert'],
keys['client_cert'], keys['client_key'])
self.import_packages(plugin, repo_id, url)
self.import_groups(plugin, url)
@@ -110,7 +125,8 @@ class RepoSync(object):
self.import_updates(plugin, url)
except Exception, e:
self.error_msg("ERROR: %s" % e)
- continue
+ if plugin is not None:
+ plugin.clear_ssl_cache()
if self.regen:
taskomatic.add_to_repodata_queue_for_channel_package_subscription(
[self.channel_label], [], "server.app.yumreposync")
commit fa12d75d44e7c0d771e867bc4fe48d443f28d2ad
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 8 13:58:27 2013 +0100
Adding rhnContentSourceSsl, to hold certificates and keys to make authenticated SSL
connections.
diff --git a/schema/spacewalk/common/tables/rhnContentSourceSsl.sql
b/schema/spacewalk/common/tables/rhnContentSourceSsl.sql
new file mode 100644
index 0000000..5e82270
--- /dev/null
+++ b/schema/spacewalk/common/tables/rhnContentSourceSsl.sql
@@ -0,0 +1,24 @@
+
+create table
+rhnContentSourceSsl
+(
+ id number not null
+ constraint rhn_csssl_id_pk primary key,
+ content_source_id number not null
+ constraint rhn_csssl_csid_uq unique
+ constraint rhn_csssl_csid_fk references rhnContentSource(id) on delete cascade,
+ ssl_ca_cert_id number not null
+ constraint rhn_csssl_cacertid_fk references rhnCryptoKey(id),
+ ssl_client_cert_id number
+ constraint rhn_csssl_clcertid_fk references rhnCryptoKey(id),
+ ssl_client_key_id number
+ constraint rhn_csssl_clkeyid_fk references rhnCryptoKey(id),
+ constraint rhn_csssl_client_chk check(ssl_client_key_id is null or ssl_client_cert_id is
not null),
+ created timestamp with local time zone default(current_timestamp) not null,
+ modified timestamp with local time zone default(current_timestamp) not null
+)
+enable row movement
+;
+
+create sequence rhn_contentsourcessl_seq;
+
diff --git a/schema/spacewalk/oracle/triggers/rhnContentSourceSsl.sql
b/schema/spacewalk/oracle/triggers/rhnContentSourceSsl.sql
new file mode 100644
index 0000000..10376b0
--- /dev/null
+++ b/schema/spacewalk/oracle/triggers/rhnContentSourceSsl.sql
@@ -0,0 +1,24 @@
+--
+-- Copyright (c) 2013 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.
+--
+
+create or replace trigger
+rhn_content_source_ssl_mod_trig
+before insert or update on rhnContentSourceSsl
+for each row
+begin
+ :new.modified := current_timestamp;
+end;
+/
+show errors
diff --git a/schema/spacewalk/postgres/triggers/rhnContentSourceSsl.sql
b/schema/spacewalk/postgres/triggers/rhnContentSourceSsl.sql
new file mode 100644
index 0000000..7ec289b
--- /dev/null
+++ b/schema/spacewalk/postgres/triggers/rhnContentSourceSsl.sql
@@ -0,0 +1,16 @@
+-- oracle equivalent source sha1 2330953d139fc07f77743e6bc63abb49d0a2d147
+
+create or replace function rhn_content_source_ssl_mod_trig_fun() returns trigger as
+$$
+begin
+ new.modified := current_timestamp;
+ return new;
+end;
+$$ language plpgsql;
+
+
+create trigger
+rhn_content_source_ssl_mod_trig
+before insert or update on rhnContentSourceSsl
+for each row
+execute procedure rhn_content_source_ssl_mod_trig_fun();
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.oracle
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.oracle
new file mode 100644
index 0000000..5e82270
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.oracle
@@ -0,0 +1,24 @@
+
+create table
+rhnContentSourceSsl
+(
+ id number not null
+ constraint rhn_csssl_id_pk primary key,
+ content_source_id number not null
+ constraint rhn_csssl_csid_uq unique
+ constraint rhn_csssl_csid_fk references rhnContentSource(id) on delete cascade,
+ ssl_ca_cert_id number not null
+ constraint rhn_csssl_cacertid_fk references rhnCryptoKey(id),
+ ssl_client_cert_id number
+ constraint rhn_csssl_clcertid_fk references rhnCryptoKey(id),
+ ssl_client_key_id number
+ constraint rhn_csssl_clkeyid_fk references rhnCryptoKey(id),
+ constraint rhn_csssl_client_chk check(ssl_client_key_id is null or ssl_client_cert_id is
not null),
+ created timestamp with local time zone default(current_timestamp) not null,
+ modified timestamp with local time zone default(current_timestamp) not null
+)
+enable row movement
+;
+
+create sequence rhn_contentsourcessl_seq;
+
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.postgresql
new file mode 100644
index 0000000..6637970
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/008-rhnContentSourceSsl.sql.postgresql
@@ -0,0 +1,25 @@
+-- oracle equivalent source sha1 dc0669403462ea1506d2fa1cf63fe45a81705c5b
+
+create table
+rhnContentSourceSsl
+(
+ id NUMERIC not null
+ constraint rhn_csssl_id_pk primary key,
+ content_source_id NUMERIC not null
+ constraint rhn_csssl_csid_uq unique
+ constraint rhn_csssl_csid_fk references rhnContentSource(id) on delete
cascade,
+ ssl_ca_cert_id NUMERIC not null
+ constraint rhn_csssl_cacertid_fk references rhnCryptoKey(id),
+ ssl_client_cert_id NUMERIC
+ constraint rhn_csssl_clcertid_fk references rhnCryptoKey(id),
+ ssl_client_key_id NUMERIC
+ constraint rhn_csssl_clkeyid_fk references rhnCryptoKey(id),
+ constraint rhn_csssl_client_chk check(ssl_client_key_id is null or
ssl_client_cert_id is not null),
+ created TIMESTAMPTZ default(current_timestamp) not null,
+ modified TIMESTAMPTZ default(current_timestamp) not null
+)
+
+;
+
+create sequence rhn_contentsourcessl_seq;
+
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.oracle
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.oracle
new file mode 100644
index 0000000..10376b0
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.oracle
@@ -0,0 +1,24 @@
+--
+-- Copyright (c) 2013 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.
+--
+
+create or replace trigger
+rhn_content_source_ssl_mod_trig
+before insert or update on rhnContentSourceSsl
+for each row
+begin
+ :new.modified := current_timestamp;
+end;
+/
+show errors
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.postgresql
new file mode 100644
index 0000000..7ec289b
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/009-rhn_content_source_ssl_mod_trig.sql.postgresql
@@ -0,0 +1,16 @@
+-- oracle equivalent source sha1 2330953d139fc07f77743e6bc63abb49d0a2d147
+
+create or replace function rhn_content_source_ssl_mod_trig_fun() returns trigger as
+$$
+begin
+ new.modified := current_timestamp;
+ return new;
+end;
+$$ language plpgsql;
+
+
+create trigger
+rhn_content_source_ssl_mod_trig
+before insert or update on rhnContentSourceSsl
+for each row
+execute procedure rhn_content_source_ssl_mod_trig_fun();