Branch 'VADER' - java/code
by Shannon Hughes
java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
New commits:
commit bb1fb53e5d153c69c90b390c3138e3aa5485cfc3
Author: Shannon Hughes <shughes(a)redhat.com>
Date: Mon Aug 3 16:28:42 2009 -0400
514994 - added logic to keep channel family name lengh at 128 or lower
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
index 29bde86..7e9862c 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
@@ -108,7 +108,15 @@ public class ChannelFamilyFactory extends HibernateFactory {
if (cfam == null) {
String label = "private-channel-family-" + orgIn.getId();
- String name = orgIn.getName() + " (" + orgIn.getId() + ") Channel Family";
+ String suffix = " (" + orgIn.getId() + ") Channel Family";
+ String prefix = orgIn.getName();
+ int len = prefix.length() + suffix.length();
+ if (len > 128) {
+ int diff = len - 128;
+ prefix = prefix.substring(1, prefix.length() - diff);
+ }
+
+ String name = prefix.concat(suffix);
cfam = new ChannelFamily();
cfam.setOrg(orgIn);
14 years, 8 months
client/rhel
by Pradeep Kilambi
client/rhel/rhn-client-tools/rhn-client-tools.spec | 9 ++++++
client/rhel/rhn-client-tools/src/firstboot/rhn_activate_gui.py | 2 +
client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py | 1
client/rhel/yum-rhn-plugin/yum-rhn-plugin.spec | 15 ++++++++--
4 files changed, 24 insertions(+), 3 deletions(-)
New commits:
commit e1cf5266ae19717afe714a8b30ad2f1202132173
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Aug 3 14:58:51 2009 -0400
client tools merge from svn
diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index bdab38e..0486907 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -204,6 +204,12 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/applications/rhn_register.desktop
%changelog
+* Wed Jul 29 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.4.20-9
+- Resolves: #445881
+
+* Mon Jun 29 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.4.20-8
+- Resolves: #467866
+
* Fri Jun 26 2009 Miroslav Suchy <msuchy(a)redhat.com> 0.6.1-1
- code cleanup - there is no usage of md5 in this code
- bump up version to 0.6
@@ -224,6 +230,9 @@ rm -rf $RPM_BUILD_ROOT
- Send smbios data to remaining_subscriptions during registration
(jbowes(a)redhat.com)
+* Fri Jun 12 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.4.20-7
+- Resolves: #504292 #467866
+
* Fri Jun 5 2009 Pradeep Kilambi <pkilambi(a)redhat.com>
- Resolves: #504296
diff --git a/client/rhel/rhn-client-tools/src/firstboot/rhn_activate_gui.py b/client/rhel/rhn-client-tools/src/firstboot/rhn_activate_gui.py
index c58ab72..8e8f8e2 100644
--- a/client/rhel/rhn-client-tools/src/firstboot/rhn_activate_gui.py
+++ b/client/rhel/rhn-client-tools/src/firstboot/rhn_activate_gui.py
@@ -55,6 +55,8 @@ class RhnActivateWindow(RhnRegisterFirstbootGuiWindow, rhnregGui.ActivateSubscri
def __init__(self):
RhnRegisterFirstbootGuiWindow.__init__(self)
rhnregGui.ActivateSubscriptionPage.__init__(self)
+ if rhnreg.registered():
+ self.skipme = True
def updatePage(self):
self.activateSubscriptionPagePrepare()
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py b/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
index 1ed7a30..87b6662 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
@@ -41,6 +41,7 @@ class RetryServer(rpclib.Server):
except rpclib.Fault:
raise
except httplib.BadStatusLine:
+ self.log.log_me("Error: Server Unavailable. Please try later.")
stdoutMsgCallback(
_("Error: Server Unavailable. Please try later."))
sys.exit(-1)
diff --git a/client/rhel/yum-rhn-plugin/yum-rhn-plugin.spec b/client/rhel/yum-rhn-plugin/yum-rhn-plugin.spec
index 1a0b102..bde6dc8 100644
--- a/client/rhel/yum-rhn-plugin/yum-rhn-plugin.spec
+++ b/client/rhel/yum-rhn-plugin/yum-rhn-plugin.spec
@@ -13,9 +13,9 @@ BuildRequires: rhpl
BuildRequires: intltool
BuildRequires: gettext
-Requires: yum >= 3.0-5.3
-Requires: rhn-client-tools >= 0.4.19
-Requires: m2crypto
+Requires: yum >= 3.2.19-15
+Requires: rhn-client-tools >= 0.4.19-9
+Requires: m2crypto >= 0.16-6.el5.6
# Not really, but for upgrades we need these
Requires: rhn-setup
@@ -60,9 +60,18 @@ make -f Makefile.yum-rhn-plugin install VERSION=%{version}-%{release} PREFIX=$RP
%changelog
+* Mon Aug 3 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.5.4-13%{?dist}
+- Resolves: #514503
+
* Fri Jun 26 2009 John Matthews <jmatthew(a)redhat.com> 0.5.7-1
- yum-rhn-plugin requires m2crypto
+* Mon Jun 22 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.5.4-10%{?dist}
+- Resolves: #484245
+
+* Fri Jun 12 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.5.4-9%{?dist}
+- Resolves: #467866
+
* Thu Jun 25 2009 John Matthews <jmatthew(a)redhat.com> 0.5.6-1
- yum operations are not getting redirected as the GET requested is formed at
the plugin level and not through rhnlib. (pkilambi(a)redhat.com)
14 years, 8 months
java/code
by Shannon Hughes
java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp | 2 +-
java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 4e1c0e4832d7ec9e91c36e0b125a6098eda6c30d
Author: Shannon Hughes <shughes(a)redhat.com>
Date: Mon Aug 3 14:41:54 2009 -0400
514792 - fix spelling error for form var on jsp page
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp
index 10e0b1a..dc4acb3 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp
@@ -71,7 +71,7 @@
<input type="hidden" name="maintainer_email" value="${maintainer_email}" />
<input type="hidden" name="maintainer_phone" value="${maintainer_phone}" />
<input type="hidden" name="support_policy" value="${support_policy}" />
- <input type="hidden" name="per_user_subscriptions" value="${per_user_subsriptions}" />
+ <input type="hidden" name="per_user_subscriptions" value="${per_user_subscriptions}" />
<input type="hidden" name="org_sharing" value="${org_sharing}" />
<input type="hidden" name="gpg_key_url" value="${gpg_key_url}" />
<input type="hidden" name="gpg_key_id" value="${gpg_key_id}" />
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp
index b12c2a8..d7b23da 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp
@@ -72,7 +72,7 @@
<input type="hidden" name="maintainer_email" value="${maintainer_email}" />
<input type="hidden" name="maintainer_phone" value="${maintainer_phone}" />
<input type="hidden" name="support_policy" value="${support_policy}" />
- <input type="hidden" name="per_user_subscriptions" value="${per_user_subsriptions}" />
+ <input type="hidden" name="per_user_subscriptions" value="${per_user_subscriptions}" />
<input type="hidden" name="org_sharing" value="${org_sharing}" />
<input type="hidden" name="gpg_key_url" value="${gpg_key_url}" />
<input type="hidden" name="gpg_key_id" value="${gpg_key_id}" />
14 years, 8 months
Branch 'VADER' - java/code
by Shannon Hughes
java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp | 2 +-
java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 04902088ef76940212f4dfcb9201fc547d894c94
Author: Shannon Hughes <shughes(a)redhat.com>
Date: Mon Aug 3 14:41:54 2009 -0400
514792 - fix spelling error for form var on jsp page
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp
index 95dbe17..785cdc6 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprivate.jsp
@@ -79,7 +79,7 @@
<input type="hidden" name="maintainer_email" value="${maintainer_email}" />
<input type="hidden" name="maintainer_phone" value="${maintainer_phone}" />
<input type="hidden" name="support_policy" value="${support_policy}" />
- <input type="hidden" name="per_user_subscriptions" value="${per_user_subsriptions}" />
+ <input type="hidden" name="per_user_subscriptions" value="${per_user_subscriptions}" />
<input type="hidden" name="org_sharing" value="${org_sharing}" />
<input type="hidden" name="gpg_key_url" value="${gpg_key_url}" />
<input type="hidden" name="gpg_key_id" value="${gpg_key_id}" />
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp
index 0c55f7c..7e40828 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/confirmprotected.jsp
@@ -80,7 +80,7 @@
<input type="hidden" name="maintainer_email" value="${maintainer_email}" />
<input type="hidden" name="maintainer_phone" value="${maintainer_phone}" />
<input type="hidden" name="support_policy" value="${support_policy}" />
- <input type="hidden" name="per_user_subscriptions" value="${per_user_subsriptions}" />
+ <input type="hidden" name="per_user_subscriptions" value="${per_user_subscriptions}" />
<input type="hidden" name="org_sharing" value="${org_sharing}" />
<input type="hidden" name="gpg_key_url" value="${gpg_key_url}" />
<input type="hidden" name="gpg_key_id" value="${gpg_key_id}" />
14 years, 8 months
schema/spacewalk
by Justin Sherrill
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql | 46 --------
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSourceType.sql | 46 ++++++++
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql | 57 ----------
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSource.sql | 57 ++++++++++
4 files changed, 103 insertions(+), 103 deletions(-)
New commits:
commit 8e09c300d95336fa21d31f3ffbddfceda470f207
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 14:19:14 2009 -0400
fixing small typo in upgrade script names
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql
deleted file mode 100644
index 546a3e1..0000000
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql
+++ /dev/null
@@ -1,46 +0,0 @@
---
--- Copyright (c) 2008 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 table
-rhnContentSourceType
-(
- id number
- constraint rhn_cst_id_nn not null
- constraint rhn_cst_id_pk primary key,
- label varchar2(32)
- constraint rhn_cst_label_nn not null
- constraint rhn_cst_label_uq unique,
- created date default(sysdate)
- constraint rhn_cst_created_nn not null,
- modified date default(sysdate)
- constraint rhn_cst_modified_nn not null
-)
- enable row movement
- ;
-
-create sequence rhn_content_source_type_id_seq start with 500;
-
-create index rhn_ccst_id_l_idx
- on rhnContentSourceType(id,label)
- tablespace [[64k_tbs]]
- ;
-
-
-insert into rhnContentSourceType (id, label) values
-(rhn_content_source_type_id_seq.nextval, 'yum');
-
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSourceType.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSourceType.sql
new file mode 100644
index 0000000..546a3e1
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSourceType.sql
@@ -0,0 +1,46 @@
+--
+-- Copyright (c) 2008 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 table
+rhnContentSourceType
+(
+ id number
+ constraint rhn_cst_id_nn not null
+ constraint rhn_cst_id_pk primary key,
+ label varchar2(32)
+ constraint rhn_cst_label_nn not null
+ constraint rhn_cst_label_uq unique,
+ created date default(sysdate)
+ constraint rhn_cst_created_nn not null,
+ modified date default(sysdate)
+ constraint rhn_cst_modified_nn not null
+)
+ enable row movement
+ ;
+
+create sequence rhn_content_source_type_id_seq start with 500;
+
+create index rhn_ccst_id_l_idx
+ on rhnContentSourceType(id,label)
+ tablespace [[64k_tbs]]
+ ;
+
+
+insert into rhnContentSourceType (id, label) values
+(rhn_content_source_type_id_seq.nextval, 'yum');
+
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
deleted file mode 100644
index ccf5cb8..0000000
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
+++ /dev/null
@@ -1,57 +0,0 @@
---
--- Copyright (c) 2008 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 table
-rhnChannelContentSource
-(
- id number
- constraint rhn_ccs_id_nn not null
- constraint rhn_ccs_id_pk primary key,
- channel_id number
- constraint rhn_ccs_c_nn not null
- constraint rhn_ccs_c_fk
- references rhnChannel(id) on delete cascade,
- type_id number
- constraint rhn_ccs_type_nn not null
- constraint rhn_ccs_type_fk
- references rhnContentSourceType(id),
- source_url varchar2(512)
- constraint rhn_ccs_url_nn not null,
- label varchar2(64)
- constraint rhn_ccs_l_nn not null,
- last_synced date,
- created date default(sysdate)
- constraint rhn_ccs_cre_nn not null,
- modified date default(sysdate)
- constraint rhn_ccs_mod_nn not null
-)
- enable row movement
- ;
-
-
-create sequence rhn_chan_content_src_id_seq start with 500;
-
-
-create unique index rhn_ccs_uq
- on rhnChannelContentSource(channel_id, type_id, source_url)
- tablespace [[64k_tbs]]
- ;
-
-/
-show errors
-
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSource.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSource.sql
new file mode 100644
index 0000000..ccf5cb8
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSource.sql
@@ -0,0 +1,57 @@
+--
+-- Copyright (c) 2008 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 table
+rhnChannelContentSource
+(
+ id number
+ constraint rhn_ccs_id_nn not null
+ constraint rhn_ccs_id_pk primary key,
+ channel_id number
+ constraint rhn_ccs_c_nn not null
+ constraint rhn_ccs_c_fk
+ references rhnChannel(id) on delete cascade,
+ type_id number
+ constraint rhn_ccs_type_nn not null
+ constraint rhn_ccs_type_fk
+ references rhnContentSourceType(id),
+ source_url varchar2(512)
+ constraint rhn_ccs_url_nn not null,
+ label varchar2(64)
+ constraint rhn_ccs_l_nn not null,
+ last_synced date,
+ created date default(sysdate)
+ constraint rhn_ccs_cre_nn not null,
+ modified date default(sysdate)
+ constraint rhn_ccs_mod_nn not null
+)
+ enable row movement
+ ;
+
+
+create sequence rhn_chan_content_src_id_seq start with 500;
+
+
+create unique index rhn_ccs_uq
+ on rhnChannelContentSource(channel_id, type_id, source_url)
+ tablespace [[64k_tbs]]
+ ;
+
+/
+show errors
+
14 years, 8 months
25 commits - backend/Makefile.backend backend/satellite_tools backend/server backend/spacewalk-backend.spec backend/upload_server java/buildconf java/code schema/spacewalk
by Justin Sherrill
backend/Makefile.backend | 2
backend/satellite_tools/Makefile | 6
backend/satellite_tools/repo_plugins/Makefile | 27 +
backend/satellite_tools/repo_plugins/__init__.py | 15
backend/satellite_tools/repo_plugins/yum_src.py | 64 ++
backend/satellite_tools/reposync.py | 244 ++++++++++
backend/satellite_tools/spacewalk-debug.8 | 20
backend/satellite_tools/spacewalk-repo-sync | 79 +++
backend/server/Makefile | 4
backend/server/basePackageUpload.py | 100 ++++
backend/server/rhnPackage.py | 16
backend/server/rhnPackageUpload.py | 71 --
backend/spacewalk-backend.spec | 7
backend/upload_server/handlers/package_push/package_push.py | 10
backend/upload_server/handlers/package_upload/package_upload.py | 8
java/buildconf/builder/config/satellite/rhn.conf | 2
java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java | 3
java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml | 8
java/code/src/com/redhat/rhn/domain/channel/Channel.java | 51 ++
java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java | 40 +
java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml | 41 +
java/code/src/com/redhat/rhn/domain/channel/ContentSource.java | 131 +++++
java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml | 26 +
java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java | 59 ++
java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java | 14
java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml | 8
java/code/src/com/redhat/rhn/domain/task/TaskFactory.java | 29 +
java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java | 30 +
java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 3
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 21
java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 46 +
java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java | 8
java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java | 114 ++++
java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp | 39 +
java/code/webapp/WEB-INF/struts-config.xml | 3
schema/spacewalk/common/tables/rhnChannelContentSource.sql | 61 ++
schema/spacewalk/common/tables/rhnContentSourceType.sql | 48 +
schema/spacewalk/common/tables/rhnContentSourceType_data.sql | 21
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql | 46 +
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql | 57 ++
40 files changed, 1477 insertions(+), 105 deletions(-)
New commits:
commit b397990514e0aed7cfcb77d5ea83a60664ea51b9
Merge: c273e9e... 074cca0...
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 14:06:12 2009 -0400
Merge branch 'master' into repo-sync
commit c273e9e74814bc85658472c21c9bfb9b69385d10
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 13:13:55 2009 -0400
moving three new tables for postgres merge
diff --git a/schema/spacewalk/common/tables/rhnChannelContentSource.sql b/schema/spacewalk/common/tables/rhnChannelContentSource.sql
new file mode 100644
index 0000000..f0b30a5
--- /dev/null
+++ b/schema/spacewalk/common/tables/rhnChannelContentSource.sql
@@ -0,0 +1,61 @@
+--
+-- Copyright (c) 2008 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 table
+rhnChannelContentSource
+(
+ id number
+ constraint rhn_ccs_id_nn not null
+ constraint rhn_ccs_id_pk primary key,
+ channel_id number
+ constraint rhn_ccs_c_nn not null
+ constraint rhn_ccs_c_fk
+ references rhnChannel(id) on delete cascade,
+ type_id number
+ constraint rhn_ccs_type_nn not null
+ constraint rhn_ccs_type_fk
+ references rhnContentSourceType(id),
+ source_url varchar2(512)
+ constraint rhn_ccs_url_nn not null,
+ label varchar2(64)
+ constraint rhn_ccs_l_nn not null,
+ last_synced date,
+ created date default(sysdate)
+ constraint rhn_ccs_cre_nn not null,
+ modified date default(sysdate)
+ constraint rhn_ccs_mod_nn not null
+)
+ enable row movement
+ ;
+
+
+create sequence rhn_chan_content_src_id_seq start with 500;
+
+
+create unique index rhn_ccs_uq
+ on rhnChannelContentSource(channel_id, type_id, source_url)
+ tablespace [[64k_tbs]]
+ ;
+
+/
+show errors
+
+--
+-- Revision 1.0 2009/06/26 21:54 jlsherrill
+-- Initial file.
+--
diff --git a/schema/spacewalk/common/tables/rhnContentSourceType.sql b/schema/spacewalk/common/tables/rhnContentSourceType.sql
new file mode 100644
index 0000000..6e0ce24
--- /dev/null
+++ b/schema/spacewalk/common/tables/rhnContentSourceType.sql
@@ -0,0 +1,48 @@
+--
+-- Copyright (c) 2008 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 table
+rhnContentSourceType
+(
+ id number
+ constraint rhn_cst_id_nn not null
+ constraint rhn_cst_id_pk primary key,
+ label varchar2(32)
+ constraint rhn_cst_label_nn not null
+ constraint rhn_cst_label_uq unique,
+ created date default(sysdate)
+ constraint rhn_cst_created_nn not null,
+ modified date default(sysdate)
+ constraint rhn_cst_modified_nn not null
+)
+ enable row movement
+ ;
+
+create sequence rhn_content_source_type_id_seq start with 500;
+
+create index rhn_ccst_id_l_idx
+ on rhnContentSourceType(id,label)
+ tablespace [[64k_tbs]]
+ ;
+
+show errors
+
+--
+-- Revision 1.0 2002/11/13 21:50:21 jlsherrill
+-- initial table add
+--
diff --git a/schema/spacewalk/common/tables/rhnContentSourceType_data.sql b/schema/spacewalk/common/tables/rhnContentSourceType_data.sql
new file mode 100644
index 0000000..db3424c
--- /dev/null
+++ b/schema/spacewalk/common/tables/rhnContentSourceType_data.sql
@@ -0,0 +1,21 @@
+--
+-- Copyright (c) 2008 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.
+--
+--
+--
+--
+
+insert into rhnContentSourceType (id, label) values
+(rhn_content_source_type_id_seq.nextval, 'yum');
+
diff --git a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
deleted file mode 100644
index f0b30a5..0000000
--- a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
+++ /dev/null
@@ -1,61 +0,0 @@
---
--- Copyright (c) 2008 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 table
-rhnChannelContentSource
-(
- id number
- constraint rhn_ccs_id_nn not null
- constraint rhn_ccs_id_pk primary key,
- channel_id number
- constraint rhn_ccs_c_nn not null
- constraint rhn_ccs_c_fk
- references rhnChannel(id) on delete cascade,
- type_id number
- constraint rhn_ccs_type_nn not null
- constraint rhn_ccs_type_fk
- references rhnContentSourceType(id),
- source_url varchar2(512)
- constraint rhn_ccs_url_nn not null,
- label varchar2(64)
- constraint rhn_ccs_l_nn not null,
- last_synced date,
- created date default(sysdate)
- constraint rhn_ccs_cre_nn not null,
- modified date default(sysdate)
- constraint rhn_ccs_mod_nn not null
-)
- enable row movement
- ;
-
-
-create sequence rhn_chan_content_src_id_seq start with 500;
-
-
-create unique index rhn_ccs_uq
- on rhnChannelContentSource(channel_id, type_id, source_url)
- tablespace [[64k_tbs]]
- ;
-
-/
-show errors
-
---
--- Revision 1.0 2009/06/26 21:54 jlsherrill
--- Initial file.
---
diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql
deleted file mode 100644
index 6e0ce24..0000000
--- a/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql
+++ /dev/null
@@ -1,48 +0,0 @@
---
--- Copyright (c) 2008 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 table
-rhnContentSourceType
-(
- id number
- constraint rhn_cst_id_nn not null
- constraint rhn_cst_id_pk primary key,
- label varchar2(32)
- constraint rhn_cst_label_nn not null
- constraint rhn_cst_label_uq unique,
- created date default(sysdate)
- constraint rhn_cst_created_nn not null,
- modified date default(sysdate)
- constraint rhn_cst_modified_nn not null
-)
- enable row movement
- ;
-
-create sequence rhn_content_source_type_id_seq start with 500;
-
-create index rhn_ccst_id_l_idx
- on rhnContentSourceType(id,label)
- tablespace [[64k_tbs]]
- ;
-
-show errors
-
---
--- Revision 1.0 2002/11/13 21:50:21 jlsherrill
--- initial table add
---
diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql
deleted file mode 100644
index db3424c..0000000
--- a/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql
+++ /dev/null
@@ -1,21 +0,0 @@
---
--- Copyright (c) 2008 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.
---
---
---
---
-
-insert into rhnContentSourceType (id, label) values
-(rhn_content_source_type_id_seq.nextval, 'yum');
-
commit 29c7e5ec1f630b621000151ea497ef2e0f40b519
Merge: 50bd935... a98d583...
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 13:12:17 2009 -0400
merge conflict
diff --cc backend/satellite_tools/Makefile
index d05d130,c2c08c0..e14fdaa
--- a/backend/satellite_tools/Makefile
+++ b/backend/satellite_tools/Makefile
@@@ -16,7 -16,14 +16,14 @@@ FILES = __init__ connection diskImportL
SCRIPTS = satellite-sync spacewalk-debug\
rhn-schema-version rhn-satellite-activate rhn-charsets \
- rhn-ssl-dbstore update-packages rhn-db-stats spacewalk-repo-sync
+ rhn-ssl-dbstore update-packages rhn-db-stats \
- spacewalk-report
++ spacewalk-repo-sync spacewalk-report
+
+ SPACEWALK_SUBDIRS = reports reports/data
+
+ SPACEWALK_FILES = reports
+
+ SPACEWALK_REPORT_FILES = reports/data
# check if we can build man pages
DOCBOOK = $(wildcard /usr/bin/docbook2man)
diff --cc backend/spacewalk-backend.spec
index d9d77c6,77196db..4bd53ae
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@@ -506,9 -505,9 +506,10 @@@ rm -f %{rhnconf}/rhnSecret.py
%attr(755,root,root) %{_bindir}/rhn-ssl-dbstore
%attr(755,root,root) %{_bindir}/satellite-sync
%attr(755,root,root) %{_bindir}/spacewalk-debug
+ %attr(755,root,root) %{_bindir}/spacewalk-report
%attr(755,root,root) %{_bindir}/rhn-satellite-exporter
%attr(755,root,root) %{_bindir}/update-packages
+%attr(755,root,root) %{_bindir}/spacewalk-repo-sync
%attr(755,root,root) %{_bindir}/rhn-db-stats
%attr(750,root,root) %{_bindir}/satpasswd
%attr(750,root,root) %{_bindir}/satwho
@@@ -537,10 -535,8 +538,12 @@@
%{rhnroot}/satellite_tools/disk_dumper/iss_actions.py*
%{rhnroot}/satellite_tools/disk_dumper/dumper.py*
%{rhnroot}/satellite_tools/disk_dumper/string_buffer.py*
+%dir %{rhnroot}/satellite_tools/repo_plugins
+%attr(770,root,apache) %dir %{_var}/log/rhn/reposync
+%{rhnroot}/satellite_tools/repo_plugins/__init__.py*
+%{rhnroot}/satellite_tools/repo_plugins/yum_src.py*
+ %{_prefix}/share/spacewalk/reports.py*
+ %{_prefix}/share/spacewalk/reports/data/*
%config %attr(644,root,apache) %{rhnconf}/default/rhn_server_iss.conf
%{_mandir}/man8/rhn-satellite-exporter.8*
%{_mandir}/man8/rhn-charsets.8*
diff --cc java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
index 275dd45,a078105..172d7e7
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@@ -17,8 -17,8 +17,9 @@@ package com.redhat.rhn.manager.channel
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelArch;
import com.redhat.rhn.domain.channel.ChannelFactory;
+ import com.redhat.rhn.domain.common.ChecksumType;
import com.redhat.rhn.domain.role.RoleFactory;
+import com.redhat.rhn.domain.task.TaskFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException;
diff --cc java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
index 80b8e80,6447deb..9300ae9
--- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
@@@ -17,7 -17,7 +17,8 @@@ package com.redhat.rhn.manager.channel
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.task.TaskFactory;
+ import com.redhat.rhn.domain.common.ChecksumType;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException;
import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException;
commit 50bd93570a4840063d2d42ef92097d4685fb4827
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 13:02:33 2009 -0400
adding newline to error message output
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 37d01bb..80f830e 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -210,7 +210,7 @@ class RepoSync:
def error_msg(self, message):
rhnLog.log_clean(0, message)
- sys.stderr.write(message)
+ sys.stderr.write(str(message) + "\n")
def log_msg(self, message):
rhnLog.log_clean(0, message)
commit c4f32e97c88e5d175f365ed65d24b76391d669a2
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 12:54:57 2009 -0400
fixing small method call in reposync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 97ec97e..37d01bb 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -56,7 +56,7 @@ class RepoSync:
self.error_msg("--url must be specified")
if not options.type:
quit = True
- self.error_message("--type must be specified")
+ self.error_msg("--type must be specified")
if not options.channel_label:
quit = True
self.error_msg("--channel must be specified")
commit 10c32328e6ac2f63b93f5e815179a57a10439be4
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 12:49:11 2009 -0400
fixing specfile to create directory for reposync
diff --git a/backend/Makefile.backend b/backend/Makefile.backend
index 73ca5c7..378723e 100644
--- a/backend/Makefile.backend
+++ b/backend/Makefile.backend
@@ -7,7 +7,7 @@ CONF_DIRS = apache-conf httpd-conf rhn-conf logrotate
# We look for config files in "well known" locations (rhn-conf,
# httpd-conf, logrotate)
-EXTRA_DIRS = /var/log/rhn /var/cache/rhn
+EXTRA_DIRS = /var/log/rhn /var/log/rhn/reposync /var/cache/rhn
all :: all-code all-conf
commit b2066fa2460ae2ec32a8a24958e155ce8420d4e0
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 12:43:11 2009 -0400
fixing small whitespace error with reposync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 6d03b60..97ec97e 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -76,8 +76,7 @@ class RepoSync:
self.repo_label = options.label
self.channel = self.load_channel()
- if not self.channel or not \
- rhnChannel.isCustomChannel(self.channel['id']):
+ if not self.channel or not rhnChannel.isCustomChannel(self.channel['id']):
print "Channel does not exist or is not custom"
sys.exit(1)
commit c03775d9bcb4e6387e6f04e1398c05f0128252c9
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 12:41:00 2009 -0400
adding better logging for spacewalk-repo-sync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 9418a78..6d03b60 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -13,7 +13,7 @@
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
-import sys, os
+import sys, os, time
from optparse import OptionParser
from common import rhnLib
from server import rhnPackage, rhnSQL, rhnChannel, rhnPackageUpload
@@ -23,6 +23,9 @@ from server.importlib.importLib import IncompletePackage
from server.importlib.backendOracle import OracleBackend
from server.importlib.packageImport import ChannelPackageSubscription
+
+default_log_location = '/var/log/rhn/reposync/'
+
class RepoSync:
parser = None
type = None
@@ -39,30 +42,32 @@ class RepoSync:
rhnSQL.initDB(db_string)
(options, args) = self.process_args()
+ log_filename = 'reposync.log'
+ if options.channel_label and options.label:
+ date = time.localtime()
+ datestr = '%s.%s.%s-%s:%s:%s' % (date.tm_year, date.tm_mon, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec)
+ log_filename = options.channel_label + '-' + options.label + '-' + datestr + '.log'
+
+ rhnLog.initLOG(default_log_location + log_filename)
quit = False
if not options.url:
quit = True
- print("--url must be specified")
+ self.error_msg("--url must be specified")
if not options.type:
quit = True
- print("--type must be specified")
+ self.error_message("--type must be specified")
if not options.channel_label:
quit = True
- print("--channel must be specified")
+ self.error_msg("--channel must be specified")
if not options.label:
quit = True
- print("--label must be specified")
-
- self.log_file = options.logfile
- if self.log_file:
- rhnLog.initLOG(self.log_file)
-
- self.error_msg(str(sys.argv))
+ self.error_msg("--label must be specified")
if quit:
sys.exit(1)
+ self.log_msg(str(sys.argv))
self.type = options.type
self.url = options.url
@@ -70,9 +75,8 @@ class RepoSync:
self.fail = options.fail
self.repo_label = options.label
self.channel = self.load_channel()
- self.log_file = options.logfile
- if not self.channel or not \
+ if not self.channel or not \
rhnChannel.isCustomChannel(self.channel['id']):
print "Channel does not exist or is not custom"
sys.exit(1)
@@ -89,7 +93,6 @@ class RepoSync:
self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported')
self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo')
self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation")
- self.parser.add_option('-g', '--logfile', action='store', dest='logfile', help="The log file to log to. Default is to stderr and stdout.")
return self.parser.parse_args()
def load_plugin(self):
@@ -101,7 +104,7 @@ class RepoSync:
def import_packages(self, packages):
to_link = []
to_download = []
- self.print_msg("Repo " + self.url + " has " + str(len(packages)) + ".")
+ self.print_msg("Repo " + self.url + " has " + str(len(packages)) + " packages.")
for pack in packages:
pid = None
if pack.checksums.has_key('md5sum'):
@@ -202,16 +205,17 @@ class RepoSync:
def print_msg(self, message):
- if self.log_file:
- rhnLog.log_clean(0, message)
+ rhnLog.log_clean(0, message)
print message
def error_msg(self, message):
- if self.log_file:
- rhnLog.log_clean(0, message)
+ rhnLog.log_clean(0, message)
sys.stderr.write(message)
+ def log_msg(self, message):
+ rhnLog.log_clean(0, message)
+
class ContentPackage:
#map of checksums. Valid keys are 'md5sum' & 'sha256'
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 1fe9866..d9d77c6 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -538,6 +538,7 @@ rm -f %{rhnconf}/rhnSecret.py*
%{rhnroot}/satellite_tools/disk_dumper/dumper.py*
%{rhnroot}/satellite_tools/disk_dumper/string_buffer.py*
%dir %{rhnroot}/satellite_tools/repo_plugins
+%attr(770,root,apache) %dir %{_var}/log/rhn/reposync
%{rhnroot}/satellite_tools/repo_plugins/__init__.py*
%{rhnroot}/satellite_tools/repo_plugins/yum_src.py*
%config %attr(644,root,apache) %{rhnconf}/default/rhn_server_iss.conf
commit d9321c436afdf239f19d8df66d447217806496ba
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Fri Jul 31 14:57:42 2009 -0400
check style fixes
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
index e61da3f..65b411d 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
@@ -818,6 +818,7 @@ public class Channel extends BaseDomainHelper implements Comparable {
* Set the yum content source, if one is already set, it will be replaced
* if null or '' is passed in, all content sources will be removed.
* @param url the url of the yum repo
+ * @param labelIn the label of the content source
*/
public void setYumContentSource(String url, String labelIn) {
if (StringUtils.isEmpty(url)) {
diff --git a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java
index aa75626..af74c20 100644
--- a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java
@@ -68,9 +68,9 @@ public class TaskFactory extends HibernateFactory {
}
/**
- *
- * @param name
- * @return
+ * list All tasks with the given name
+ * @param name the name of the task
+ * @return List of tasks
*/
public static List<Task> listTasks(String name) {
Session session = null;
@@ -86,8 +86,8 @@ public class TaskFactory extends HibernateFactory {
}
/**
- *
- * @param task
+ * Remove a task from teh database
+ * @param task the task to remove
*/
public static void removeTask(Task task) {
TaskFactory.getSession().delete(task);
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
index 40a4c2c..f26278b 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
@@ -27,7 +27,6 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -66,8 +65,8 @@ public class RepoSyncTask implements Job {
for (Task task : TaskFactory.listTasks(DISPLAY_NAME)) {
ContentSource src = ChannelFactory.lookupContentSource(task.getData());
if (log.isInfoEnabled()) {
- log.info("Syncing repo " + src.getSourceUrl() + " to channel "
- + src.getChannel().getLabel());
+ log.info("Syncing repo " + src.getSourceUrl() + " to channel " +
+ src.getChannel().getLabel());
}
if (src == null) {
log.error("Content Source could not be found: " + task.getData());
commit cb96846c44dd4a9edb6bebf809043f4b38206d6f
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jul 30 18:11:31 2009 -0400
some repo sync task fixes
diff --git a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
index 4160ba1..1002d2f 100644
--- a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
+++ b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
@@ -145,7 +145,8 @@ public class ConfigDefaults {
public static final String VIRT_DISK = "kickstart.virt_disk_size_gb";
public static final String KICKSTART_NETWORK_INTERFACE = "kickstart.default_interface";
- public static final String SPACEWALK_REPO_SYNC_PATH = "spacewalk_repo_sync_path";
+ public static final String SPACEWALK_REPOSYNC_PATH = "spacewalk_reposync_path";
+ public static final String SPACEWALK_REPOSYNC_LOG_FILE = "spacewalk_reposync_logfile";
private ConfigDefaults() {
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
index 6f913d1..ba3ae7d 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
@@ -335,7 +335,9 @@ public class EditChannelAction extends RhnAction implements Listable {
ucc.setAccess((String)form.get("org_sharing"));
ucc.setYumUrl((String) form.getString("yum_repo"));
ucc.setRepoLabel((String) form.getString("repo_label"));
- ucc.setSyncRepo((Boolean)form.get("sync_repo"));
+ if (form.get("sync_repo") != null) {
+ ucc.setSyncRepo((Boolean)form.get("sync_repo"));
+ }
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
@@ -408,7 +410,9 @@ public class EditChannelAction extends RhnAction implements Listable {
ccc.setAccess((String)form.get("org_sharing"));
ccc.setYumUrl((String) form.getString("yum_repo"));
ccc.setRepoLabel((String) form.getString("repo_label"));
- ccc.setSyncRepo((Boolean)form.get("sync_repo"));
+ if (form.get("sync_repo") != null) {
+ ccc.setSyncRepo((Boolean)form.get("sync_repo"));
+ }
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
index 98c3272..40a4c2c 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
@@ -95,18 +95,19 @@ public class RepoSyncTask implements Job {
private static List<String> getSyncCommand(ContentSource src) {
List<String> cmd = new ArrayList<String>();
- cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPO_SYNC_PATH,
+ cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_PATH,
"/usr/bin/spacewalk-repo-sync"));
- cmd.add("-c");
+ cmd.add("--channel");
cmd.add(src.getChannel().getLabel());
- cmd.add("-u");
+ cmd.add("--url");
cmd.add(src.getSourceUrl());
- cmd.add("-t");
+ cmd.add("--type");
cmd.add(src.getType().getLabel());
- cmd.add("-l");
+ cmd.add("--label");
cmd.add(src.getLabel());
- cmd.add("-g");
- cmd.add("/var/log/rhn/rhn_reposync.log");
+ cmd.add("--logfile");
+ cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_LOG_FILE,
+ "/var/log/rhn/rhn_reposync.log"));
return cmd;
}
commit 0c0b1227c5e534232f49d435ff7e8f7f0b0c1938
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jul 30 17:39:06 2009 -0400
updating task to include log file and more logging
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
index fdbe9e4..98c3272 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
@@ -27,6 +27,7 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -63,23 +64,28 @@ public class RepoSyncTask implements Job {
throws JobExecutionException {
for (Task task : TaskFactory.listTasks(DISPLAY_NAME)) {
-
ContentSource src = ChannelFactory.lookupContentSource(task.getData());
+ if (log.isInfoEnabled()) {
+ log.info("Syncing repo " + src.getSourceUrl() + " to channel "
+ + src.getChannel().getLabel());
+ }
if (src == null) {
log.error("Content Source could not be found: " + task.getData());
continue;
}
try {
-
Process p = Runtime.getRuntime().exec(
- (String[]) getSyncCommand(src).toArray());
+ getSyncCommand(src).toArray(new String[0]));
p.waitFor();
+
}
catch (IOException e) {
+ log.fatal(e.getMessage());
e.printStackTrace();
}
catch (InterruptedException e) {
+ log.fatal(e.getMessage());
e.printStackTrace();
}
src.setLastSynced(new Date());
@@ -90,7 +96,7 @@ public class RepoSyncTask implements Job {
private static List<String> getSyncCommand(ContentSource src) {
List<String> cmd = new ArrayList<String>();
cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPO_SYNC_PATH,
- "/usr/sbin/spacewalk-repo-sync"));
+ "/usr/bin/spacewalk-repo-sync"));
cmd.add("-c");
cmd.add(src.getChannel().getLabel());
cmd.add("-u");
@@ -99,6 +105,8 @@ public class RepoSyncTask implements Job {
cmd.add(src.getType().getLabel());
cmd.add("-l");
cmd.add(src.getLabel());
+ cmd.add("-g");
+ cmd.add("/var/log/rhn/rhn_reposync.log");
return cmd;
}
commit 57112cb536f9142d35aa1030b41cb27b34863627
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jul 30 17:38:38 2009 -0400
making the logging a bit cleaner
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 053a8c4..9418a78 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -203,13 +203,13 @@ class RepoSync:
def print_msg(self, message):
if self.log_file:
- rhnLog.log_debug(0, message)
+ rhnLog.log_clean(0, message)
print message
def error_msg(self, message):
if self.log_file:
- rhnLog.log_debug(0, message)
+ rhnLog.log_clean(0, message)
sys.stderr.write(message)
class ContentPackage:
commit 2280dc149ddc31deca55e97c8bd1b7393e0ccf20
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jul 30 16:09:15 2009 -0400
fixing some import things to actually work on an installed system
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py
index 77c6f57..a9c0ad6 100644
--- a/backend/satellite_tools/repo_plugins/yum_src.py
+++ b/backend/satellite_tools/repo_plugins/yum_src.py
@@ -16,7 +16,7 @@
import yum
import shutil
from yum import config
-from reposync import ContentPackage
+from satellite_tools.reposync import ContentPackage
class ContentSource:
url = None
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index e5074b0..053a8c4 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -39,6 +39,7 @@ class RepoSync:
rhnSQL.initDB(db_string)
(options, args) = self.process_args()
+
quit = False
if not options.url:
quit = True
@@ -53,6 +54,12 @@ class RepoSync:
quit = True
print("--label must be specified")
+ self.log_file = options.logfile
+ if self.log_file:
+ rhnLog.initLOG(self.log_file)
+
+ self.error_msg(str(sys.argv))
+
if quit:
sys.exit(1)
@@ -71,8 +78,6 @@ class RepoSync:
sys.exit(1)
- if self.log_file:
- rhnLog.initLOG(self.log_file)
self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label)
self.import_packages(self.plugin.list_packages())
@@ -88,10 +93,10 @@ class RepoSync:
return self.parser.parse_args()
def load_plugin(self):
- sys.path.append("repo_plugins")
name = self.type + "_src"
- mod = __import__(name)
- return getattr(mod, "ContentSource")
+ mod = __import__('satellite_tools.repo_plugins', globals(), locals(), [name])
+ submod = getattr(mod, name)
+ return getattr(submod, "ContentSource")
def import_packages(self, packages):
to_link = []
commit f842a5b42266b3ad09929a9b5d524cbd65470bb7
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jul 30 13:23:47 2009 -0400
adding sync repo option to channel details, and taskomatic task
diff --git a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
index d1e5065..4160ba1 100644
--- a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
+++ b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
@@ -145,6 +145,8 @@ public class ConfigDefaults {
public static final String VIRT_DISK = "kickstart.virt_disk_size_gb";
public static final String KICKSTART_NETWORK_INTERFACE = "kickstart.default_interface";
+ public static final String SPACEWALK_REPO_SYNC_PATH = "spacewalk_repo_sync_path";
+
private ConfigDefaults() {
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
index baa0737..6f913d1 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
@@ -335,6 +335,7 @@ public class EditChannelAction extends RhnAction implements Listable {
ucc.setAccess((String)form.get("org_sharing"));
ucc.setYumUrl((String) form.getString("yum_repo"));
ucc.setRepoLabel((String) form.getString("repo_label"));
+ ucc.setSyncRepo((Boolean)form.get("sync_repo"));
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
@@ -407,6 +408,7 @@ public class EditChannelAction extends RhnAction implements Listable {
ccc.setAccess((String)form.get("org_sharing"));
ccc.setYumUrl((String) form.getString("yum_repo"));
ccc.setRepoLabel((String) form.getString("repo_label"));
+ ccc.setSyncRepo((Boolean)form.get("sync_repo"));
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
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 0ea6469..275dd45 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@ -18,12 +18,14 @@ import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelArch;
import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.role.RoleFactory;
+import com.redhat.rhn.domain.task.TaskFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException;
import com.redhat.rhn.frontend.xmlrpc.InvalidGPGKeyException;
import com.redhat.rhn.frontend.xmlrpc.InvalidGPGUrlException;
import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException;
+import com.redhat.rhn.taskomatic.task.RepoSyncTask;
import org.apache.commons.lang.StringUtils;
@@ -69,6 +71,7 @@ public class CreateChannelCommand {
protected String access = Channel.PRIVATE;
protected String yumUrl;
protected String repoLabel;
+ protected boolean syncRepo = false;
@@ -261,6 +264,7 @@ public class CreateChannelCommand {
c.setMaintainerEmail(maintainerEmail);
c.setMaintainerPhone(maintainerPhone);
c.setSupportPolicy(supportPolicy);
+ c.setYumContentSource(yumUrl, repoLabel);
// handles either parent id or label
setParentChannel(c, user, parentLabel, parentId);
@@ -271,9 +275,11 @@ public class CreateChannelCommand {
ChannelFactory.save(c);
ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED);
-
- c.setYumContentSource(yumUrl, repoLabel);
+ if (syncRepo && !c.getContentSources().isEmpty()) {
+ TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME,
+ c.getContentSources().iterator().next().getId());
+ }
return c;
}
@@ -449,5 +455,13 @@ public class CreateChannelCommand {
public void setRepoLabel(String repoLabelIn) {
this.repoLabel = repoLabelIn;
}
+
+
+ /**
+ * @param syncRepoIn The syncRepo to set.
+ */
+ public void setSyncRepo(boolean syncRepoIn) {
+ this.syncRepo = syncRepoIn;
+ }
}
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 79764aa..80b8e80 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
@@ -17,9 +17,11 @@ package com.redhat.rhn.manager.channel;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.task.TaskFactory;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException;
import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException;
+import com.redhat.rhn.taskomatic.task.RepoSyncTask;
/**
* UpdateChannelCommand - command to create a new channel.
@@ -77,10 +79,12 @@ public class UpdateChannelCommand extends CreateChannelCommand {
c.setMaintainerEmail(maintainerEmail);
c.setMaintainerPhone(maintainerPhone);
c.setSupportPolicy(supportPolicy);
-
-
c.setYumContentSource(yumUrl, repoLabel);
+ if (syncRepo && !c.getContentSources().isEmpty()) {
+ TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME,
+ c.getContentSources().iterator().next().getId());
+ }
// need to save before calling stored proc below
ChannelFactory.save(c);
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
index ae382a5..fdbe9e4 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
@@ -14,6 +14,8 @@
*/
package com.redhat.rhn.taskomatic.task;
+import com.redhat.rhn.common.conf.Config;
+import com.redhat.rhn.common.conf.ConfigDefaults;
import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.channel.ContentSource;
import com.redhat.rhn.domain.task.Task;
@@ -29,6 +31,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+
/**
* Repo Sync
* Used for syncing repos (like yum repos) to a channel
@@ -59,7 +62,7 @@ public class RepoSyncTask implements Job {
public void execute(JobExecutionContext context)
throws JobExecutionException {
- for (Task task : TaskFactory.listTasks("repo_sync")) {
+ for (Task task : TaskFactory.listTasks(DISPLAY_NAME)) {
ContentSource src = ChannelFactory.lookupContentSource(task.getData());
if (src == null) {
@@ -68,10 +71,16 @@ public class RepoSyncTask implements Job {
}
try {
- Process p = Runtime.getRuntime().exec("");
+
+ Process p = Runtime.getRuntime().exec(
+ (String[]) getSyncCommand(src).toArray());
+ p.waitFor();
}
catch (IOException e) {
-
+ e.printStackTrace();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
}
src.setLastSynced(new Date());
TaskFactory.removeTask(task);
@@ -80,13 +89,16 @@ public class RepoSyncTask implements Job {
private static List<String> getSyncCommand(ContentSource src) {
List<String> cmd = new ArrayList<String>();
- cmd.add("/usr/sbin/spacewalk-repo-sync");
+ cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPO_SYNC_PATH,
+ "/usr/sbin/spacewalk-repo-sync"));
cmd.add("-c");
cmd.add(src.getChannel().getLabel());
cmd.add("-u");
cmd.add(src.getSourceUrl());
cmd.add("-t");
cmd.add(src.getType().getLabel());
+ cmd.add("-l");
+ cmd.add(src.getLabel());
return cmd;
}
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
index adda2fb..ee51f22 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
@@ -120,6 +120,14 @@
<html:text property="yum_repo" maxlength="512" size="64" />
</td>
</tr>
+ <tr>
+ <th>
+ <bean:message key="channel.edit.jsp.repolabel"/>:
+ </th>
+ <td>
+ <html:text property="repo_label" maxlength="64" size="20" />
+ </td>
+ </tr>
<c:if test='${not empty param.cid}'>
<tr>
<th>
@@ -132,14 +140,6 @@
</c:if>
<tr>
<th>
- <bean:message key="channel.edit.jsp.repolabel"/>:
- </th>
- <td>
- <html:text property="repo_label" maxlength="64" size="20" />
- </td>
- </tr>
- <tr>
- <th>
<bean:message key="channel.edit.jsp.sync"/>:
</th>
<td>
commit a75f22ad634db6631b56582018a81d723a61c257
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jul 30 13:21:41 2009 -0400
adding logging, cache clearing, and a few fixes to reposync
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py
index fb3859f..77c6f57 100644
--- a/backend/satellite_tools/repo_plugins/yum_src.py
+++ b/backend/satellite_tools/repo_plugins/yum_src.py
@@ -14,6 +14,7 @@
# in this software or its documentation.
#
import yum
+import shutil
from yum import config
from reposync import ContentPackage
@@ -21,10 +22,11 @@ class ContentSource:
url = None
name = None
repo = None
-
+ cache_dir = '/var/cache/rhn/reposync/'
def __init__(self, url, name):
self.url = url
self.name = name
+ self._clean_cache(self.cache_dir + name)
def list_packages(self):
""" list packages"""
@@ -33,8 +35,8 @@ class ContentSource:
repo.cache = 0
repo.metadata_expire = 0
repo.baseurl = [self.url]
- repo.basecachedir = '/var/cache/rhn/reposync/'
-# repo.cachedir = '/var/cache/rhn/reposync/'
+ repo.basecachedir = self.cache_dir
+ repo.baseurlSetup()
repo.setup(False)
sack = repo.getPackageSack()
sack.populate(repo, 'metadata', None, 0)
@@ -52,4 +54,11 @@ class ContentSource:
def get_package(self, package):
""" get package """
- return self.repo.getPackage(package.unique_id)
+ check = (self.verify_pkg, (package.unique_id ,1), {})
+ return self.repo.getPackage(package.unique_id, checkfunc=check)
+
+ def verify_pkg(self, fo, pkg, fail):
+ return pkg.verifyLocalPkg()
+
+ def _clean_cache(self, directory):
+ shutil.rmtree(directory, True)
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 0fd24d2..e5074b0 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -17,7 +17,8 @@ import sys, os
from optparse import OptionParser
from common import rhnLib
from server import rhnPackage, rhnSQL, rhnChannel, rhnPackageUpload
-from common import CFG, initCFG, rhn_rpm
+from common import CFG, initCFG, rhn_rpm, rhnLog, fetchTraceback
+from common.rhn_mpm import InvalidPackageError
from server.importlib.importLib import IncompletePackage
from server.importlib.backendOracle import OracleBackend
from server.importlib.packageImport import ChannelPackageSubscription
@@ -38,15 +39,22 @@ class RepoSync:
rhnSQL.initDB(db_string)
(options, args) = self.process_args()
-
+ quit = False
if not options.url:
+ quit = True
print("--url must be specified")
if not options.type:
+ quit = True
print("--type must be specified")
if not options.channel_label:
+ quit = True
print("--channel must be specified")
if not options.label:
- print("--label must be specified")
+ quit = True
+ print("--label must be specified")
+
+ if quit:
+ sys.exit(1)
self.type = options.type
@@ -55,12 +63,17 @@ class RepoSync:
self.fail = options.fail
self.repo_label = options.label
self.channel = self.load_channel()
-
+ self.log_file = options.logfile
+
if not self.channel or not \
rhnChannel.isCustomChannel(self.channel['id']):
print "Channel does not exist or is not custom"
sys.exit(1)
+
+ if self.log_file:
+ rhnLog.initLOG(self.log_file)
+
self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label)
self.import_packages(self.plugin.list_packages())
@@ -71,6 +84,7 @@ class RepoSync:
self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported')
self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo')
self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation")
+ self.parser.add_option('-g', '--logfile', action='store', dest='logfile', help="The log file to log to. Default is to stderr and stdout.")
return self.parser.parse_args()
def load_plugin(self):
@@ -82,6 +96,7 @@ class RepoSync:
def import_packages(self, packages):
to_link = []
to_download = []
+ self.print_msg("Repo " + self.url + " has " + str(len(packages)) + ".")
for pack in packages:
pid = None
if pack.checksums.has_key('md5sum'):
@@ -101,7 +116,7 @@ class RepoSync:
for (index, pack) in enumerate(to_download):
"""download each package"""
try:
- print(str(index) + "/" + str(len(to_download)) + " : "+ \
+ self.print_msg(str(index+1) + "/" + str(len(to_download)) + " : "+ \
pack.getNVREA())
path = self.plugin.get_package(pack)
md5 = rhnLib.getFileMD5(filename=path)
@@ -112,9 +127,13 @@ class RepoSync:
self.associate_package(pack, md5)
else:
to_link.append(pack)
+ if self.url.find("file://") < 0:
+ os.remove(path)
+
except KeyboardInterrupt:
raise
except:
+ self.error_msg("ERROR" + fetchTraceback())
if self.fail:
raise
continue
@@ -124,6 +143,7 @@ class RepoSync:
except KeyboardInterrupt:
raise
except:
+ self.error_msg(fetchTraceback())
if self.fail:
raise
continue
@@ -142,9 +162,6 @@ class RepoSync:
relative_path=rel_package_path,
org_id=self.channel['org_id'])
temp_file.close()
- if self.url.find("file://") < 0:
- os.remove(path)
-
def associate_package(self, pack, md5sum):
caller = "server.app.yumreposync"
@@ -154,32 +171,42 @@ class RepoSync:
package['name'] = pack.name
package['version'] = pack.version
package['release'] = pack.release
- if pack.epoch == 0:
- package['epoch'] = ""
- else:
- package['epoch'] = pack.epoch
+ package['epoch'] = pack.epoch
package['arch'] = pack.arch
package['md5sum'] = md5sum
package['channels'] = [{'label':self.channel_label,
'id':self.channel['id']}]
package['org_id'] = self.channel['org_id']
-
try:
- importer = ChannelPackageSubscription(
- [IncompletePackage().populate(package)],
- backend, caller=caller)
- importer.run()
+ self._importer_run(package, caller, backend)
except:
- package['epoch'] = '0'
+ package['epoch'] = ''
+ self._importer_run(package, caller, backend)
+
+ backend.commit()
+
+ def _importer_run(self, package, caller, backend):
importer = ChannelPackageSubscription(
- [IncompletePackage().populate(package)],
+ [IncompletePackage().populate(package)],
backend, caller=caller)
importer.run()
- backend.commit()
+
def load_channel(self):
return rhnChannel.channel_info(self.channel_label)
+
+ def print_msg(self, message):
+ if self.log_file:
+ rhnLog.log_debug(0, message)
+ print message
+
+
+ def error_msg(self, message):
+ if self.log_file:
+ rhnLog.log_debug(0, message)
+ sys.stderr.write(message)
+
class ContentPackage:
#map of checksums. Valid keys are 'md5sum' & 'sha256'
@@ -199,9 +226,11 @@ class ContentPackage:
self.version = version
self.release = release
self.arch = arch
+ self.epoch = epoch
def getNVREA(self):
if self.epoch:
return self.name + '-' + self.version + '-' + self.release + '-' + self.epoch + '.' + self.arch
else:
return self.name + '-' + self.version + '-' + self.release + '.' + self.arch
+
commit 27676a0db884611b0326b797b6fd6b97e7f33300
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Wed Jul 29 16:50:13 2009 -0400
adding makefile to repo_plugins
diff --git a/backend/satellite_tools/repo_plugins/Makefile b/backend/satellite_tools/repo_plugins/Makefile
new file mode 100644
index 0000000..556fb17
--- /dev/null
+++ b/backend/satellite_tools/repo_plugins/Makefile
@@ -0,0 +1,27 @@
+# Makefile for repo sync plugins
+#
+# $Id: Makefile $
+#
+# 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.
+#
+#
+
+TOP = ../..
+
+# Specific stuff
+SUBDIR = satellite_tools/repo_plugins
+FILES = __init__ yum_src
+
+include $(TOP)/Makefile.defs
+
diff --git a/backend/satellite_tools/spacewalk-debug.8 b/backend/satellite_tools/spacewalk-debug.8
index 0db3791..2a63608 100644
--- a/backend/satellite_tools/spacewalk-debug.8
+++ b/backend/satellite_tools/spacewalk-debug.8
@@ -1,19 +1,14 @@
-.\" This manpage has been automatically generated by docbook2man
-.\" from a DocBook document. This tool can be found at:
-.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
-.\" Please send any bug reports, improvements, comments, patches,
-.\" etc. to Steve Cheng <steve(a)ggi-project.org>.
-.TH "SPACEWALK-DEBUG" "8" "11 June 2008" "Version 3.6" ""
-
+.\\" auto-generated by docbook2man-spec $Revision: 1.1 $
+.TH "SPACEWALK-DEBUG" "8" "29 July 2009" "Version 3.6" ""
.SH NAME
-spacewalk-debug \- Debug utility that packages log files and relevant debug information needed for full diagnosis of Spacewalk issues.
+spacewalk-debug \- Debug utility that packages log files and relevant debug information needed for full diagnosis of Spacewalk Server issues.
.SH SYNOPSIS
-
+.sp
.nf
-
-
+
+.sp
\fBspacewalk-debug\fR
-
+.sp
.fi
.SH "DESCRIPTION"
.PP
@@ -45,4 +40,5 @@ satellite-sync(8)
.SH "AUTHORS"
Todd Warner <taw(a)redhat.com>
+
Pradeep Kilambi <pkilambi(a)redhat.com>
commit 018fcfd031374ef91fbc54d27031e695511a09e4
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Jul 27 12:51:29 2009 -0400
updating spacewalk backend spec file with reposync stuff
diff --git a/backend/server/Makefile b/backend/server/Makefile
index fbbad78..776fb63 100644
--- a/backend/server/Makefile
+++ b/backend/server/Makefile
@@ -18,8 +18,8 @@ FILES = __init__ \
rhnHandler rhnImport rhnMapping rhnLib rhnPackage \
rhnItem \
rhnKickstart \
- rhnPackageUpload rhnRepository rhnSession rhnUser \
- rhnVirtualization taskomatic
+ rhnPackageUpload basePackageUpload rhnRepository \
+ rhnSession rhnUser rhnVirtualization taskomatic
SUBDIRS = rhnSQL rhnServer action \
handlers importlib action_extra_data \
config_common repomd
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 4037804..1fe9866 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -325,6 +325,7 @@ rm -f %{rhnconf}/rhnSecret.py*
%{rhnroot}/server/rhnItem.py*
%{rhnroot}/server/rhnPackage.py*
%{rhnroot}/server/rhnPackageUpload.py*
+%{rhnroot}/server/basePackageUpload.py*
%{rhnroot}/server/rhnHandler.py*
%{rhnroot}/server/rhnImport.py*
%{rhnroot}/server/rhnLib.py*
@@ -507,6 +508,7 @@ rm -f %{rhnconf}/rhnSecret.py*
%attr(755,root,root) %{_bindir}/spacewalk-debug
%attr(755,root,root) %{_bindir}/rhn-satellite-exporter
%attr(755,root,root) %{_bindir}/update-packages
+%attr(755,root,root) %{_bindir}/spacewalk-repo-sync
%attr(755,root,root) %{_bindir}/rhn-db-stats
%attr(750,root,root) %{_bindir}/satpasswd
%attr(750,root,root) %{_bindir}/satwho
@@ -525,6 +527,7 @@ rm -f %{rhnconf}/rhnSecret.py*
%{rhnroot}/satellite_tools/rhn_ssl_dbstore.py*
%{rhnroot}/satellite_tools/xmlWireSource.py*
%{rhnroot}/satellite_tools/updatePackages.py*
+%{rhnroot}/satellite_tools/reposync.py*
%dir %{rhnroot}/satellite_tools/disk_dumper
%{rhnroot}/satellite_tools/disk_dumper/__init__.py*
%{rhnroot}/satellite_tools/disk_dumper/iss.py*
@@ -534,6 +537,9 @@ rm -f %{rhnconf}/rhnSecret.py*
%{rhnroot}/satellite_tools/disk_dumper/iss_actions.py*
%{rhnroot}/satellite_tools/disk_dumper/dumper.py*
%{rhnroot}/satellite_tools/disk_dumper/string_buffer.py*
+%dir %{rhnroot}/satellite_tools/repo_plugins
+%{rhnroot}/satellite_tools/repo_plugins/__init__.py*
+%{rhnroot}/satellite_tools/repo_plugins/yum_src.py*
%config %attr(644,root,apache) %{rhnconf}/default/rhn_server_iss.conf
%{_mandir}/man8/rhn-satellite-exporter.8*
%{_mandir}/man8/rhn-charsets.8*
commit 629d5ca6cf235df83d60ca0fbaf17055624308b9
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Jul 27 12:44:23 2009 -0400
updating Makefile with reposync files
diff --git a/backend/satellite_tools/Makefile b/backend/satellite_tools/Makefile
index 9c02dce..d05d130 100644
--- a/backend/satellite_tools/Makefile
+++ b/backend/satellite_tools/Makefile
@@ -6,17 +6,17 @@ TOP = ..
# Specific stuff
SUBDIR = satellite_tools
-SUBDIRS = exporter disk_dumper accounts
+SUBDIRS = exporter disk_dumper accounts repo_plugins
FILES = __init__ connection diskImportLib messages \
progress_bar req_channels satCerts satrm satsync syncCache \
sync_handlers rhn-entitlement-report\
syncLib SequenceServer xmlDiskDumper xmlDiskSource \
xmlSource xmlWireSource rhn_satellite_activate rhn_ssl_dbstore \
- satComputePkgHeaders updatePackages
+ satComputePkgHeaders updatePackages reposync
SCRIPTS = satellite-sync spacewalk-debug\
rhn-schema-version rhn-satellite-activate rhn-charsets \
- rhn-ssl-dbstore update-packages rhn-db-stats
+ rhn-ssl-dbstore update-packages rhn-db-stats spacewalk-repo-sync
# check if we can build man pages
DOCBOOK = $(wildcard /usr/bin/docbook2man)
diff --git a/backend/satellite_tools/repo_plugins/__init__.py b/backend/satellite_tools/repo_plugins/__init__.py
new file mode 100644
index 0000000..fb3600e
--- /dev/null
+++ b/backend/satellite_tools/repo_plugins/__init__.py
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2008 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 353e94dfc2ce49c6cd0ba61e4bb67ec901767884
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Jul 27 12:39:16 2009 -0400
some clean up on repo sync stuff
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py
index fd39518..fb3859f 100644
--- a/backend/satellite_tools/repo_plugins/yum_src.py
+++ b/backend/satellite_tools/repo_plugins/yum_src.py
@@ -16,8 +16,8 @@
import yum
from yum import config
from reposync import ContentPackage
-class ContentSource:
+class ContentSource:
url = None
name = None
repo = None
@@ -31,7 +31,7 @@ class ContentSource:
repo = yum.yumRepo.YumRepository(self.name)
self.repo = repo
repo.cache = 0
- repo.metadata_expire = 5
+ repo.metadata_expire = 0
repo.baseurl = [self.url]
repo.basecachedir = '/var/cache/rhn/reposync/'
# repo.cachedir = '/var/cache/rhn/reposync/'
@@ -42,7 +42,8 @@ class ContentSource:
to_return = []
for pack in list:
new_pack = ContentPackage()
- new_pack.setNVREA(pack.name, pack.version, pack.release, pack.epoch, pack.arch)
+ new_pack.setNVREA(pack.name, pack.version, pack.release,
+ pack.epoch, pack.arch)
new_pack.unique_id = pack
for cs in pack.checksums:
new_pack.checksums[cs[0]] = cs[1]
@@ -52,5 +53,3 @@ class ContentSource:
def get_package(self, package):
""" get package """
return self.repo.getPackage(package.unique_id)
-
-
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 5abcc1c..0fd24d2 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -23,8 +23,6 @@ from server.importlib.backendOracle import OracleBackend
from server.importlib.packageImport import ChannelPackageSubscription
class RepoSync:
-
-
parser = None
type = None
url = None
@@ -34,7 +32,6 @@ class RepoSync:
fail = False
repo_label = None
-
def main(self):
initCFG('server')
db_string = CFG.DEFAULT_DB #"rhnsat/rhnsat@rhnsat"
@@ -59,15 +56,14 @@ class RepoSync:
self.repo_label = options.label
self.channel = self.load_channel()
- if not self.channel or not rhnChannel.isCustomChannel(self.channel['id']):
+ if not self.channel or not \
+ rhnChannel.isCustomChannel(self.channel['id']):
print "Channel does not exist or is not custom"
sys.exit(1)
self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label)
self.import_packages(self.plugin.list_packages())
-
-
def process_args(self):
self.parser = OptionParser()
self.parser.add_option('-u', '--url', action='store', dest='url', help='The url to sync')
@@ -76,7 +72,6 @@ class RepoSync:
self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo')
self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation")
return self.parser.parse_args()
-
def load_plugin(self):
sys.path.append("repo_plugins")
@@ -94,18 +89,24 @@ class RepoSync:
elif pack.checksums.has_key('sha256'):
"""lookup by sha256"""
if pid == None:
- if self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, pack.epoch, pack.arch]) and \
- self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, '', pack.arch]):
+ if self.channel_label not in \
+ rhnPackage.get_channels_for_package([pack.name, \
+ pack.version, pack.release, pack.epoch, pack.arch]) and \
+ self.channel_label not in \
+ rhnPackage.get_channels_for_package([pack.name, \
+ pack.version, pack.release, '', pack.arch]):
to_download.append(pack)
for (index, pack) in enumerate(to_download):
"""download each package"""
try:
- print(str(index) + "/" + str(len(to_download)) + " : "+ pack.getNVREA())
+ print(str(index) + "/" + str(len(to_download)) + " : "+ \
+ pack.getNVREA())
path = self.plugin.get_package(pack)
md5 = rhnLib.getFileMD5(filename=path)
- pid = rhnPackage.get_package_for_md5sum(self.channel['org_id'], md5)
+ pid = rhnPackage.get_package_for_md5sum(
+ self.channel['org_id'], md5)
if pid is None:
self.upload_package(pack, path, md5)
self.associate_package(pack, md5)
@@ -138,7 +139,8 @@ class RepoSync:
package_dict, diff_level = rhnPackageUpload.push_package(header,
payload_stream, md5sum, force=False,
header_start=header_start, header_end=header_end,
- relative_path=rel_package_path, org_id=self.channel['org_id'])
+ relative_path=rel_package_path,
+ org_id=self.channel['org_id'])
temp_file.close()
if self.url.find("file://") < 0:
os.remove(path)
@@ -158,21 +160,26 @@ class RepoSync:
package['epoch'] = pack.epoch
package['arch'] = pack.arch
package['md5sum'] = md5sum
- package['channels'] = [{'label':self.channel_label, 'id':self.channel['id']}]
+ package['channels'] = [{'label':self.channel_label,
+ 'id':self.channel['id']}]
package['org_id'] = self.channel['org_id']
try:
- importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller)
+ importer = ChannelPackageSubscription(
+ [IncompletePackage().populate(package)],
+ backend, caller=caller)
importer.run()
except:
package['epoch'] = '0'
- importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller)
+ importer = ChannelPackageSubscription(
+ [IncompletePackage().populate(package)],
+ backend, caller=caller)
importer.run()
backend.commit()
+
def load_channel(self):
return rhnChannel.channel_info(self.channel_label)
-
class ContentPackage:
#map of checksums. Valid keys are 'md5sum' & 'sha256'
@@ -198,4 +205,3 @@ class ContentPackage:
return self.name + '-' + self.version + '-' + self.release + '-' + self.epoch + '.' + self.arch
else:
return self.name + '-' + self.version + '-' + self.release + '.' + self.arch
-
diff --git a/backend/satellite_tools/spacewalk-repo-sync b/backend/satellite_tools/spacewalk-repo-sync
index 244c260..a14ad76 100755
--- a/backend/satellite_tools/spacewalk-repo-sync
+++ b/backend/satellite_tools/spacewalk-repo-sync
@@ -22,7 +22,6 @@ if __name__ != '__main__':
import sys
def systemExit(code, msgs=None):
"Exit with a code and optional message(s). Saved a few lines of code."
-
if msgs:
if type(msgs) not in [type([]), type(())]:
msgs = (msgs, )
@@ -30,7 +29,6 @@ def systemExit(code, msgs=None):
sys.stderr.write(str(msg)+'\n')
sys.exit(code)
-
try:
import os
import socket
@@ -45,16 +43,12 @@ except ImportError:
sys.stderr.write("Unable to find RHN code tree.\n"
"Path not correct? '%s'\n" % _LIBPATH)
-
-
-
def releaseLOCK():
global LOCK
if LOCK:
LOCK.release()
LOCK = None
-
def main():
# quick check to see if you are a super-user.
@@ -62,19 +56,16 @@ def main():
sys.stderr.write('ERROR: must be root to execute\n')
sys.exit(8)
-
LOCK = None
try:
- LOCK = rhnLockfile.Lockfile('/var/run/spacewalk-sync.pid')
+ LOCK = rhnLockfile.Lockfile('/var/run/spacewalk-repo-sync.pid')
except rhnLockfile.LockfileLockedException:
- systemExit(1, "SYNC ERROR: attempting to run more than one instance of satellite-sync. Exiting.")
-
+ systemExit(1, "ERROR: attempting to run more than one instance of spacewalk-repo-sync Exiting.")
sync = reposync.RepoSync()
sync.main()
releaseLOCK()
return 0
-
if __name__ == '__main__':
try:
sys.exit(abs(main() or 0))
@@ -86,4 +77,3 @@ if __name__ == '__main__':
except Exception, e:
releaseLOCK()
raise
-
commit 6ed3ca255562fef25eb51bcb2523a2929af504a7
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jul 22 18:24:16 2009 -0400
adding repo sync task and other UI bits for spacewalk repo sync
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py
new file mode 100644
index 0000000..fd39518
--- /dev/null
+++ b/backend/satellite_tools/repo_plugins/yum_src.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python -u
+#
+# Copyright (c) 2008 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 yum
+from yum import config
+from reposync import ContentPackage
+class ContentSource:
+
+ url = None
+ name = None
+ repo = None
+
+ def __init__(self, url, name):
+ self.url = url
+ self.name = name
+
+ def list_packages(self):
+ """ list packages"""
+ repo = yum.yumRepo.YumRepository(self.name)
+ self.repo = repo
+ repo.cache = 0
+ repo.metadata_expire = 5
+ repo.baseurl = [self.url]
+ repo.basecachedir = '/var/cache/rhn/reposync/'
+# repo.cachedir = '/var/cache/rhn/reposync/'
+ repo.setup(False)
+ sack = repo.getPackageSack()
+ sack.populate(repo, 'metadata', None, 0)
+ list = sack.returnPackages()
+ to_return = []
+ for pack in list:
+ new_pack = ContentPackage()
+ new_pack.setNVREA(pack.name, pack.version, pack.release, pack.epoch, pack.arch)
+ new_pack.unique_id = pack
+ for cs in pack.checksums:
+ new_pack.checksums[cs[0]] = cs[1]
+ to_return.append(new_pack)
+ return to_return
+
+ def get_package(self, package):
+ """ get package """
+ return self.repo.getPackage(package.unique_id)
+
+
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
index 303fa7d..e61da3f 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
@@ -819,7 +819,7 @@ public class Channel extends BaseDomainHelper implements Comparable {
* if null or '' is passed in, all content sources will be removed.
* @param url the url of the yum repo
*/
- public void setYumContentSource(String url) {
+ public void setYumContentSource(String url, String labelIn) {
if (StringUtils.isEmpty(url)) {
if (!this.getContentSources().isEmpty()) {
this.getContentSources().clear();
@@ -830,11 +830,14 @@ public class Channel extends BaseDomainHelper implements Comparable {
ContentSource cs = new ContentSource();
cs.setChannel(this);
cs.setSourceUrl(url);
+ cs.setLabel(labelIn);
cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM);
this.getContentSources().add(cs);
}
else {
- this.getContentSources().iterator().next().setSourceUrl(url);
+ ContentSource cs = this.getContentSources().iterator().next();
+ cs.setSourceUrl(url);
+ cs.setLabel(labelIn);
}
}
ChannelFactory.save(this);
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 7f3aa2a..71a73b1 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
@@ -120,6 +120,19 @@ public class ChannelFactory extends HibernateFactory {
}
/**
+ * Lookup a content source by id
+ * @param id the id to lookup
+ * @return the ContentSource
+ */
+ public static ContentSource lookupContentSource(Long id) {
+ Map params = new HashMap();
+ params.put("id", id);
+ return (ContentSource) singleton.lookupObjectByNamedQuery(
+ "ContentSource.findById", params);
+ }
+
+
+ /**
* Retrieve a list of channel ids associated with the labels provided
* @param labelsIn the labels to search for
* @return list of channel ids
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
index 2756941..fd8edd2 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
@@ -17,6 +17,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="lastSynced" type="timestamp" column="last_synced"/>
<property name="created" type="timestamp" column="created" insert="false" update="false" />
<property name="modified" type="timestamp" column="modified" insert="false" update="false" />
+ <property name="label" type="string" column="label"/>
<many-to-one
@@ -31,4 +32,10 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
</class>
+
+
+ <query name="ContentSource.findById">
+ <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id = :id]]>
+ </query>
+
</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
index 70a54e8..74599a1 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
@@ -29,8 +29,25 @@ public class ContentSource extends BaseDomainHelper {
private ContentSourceType type;
private String sourceUrl;
private Date lastSynced;
+ private String label;
+
+ /**
+ * @return Returns the label.
+ */
+ public String getLabel() {
+ return label;
+ }
+
+
+ /**
+ * @param labelIn The label to set.
+ */
+ public void setLabel(String labelIn) {
+ this.label = labelIn;
+ }
+
/**
* @return Returns the id.
*/
diff --git a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml
index 276b5e8..70b8f1a 100644
--- a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml
@@ -32,6 +32,14 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
where org_id = :org_id and task_name = :name
and task_data = :data and earliest = :earliest]]>
</query>
+
+ <query name="Task.listTasksByName">
+ <![CDATA[from com.redhat.rhn.domain.task.Task as t
+ where t.name = :name]]>
+ </query>
+
+
+
<sql-query name="Task.lookupByNameLike">
<![CDATA[SELECT {t.*}
diff --git a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java
index 50149eb..aa75626 100644
--- a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java
@@ -19,10 +19,12 @@ import com.redhat.rhn.domain.org.Org;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.CriteriaSpecification;
import org.hibernate.criterion.Order;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -66,6 +68,33 @@ public class TaskFactory extends HibernateFactory {
}
/**
+ *
+ * @param name
+ * @return
+ */
+ public static List<Task> listTasks(String name) {
+ Session session = null;
+ try {
+ session = HibernateFactory.getSession();
+ return session.getNamedQuery("Task.listTasksByName")
+ .setString("name", name).list();
+ }
+ catch (HibernateException he) {
+ log.error("Hibernate exception: " + he.toString());
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ * @param task
+ */
+ public static void removeTask(Task task) {
+ TaskFactory.getSession().delete(task);
+ }
+
+
+ /**
* Saves the object to the db
* @param taskIn The task to save
*/
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
index c7c8f66..baa0737 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
@@ -334,6 +334,7 @@ public class EditChannelAction extends RhnAction implements Listable {
ucc.setSupportPolicy((String)form.get("support_policy"));
ucc.setAccess((String)form.get("org_sharing"));
ucc.setYumUrl((String) form.getString("yum_repo"));
+ ucc.setRepoLabel((String) form.getString("repo_label"));
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
@@ -405,6 +406,7 @@ public class EditChannelAction extends RhnAction implements Listable {
ccc.setSupportPolicy((String)form.get("support_policy"));
ccc.setAccess((String)form.get("org_sharing"));
ccc.setYumUrl((String) form.getString("yum_repo"));
+ ccc.setRepoLabel((String) form.getString("repo_label"));
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
@@ -570,11 +572,13 @@ public class EditChannelAction extends RhnAction implements Listable {
if (c.getContentSources().isEmpty()) {
form.set("yum_repo", "");
+ form.set("repo_label", "");
request.setAttribute("last_sync", "");
}
else {
ContentSource cs = c.getContentSources().iterator().next();
form.set("yum_repo", cs.getSourceUrl());
+ form.set("repo_label", cs.getLabel());
String lastSync = LocalizationService.getInstance().getMessage(
"channel.edit.repo.neversynced");
if (cs.getLastSynced() != null) {
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 8c76681..82aabc0 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -21431,6 +21431,12 @@ given channel.</source>
<trans-unit id="channel.edit.jsp.repourl">
<source>Repository URL</source>
</trans-unit>
+ <trans-unit id="channel.edit.jsp.repolabel">
+ <source>Label</source>
+ </trans-unit>
+ <trans-unit id="edit.channel.invalidrepolabel.missing">
+ <source>A repo label is required if providing a yum repository url.</source>
+ </trans-unit>
<trans-unit id="channel.edit.jsp.lastsynced">
<source>Last Sync Time</source>
</trans-unit>
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 d75225c..0ea6469 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@ -68,9 +68,12 @@ public class CreateChannelCommand {
protected String supportPolicy;
protected String access = Channel.PRIVATE;
protected String yumUrl;
+ protected String repoLabel;
+
+
/**
* default constructor.
*/
@@ -269,7 +272,8 @@ public class CreateChannelCommand {
ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED);
- c.setYumContentSource(yumUrl);
+ c.setYumContentSource(yumUrl, repoLabel);
+
return c;
}
@@ -324,6 +328,12 @@ public class CreateChannelCommand {
throw new IllegalArgumentException(
"Required parameters not set: user, or summary");
}
+
+ if (!StringUtils.isEmpty(yumUrl) && StringUtils.isEmpty(repoLabel)) {
+ throw new IllegalArgumentException(
+ "edit.channel.invalidrepolabel.missing");
+ }
+
}
protected void verifyChannelName(String cname) throws InvalidChannelNameException {
@@ -432,5 +442,12 @@ public class CreateChannelCommand {
public void setYumUrl(String yumUrlIn) {
this.yumUrl = yumUrlIn;
}
+
+ /**
+ * @param repoLabelIn The repoLabel to set.
+ */
+ public void setRepoLabel(String repoLabelIn) {
+ this.repoLabel = repoLabelIn;
+ }
}
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 66d8673..79764aa 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
@@ -79,7 +79,7 @@ public class UpdateChannelCommand extends CreateChannelCommand {
c.setSupportPolicy(supportPolicy);
- c.setYumContentSource(yumUrl);
+ c.setYumContentSource(yumUrl, repoLabel);
// need to save before calling stored proc below
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
new file mode 100644
index 0000000..ae382a5
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java
@@ -0,0 +1,94 @@
+/**
+ * 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.
+ */
+package com.redhat.rhn.taskomatic.task;
+
+import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.channel.ContentSource;
+import com.redhat.rhn.domain.task.Task;
+import com.redhat.rhn.domain.task.TaskFactory;
+
+import org.apache.log4j.Logger;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Repo Sync
+ * Used for syncing repos (like yum repos) to a channel
+ * This really just calls a python script
+ *
+ * @version $Rev$
+ */
+public class RepoSyncTask implements Job {
+
+ /**
+ * Used to log stats in the RHNDAEMONSTATE table
+ */
+ public static final String DISPLAY_NAME = "repo_sync";
+
+ private static Logger log = Logger.getLogger(RepoSyncTask.class);
+
+ /**
+ * Default constructor
+ */
+ public RepoSyncTask() {
+ }
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void execute(JobExecutionContext context)
+ throws JobExecutionException {
+
+ for (Task task : TaskFactory.listTasks("repo_sync")) {
+
+ ContentSource src = ChannelFactory.lookupContentSource(task.getData());
+ if (src == null) {
+ log.error("Content Source could not be found: " + task.getData());
+ continue;
+ }
+
+ try {
+ Process p = Runtime.getRuntime().exec("");
+ }
+ catch (IOException e) {
+
+ }
+ src.setLastSynced(new Date());
+ TaskFactory.removeTask(task);
+ }
+ }
+
+ private static List<String> getSyncCommand(ContentSource src) {
+ List<String> cmd = new ArrayList<String>();
+ cmd.add("/usr/sbin/spacewalk-repo-sync");
+ cmd.add("-c");
+ cmd.add(src.getChannel().getLabel());
+ cmd.add("-u");
+ cmd.add(src.getSourceUrl());
+ cmd.add("-t");
+ cmd.add(src.getType().getLabel());
+ return cmd;
+ }
+
+
+}
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
index eb7649a..adda2fb 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
@@ -117,7 +117,7 @@
<bean:message key="channel.edit.jsp.repourl"/>:
</th>
<td>
- <html:text property="yum_repo" maxlength="512" size="60" />
+ <html:text property="yum_repo" maxlength="512" size="64" />
</td>
</tr>
<c:if test='${not empty param.cid}'>
@@ -132,6 +132,14 @@
</c:if>
<tr>
<th>
+ <bean:message key="channel.edit.jsp.repolabel"/>:
+ </th>
+ <td>
+ <html:text property="repo_label" maxlength="64" size="20" />
+ </td>
+ </tr>
+ <tr>
+ <th>
<bean:message key="channel.edit.jsp.sync"/>:
</th>
<td>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index d09d20d..8086357 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -838,6 +838,7 @@
<form-property name="maintainer_phone" type="java.lang.String" />
<form-property name="support_policy" type="java.lang.String" />
<form-property name="yum_repo" type="java.lang.String" />
+ <form-property name="repo_label" type="java.lang.String" />
<form-property name="sync_repo" type="java.lang.Boolean" />
<form-property name="per_user_subscriptions" type="java.lang.String" />
<form-property name="org_sharing" type="java.lang.String" />
commit 7363b853cd74456f03b24bfceb0478a89031ceb6
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jul 22 18:23:56 2009 -0400
adding label to ContentSource schema
diff --git a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
index 26c3973..f0b30a5 100644
--- a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
+++ b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
@@ -32,6 +32,8 @@ rhnChannelContentSource
references rhnContentSourceType(id),
source_url varchar2(512)
constraint rhn_ccs_url_nn not null,
+ label varchar2(64)
+ constraint rhn_ccs_l_nn not null,
last_synced date,
created date default(sysdate)
constraint rhn_ccs_cre_nn not null,
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
index a1445e1..ccf5cb8 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
@@ -32,6 +32,8 @@ rhnChannelContentSource
references rhnContentSourceType(id),
source_url varchar2(512)
constraint rhn_ccs_url_nn not null,
+ label varchar2(64)
+ constraint rhn_ccs_l_nn not null,
last_synced date,
created date default(sysdate)
constraint rhn_ccs_cre_nn not null,
commit 7a0f31f3dabe9c0c0f226421321c58f2c8c3c29b
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jul 22 18:22:37 2009 -0400
backend/satellite_tools/repo_plugins/yum_src.py
initial commit of spacewalk repo sync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
new file mode 100644
index 0000000..5abcc1c
--- /dev/null
+++ b/backend/satellite_tools/reposync.py
@@ -0,0 +1,201 @@
+#!/usr/bin/python -u
+#
+# Copyright (c) 2008 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 sys, os
+from optparse import OptionParser
+from common import rhnLib
+from server import rhnPackage, rhnSQL, rhnChannel, rhnPackageUpload
+from common import CFG, initCFG, rhn_rpm
+from server.importlib.importLib import IncompletePackage
+from server.importlib.backendOracle import OracleBackend
+from server.importlib.packageImport import ChannelPackageSubscription
+
+class RepoSync:
+
+
+ parser = None
+ type = None
+ url = None
+ channel_label = None
+ plugin = None
+ channel = None
+ fail = False
+ repo_label = None
+
+
+ def main(self):
+ initCFG('server')
+ db_string = CFG.DEFAULT_DB #"rhnsat/rhnsat@rhnsat"
+ rhnSQL.initDB(db_string)
+ (options, args) = self.process_args()
+
+
+ if not options.url:
+ print("--url must be specified")
+ if not options.type:
+ print("--type must be specified")
+ if not options.channel_label:
+ print("--channel must be specified")
+ if not options.label:
+ print("--label must be specified")
+
+
+ self.type = options.type
+ self.url = options.url
+ self.channel_label = options.channel_label
+ self.fail = options.fail
+ self.repo_label = options.label
+ self.channel = self.load_channel()
+
+ if not self.channel or not rhnChannel.isCustomChannel(self.channel['id']):
+ print "Channel does not exist or is not custom"
+ sys.exit(1)
+
+ self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label)
+ self.import_packages(self.plugin.list_packages())
+
+
+
+ def process_args(self):
+ self.parser = OptionParser()
+ self.parser.add_option('-u', '--url', action='store', dest='url', help='The url to sync')
+ self.parser.add_option('-c', '--channel', action='store', dest='channel_label', help='The label of the channel to sync packages to')
+ self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported')
+ self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo')
+ self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation")
+ return self.parser.parse_args()
+
+
+ def load_plugin(self):
+ sys.path.append("repo_plugins")
+ name = self.type + "_src"
+ mod = __import__(name)
+ return getattr(mod, "ContentSource")
+
+ def import_packages(self, packages):
+ to_link = []
+ to_download = []
+ for pack in packages:
+ pid = None
+ if pack.checksums.has_key('md5sum'):
+ """lookup by md5sum"""
+ elif pack.checksums.has_key('sha256'):
+ """lookup by sha256"""
+ if pid == None:
+ if self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, pack.epoch, pack.arch]) and \
+ self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, '', pack.arch]):
+ to_download.append(pack)
+
+
+ for (index, pack) in enumerate(to_download):
+ """download each package"""
+ try:
+ print(str(index) + "/" + str(len(to_download)) + " : "+ pack.getNVREA())
+ path = self.plugin.get_package(pack)
+ md5 = rhnLib.getFileMD5(filename=path)
+ pid = rhnPackage.get_package_for_md5sum(self.channel['org_id'], md5)
+ if pid is None:
+ self.upload_package(pack, path, md5)
+ self.associate_package(pack, md5)
+ else:
+ to_link.append(pack)
+ except KeyboardInterrupt:
+ raise
+ except:
+ if self.fail:
+ raise
+ continue
+ for pack in to_link:
+ try:
+ self.associate_package(pack, md5)
+ except KeyboardInterrupt:
+ raise
+ except:
+ if self.fail:
+ raise
+ continue
+
+ def upload_package(self, package, path, md5):
+ temp_file = open(path, 'rb')
+ header, payload_stream, md5sum, header_start, header_end = \
+ rhnPackageUpload.load_package(temp_file)
+ rel_package_path = rhnPackageUpload.relative_path_from_header(
+ header, org_id=self.channel['org_id'], md5sum=md5sum)
+ package_path = os.path.join(CFG.MOUNT_POINT,
+ rel_package_path)
+ package_dict, diff_level = rhnPackageUpload.push_package(header,
+ payload_stream, md5sum, force=False,
+ header_start=header_start, header_end=header_end,
+ relative_path=rel_package_path, org_id=self.channel['org_id'])
+ temp_file.close()
+ if self.url.find("file://") < 0:
+ os.remove(path)
+
+
+ def associate_package(self, pack, md5sum):
+ caller = "server.app.yumreposync"
+ backend = OracleBackend()
+ backend.init()
+ package = {}
+ package['name'] = pack.name
+ package['version'] = pack.version
+ package['release'] = pack.release
+ if pack.epoch == 0:
+ package['epoch'] = ""
+ else:
+ package['epoch'] = pack.epoch
+ package['arch'] = pack.arch
+ package['md5sum'] = md5sum
+ package['channels'] = [{'label':self.channel_label, 'id':self.channel['id']}]
+ package['org_id'] = self.channel['org_id']
+
+ try:
+ importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller)
+ importer.run()
+ except:
+ package['epoch'] = '0'
+ importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller)
+ importer.run()
+ backend.commit()
+ def load_channel(self):
+ return rhnChannel.channel_info(self.channel_label)
+
+
+class ContentPackage:
+
+ #map of checksums. Valid keys are 'md5sum' & 'sha256'
+ checksums = {}
+
+ #unique ID that can be used by plugin
+ unique_id = None
+
+ name = None
+ version = None
+ release = None
+ epoch = None
+ arch = None
+
+ def setNVREA(self, name, version, release, epoch, arch):
+ self.name = name
+ self.version = version
+ self.release = release
+ self.arch = arch
+
+ def getNVREA(self):
+ if self.epoch:
+ return self.name + '-' + self.version + '-' + self.release + '-' + self.epoch + '.' + self.arch
+ else:
+ return self.name + '-' + self.version + '-' + self.release + '.' + self.arch
+
diff --git a/backend/satellite_tools/spacewalk-repo-sync b/backend/satellite_tools/spacewalk-repo-sync
new file mode 100755
index 0000000..244c260
--- /dev/null
+++ b/backend/satellite_tools/spacewalk-repo-sync
@@ -0,0 +1,89 @@
+#!/usr/bin/python -u
+#
+# Copyright (c) 2008 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.
+#
+
+LOCK = None
+
+if __name__ != '__main__':
+ raise ImportError, "module cannot be imported"
+
+import sys
+def systemExit(code, msgs=None):
+ "Exit with a code and optional message(s). Saved a few lines of code."
+
+ if msgs:
+ if type(msgs) not in [type([]), type(())]:
+ msgs = (msgs, )
+ for msg in msgs:
+ sys.stderr.write(str(msg)+'\n')
+ sys.exit(code)
+
+
+try:
+ import os
+ import socket
+ _LIBPATH = "/usr/share/rhn"
+ if _LIBPATH not in sys.path:
+ sys.path.append(_LIBPATH)
+ from common import rhnLockfile, CFG, fetchTraceback
+ from satellite_tools import reposync
+except KeyboardInterrupt:
+ systemExit(0, "\nUser interrupted process.")
+except ImportError:
+ sys.stderr.write("Unable to find RHN code tree.\n"
+ "Path not correct? '%s'\n" % _LIBPATH)
+
+
+
+
+def releaseLOCK():
+ global LOCK
+ if LOCK:
+ LOCK.release()
+ LOCK = None
+
+
+def main():
+
+ # quick check to see if you are a super-user.
+ if os.getuid() != 0:
+ sys.stderr.write('ERROR: must be root to execute\n')
+ sys.exit(8)
+
+
+ LOCK = None
+ try:
+ LOCK = rhnLockfile.Lockfile('/var/run/spacewalk-sync.pid')
+ except rhnLockfile.LockfileLockedException:
+ systemExit(1, "SYNC ERROR: attempting to run more than one instance of satellite-sync. Exiting.")
+
+ sync = reposync.RepoSync()
+ sync.main()
+ releaseLOCK()
+ return 0
+
+
+if __name__ == '__main__':
+ try:
+ sys.exit(abs(main() or 0))
+ except KeyboardInterrupt:
+ systemExit(0, "\nUser interrupted process.")
+ except SystemExit, e:
+ releaseLOCK()
+ sys.exit(e.code)
+ except Exception, e:
+ releaseLOCK()
+ raise
+
diff --git a/backend/server/basePackageUpload.py b/backend/server/basePackageUpload.py
new file mode 100644
index 0000000..ad05f93
--- /dev/null
+++ b/backend/server/basePackageUpload.py
@@ -0,0 +1,100 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2008 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.
+#
+# $Id$
+
+import os
+import tempfile
+from mod_python import apache
+
+from common import CFG, log_debug, rhnFault, rhn_mpm, rhnLib, UserDictCase
+from common.rhn_rpm import get_header_byte_range
+
+from server import rhnSQL
+from server.importlib import importLib, userAuth, mpmSource, backendOracle, \
+ packageImport, errataCache
+from server.rhnLib import get_package_path, \
+ get_package_path_without_package_name
+from server.rhnServer import server_packages
+
+class BasePackageUpload:
+ def __init__(self, req):
+ self.header_prefix = "X-RHN-Upload"
+ self.error_header_prefix = 'X-RHN-Upload-Error'
+ self.prefix = 'rhn/repository'
+ self.is_source = 0
+ self.rel_package_path = None
+ self.package_path = None
+ self.required_fields = [
+ "Package-Name",
+ "Package-Version",
+ "Package-Release",
+ "Package-Arch",
+ "File-MD5sum",
+ ]
+ self.field_data = UserDictCase()
+ self.org_id = None
+
+ def headerParserHandler(self, req):
+ """ This whole function is ugly as hell. The Auth field in the header used to be required, but now
+ it must have either the Auth field or the Auth-Session field.
+ """
+ # Initialize the logging
+ log_debug(3, "Method", req.method)
+
+ #Header string. This is what the Auth-Session field will look like in the header.
+ session_header = "%s-%s" % (self.header_prefix, "Auth-Session")
+
+ for f in self.required_fields:
+ hf = "%s-%s" % (self.header_prefix, f)
+ if not req.headers_in.has_key(hf):
+ #If the current field is Auth and Auth-Session field isn't present, something is wrong.
+ if f == "Auth" and not req.headers_in.has_key(session_header):
+ log_debug(4, "Required field %s missing" % f)
+ raise rhnFault(500, f)
+
+ #The current field is Auth and the Auth-Session field is present, so everything is good.
+ elif f == "Auth" and req.headers_in.has_key(session_header):
+ self.field_data["Auth-Session"] = req.headers_in[session_header]
+ continue
+
+ #The current field being looked for isn't the Auth field and it's missing, so something is wrong.
+ else:
+ log_debug(4, "Required field %s missing" % f)
+ raise rhnFault(500, f)
+
+ if not (f == "Auth" and not req.headers_in.has_key(hf)):
+ self.field_data[f] = req.headers_in[hf]
+ else:
+ if req.headers_in.has_key(session_header):
+ self.field_data[f] = req.headers_in[hf]
+
+ self.package_name = self.field_data["Package-Name"]
+ 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"]
+ #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
+
+ def handler(self, req):
+ log_debug(3, "Method", req.method)
+ return apache.OK
+ def cleanupHandler(self, req):
+ return apache.OK
+
+ def logHandler(self, req):
+ return apache.OK
diff --git a/backend/server/rhnPackage.py b/backend/server/rhnPackage.py
index c5f97b0..0b7ac08 100644
--- a/backend/server/rhnPackage.py
+++ b/backend/server/rhnPackage.py
@@ -432,6 +432,22 @@ def get_channels_for_package(pkg):
return []
return map(lambda c: c['label'], ret)
+def get_package_for_md5sum(org_id, md5sum):
+ statement = """
+ select
+ p.id
+ from
+ rhnPackage p
+ where p.org_id = :org_id
+ and p.md5sum = :md5sum
+ """
+ h = rhnSQL.prepare(statement)
+ h.execute(org_id=org_id, md5sum=md5sum)
+ ret = h.fetchone_dict()
+ if not ret:
+ return None
+ return ret['id']
+
def _none2emptyString(foo):
if foo is None:
diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py
index 5cdcd95..46b57a7 100644
--- a/backend/server/rhnPackageUpload.py
+++ b/backend/server/rhnPackageUpload.py
@@ -17,7 +17,6 @@
import os
import tempfile
-from mod_python import apache
from common import CFG, log_debug, rhnFault, rhn_mpm, rhnLib, UserDictCase
from common.rhn_rpm import get_header_byte_range
@@ -29,76 +28,6 @@ from server.rhnLib import get_package_path, \
get_package_path_without_package_name
from server.rhnServer import server_packages
-class BasePackageUpload:
- def __init__(self, req):
- self.header_prefix = "X-RHN-Upload"
- self.error_header_prefix = 'X-RHN-Upload-Error'
- self.prefix = 'rhn/repository'
- self.is_source = 0
- self.rel_package_path = None
- self.package_path = None
- self.required_fields = [
- "Package-Name",
- "Package-Version",
- "Package-Release",
- "Package-Arch",
- "File-MD5sum",
- ]
- self.field_data = UserDictCase()
- self.org_id = None
-
- def headerParserHandler(self, req):
- """ This whole function is ugly as hell. The Auth field in the header used to be required, but now
- it must have either the Auth field or the Auth-Session field.
- """
- # Initialize the logging
- log_debug(3, "Method", req.method)
-
- #Header string. This is what the Auth-Session field will look like in the header.
- session_header = "%s-%s" % (self.header_prefix, "Auth-Session")
-
- for f in self.required_fields:
- hf = "%s-%s" % (self.header_prefix, f)
- if not req.headers_in.has_key(hf):
- #If the current field is Auth and Auth-Session field isn't present, something is wrong.
- if f == "Auth" and not req.headers_in.has_key(session_header):
- log_debug(4, "Required field %s missing" % f)
- raise rhnFault(500, f)
-
- #The current field is Auth and the Auth-Session field is present, so everything is good.
- elif f == "Auth" and req.headers_in.has_key(session_header):
- self.field_data["Auth-Session"] = req.headers_in[session_header]
- continue
-
- #The current field being looked for isn't the Auth field and it's missing, so something is wrong.
- else:
- log_debug(4, "Required field %s missing" % f)
- raise rhnFault(500, f)
-
- if not (f == "Auth" and not req.headers_in.has_key(hf)):
- self.field_data[f] = req.headers_in[hf]
- else:
- if req.headers_in.has_key(session_header):
- self.field_data[f] = req.headers_in[hf]
-
- self.package_name = self.field_data["Package-Name"]
- 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"]
- #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
-
- def handler(self, req):
- log_debug(3, "Method", req.method)
- return apache.OK
- def cleanupHandler(self, req):
- return apache.OK
-
- def logHandler(self, req):
- return apache.OK
-
def source_match(v1, v2):
""" returns true if both parameters are true, false otherwise """
diff --git a/backend/upload_server/handlers/package_push/package_push.py b/backend/upload_server/handlers/package_push/package_push.py
index fd19a3e..2115ada 100644
--- a/backend/upload_server/handlers/package_push/package_push.py
+++ b/backend/upload_server/handlers/package_push/package_push.py
@@ -26,11 +26,11 @@ from mod_python import apache
from rhn import rpclib
from common import CFG, log_debug, log_error, rhnFault, rhnFlags
-from server import rhnPackageUpload, rhnSQL
+from server import rhnPackageUpload, rhnSQL, basePackageUpload
-class PackagePush(rhnPackageUpload.BasePackageUpload):
+class PackagePush(basePackageUpload.BasePackageUpload):
def __init__(self, req):
- rhnPackageUpload.BasePackageUpload.__init__(self, req)
+ basePackageUpload.BasePackageUpload.__init__(self, req)
self.required_fields.extend([
'Auth',
'Force',
@@ -43,7 +43,7 @@ class PackagePush(rhnPackageUpload.BasePackageUpload):
self.force = None
def headerParserHandler(self, req):
- ret = rhnPackageUpload.BasePackageUpload.headerParserHandler(self, req)
+ ret = basePackageUpload.BasePackageUpload.headerParserHandler(self, req)
# Optional headers
maps = [['Null-Org', 'null_org'], ['Packaging', 'packaging']]
for hn, sn in maps:
@@ -108,7 +108,7 @@ class PackagePush(rhnPackageUpload.BasePackageUpload):
def handler(self, req):
- ret = rhnPackageUpload.BasePackageUpload.handler(self, req)
+ ret = basePackageUpload.BasePackageUpload.handler(self, req)
if ret != apache.OK:
return ret
diff --git a/backend/upload_server/handlers/package_upload/package_upload.py b/backend/upload_server/handlers/package_upload/package_upload.py
index c3689cb..b087ca9 100644
--- a/backend/upload_server/handlers/package_upload/package_upload.py
+++ b/backend/upload_server/handlers/package_upload/package_upload.py
@@ -23,12 +23,12 @@ import os
from mod_python import apache
from common import CFG, log_debug, log_error, rhnFault, rhnFlags
-from server import rhnPackageUpload
+from server import rhnPackageUpload, basePackageUpload
from server.rhnLib import get_package_path
-class PackageUpload(rhnPackageUpload.BasePackageUpload):
+class PackageUpload(basePackageUpload.BasePackageUpload):
def headerParserHandler(self, req):
- ret = rhnPackageUpload.BasePackageUpload.headerParserHandler(self, req)
+ ret = basePackageUpload.BasePackageUpload.headerParserHandler(self, req)
if ret != apache.OK:
return ret
@@ -60,7 +60,7 @@ class PackageUpload(rhnPackageUpload.BasePackageUpload):
return apache.OK
def handler(self, req):
- ret = rhnPackageUpload.BasePackageUpload.handler(self, req)
+ ret = basePackageUpload.BasePackageUpload.handler(self, req)
if ret != apache.OK:
return ret
commit ac8941eed03bef6babc9caff3c47ae1a02a357ff
Merge: a54eb73... 953f234...
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jul 22 14:14:38 2009 -0400
merge conflict
diff --cc java/code/src/com/redhat/rhn/domain/channel/Channel.java
index b7f8d4d,ca5071e..303fa7d
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
@@@ -794,46 -795,30 +798,72 @@@ public class Channel extends BaseDomain
public boolean containsDistributions() {
return ChannelFactory.containsDistributions(this);
}
+
+ /**
+ * @return Returns the contentSources.
+ */
+ public Set<ContentSource> getContentSources() {
+ return contentSources;
+ }
+
+
+ /**
+ * @param contentSourcesIn The contentSources to set.
+ */
+ public void setContentSources(Set<ContentSource> contentSourcesIn) {
+ this.contentSources = contentSourcesIn;
+ }
+
+ /**
+ * Set the yum content source, if one is already set, it will be replaced
+ * if null or '' is passed in, all content sources will be removed.
+ * @param url the url of the yum repo
+ */
+ public void setYumContentSource(String url) {
+ if (StringUtils.isEmpty(url)) {
+ if (!this.getContentSources().isEmpty()) {
+ this.getContentSources().clear();
+ }
+ }
+ else {
+ if (this.getContentSources().isEmpty()) {
+ ContentSource cs = new ContentSource();
+ cs.setChannel(this);
+ cs.setSourceUrl(url);
+ cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM);
+ this.getContentSources().add(cs);
+ }
+ else {
+ this.getContentSources().iterator().next().setSourceUrl(url);
+ }
+ }
+ ChannelFactory.save(this);
+ }
+
+
+ /**
+ * get the compatible checksum type to be used for repomd.xml
+ * based on channel release. If its RHEL-5 we use sha1
+ * anything newer will be sha256.
+ * @return checksumType
+ */
+ public String getChecksumType() {
+ Channel toConsider = this;
+ while (toConsider.getParentChannel() != null) {
+ toConsider = toConsider.getParentChannel();
+ }
+ DistChannelMap channelDist = ChannelFactory.lookupDistChannelMap(toConsider);
+ if (channelDist != null) {
+ String release = channelDist.getRelease();
+ // If channel or parent is RHEL-5 use sha1, else use sha256
+ if (toConsider.isCustom() || sha1compatiblechannels.contains(release)) {
+ return CHECKSUM_SHA_1;
+ }
+ else {
+ return CHECKSUM_SHA_256;
+ }
+ }
+ // default to sha256
+ return CHECKSUM_SHA_256;
+ }
}
diff --cc java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index 2499e27,a8952f6..a01a024
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@@ -8243,9 -8272,18 +8272,21 @@@ Follow this url to see the full list o
<trans-unit id="snapshots.configchannel">
<source>Configuration Channels Updated</source>
</trans-unit>
+ <trans-unit id="channel.edit.repo.neversynced">
+ <source>This repo has never been synced.</source>
+ </trans-unit>
+ <trans-unit id="ssm.provision.scheduled">
+ <source>Successfully scheduled {0} system(s) for provisioning.</source>
+ </trans-unit>
+ <trans-unit id="ssm.package.install.operationname">
+ <source>Schedule Package Installations</source>
+ </trans-unit>
+ <trans-unit id="ssm.package.upgrade.operationname">
+ <source>Schedule Package Upgrades</source>
+ </trans-unit>
+ <trans-unit id="ssm.package.verify.operationname">
+ <source>Schedule Package Verifications</source>
+ </trans-unit>
<trans-unit id="kickstart.cobbler.distro.syncfail">
<source>
The following is a list of errors gathered while Spacewalk attempts to
commit a54eb7309017956196ba92d58a6ba615bc288a9b
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jul 13 13:45:19 2009 -0400
adding sync repo option to UI for yum repos
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 2580fb5..ac7d30f 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -21337,7 +21337,10 @@ given channel.</source>
</trans-unit>
<trans-unit id="channel.edit.jsp.lastsynced">
<source>Last Sync Time</source>
- </trans-unit>
+ </trans-unit>
+ <trans-unit id="channel.edit.jsp.sync">
+ <source>Sync Repo</source>
+ </trans-unit>
</body>
</file>
</xliff>
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
index 7ee2632..eb7649a 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
@@ -120,14 +120,24 @@
<html:text property="yum_repo" maxlength="512" size="60" />
</td>
</tr>
+ <c:if test='${not empty param.cid}'>
+ <tr>
+ <th>
+ <bean:message key="channel.edit.jsp.lastsynced"/>:
+ </th>
+ <td>
+ <c:out value='${last_sync}'/>
+ </td>
+ </tr>
+ </c:if>
<tr>
- <th>
- <bean:message key="channel.edit.jsp.lastsynced"/>:
+ <th>
+ <bean:message key="channel.edit.jsp.sync"/>:
</th>
<td>
- <c:out value='${last_sync}'/>
+ <html:checkbox property="sync_repo" />
</td>
- </tr>
+ </tr>
</table>
<h2><bean:message key="channel.edit.jsp.contactsupportinfo"/></h2>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 884ac91..37787a1 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -841,6 +841,7 @@
<form-property name="maintainer_phone" type="java.lang.String" />
<form-property name="support_policy" type="java.lang.String" />
<form-property name="yum_repo" type="java.lang.String" />
+ <form-property name="sync_repo" type="java.lang.Boolean" />
<form-property name="per_user_subscriptions" type="java.lang.String" />
<form-property name="org_sharing" type="java.lang.String" />
<form-property name="gpg_key_url" type="java.lang.String" />
commit d19948c081d40f1682ba6a6f4aeb6885eb8eb440
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Fri Jul 10 16:25:37 2009 -0400
initial yum repo sync schema and UI work
diff --git a/java/buildconf/builder/config/satellite/rhn.conf b/java/buildconf/builder/config/satellite/rhn.conf
index 06eb7a6..6d65bbe 100644
--- a/java/buildconf/builder/config/satellite/rhn.conf
+++ b/java/buildconf/builder/config/satellite/rhn.conf
@@ -38,7 +38,7 @@ web.default_db=rhnsat/rhnsat@rhnsat
web.legacy_user_enabled = 1
web.legacy_save_enabled = 1
-hibernate.connection.url=jdbc:log:oracle.jdbc.driver.OracleDriver:oracle:thin:@joust.rhndev.redhat.com:1521:rhnsat
+hibernate.connection.url=jdbc:log:oracle.jdbc.driver.OracleDriver:oracle:thin:@rlx-2-10.rhndev.redhat.com:1521:rhnsat
hibernate.connection.driver_class=net.rkbloom.logdriver.LogDriver
web.product_name = Spacewalk
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
index f4ecff3..51f850d 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
@@ -63,6 +63,14 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
column="channel_family_id"/>
</set>
+ <set name="contentSources" lazy="true" table="rhnChannelContentSource"
+ cascade="all-delete-orphan" inverse="true">
+ <key column="channel_id"/>
+ <one-to-many
+ class="com.redhat.rhn.domain.channel.ContentSource" />
+ </set>
+
+
<set name="trustedOrgs" lazy="true" table="rhnChannelTrust"
cascade="save-update">
<key column="channel_id"/>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
index b45d739..b7f8d4d 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
@@ -24,6 +24,7 @@ import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.system.IncompatibleArchException;
import com.redhat.rhn.manager.system.SystemManager;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -84,7 +85,9 @@ public class Channel extends BaseDomainHelper implements Comparable {
private String maintainerEmail;
private String maintainerPhone;
private String supportPolicy;
-
+ private Set<ContentSource> contentSources = new HashSet();
+
+
/**
* @param orgIn what org you want to know if it is globally subscribable in
* @return Returns whether or not this channel is globally subscribable.
@@ -791,4 +794,46 @@ public class Channel extends BaseDomainHelper implements Comparable {
public boolean containsDistributions() {
return ChannelFactory.containsDistributions(this);
}
+
+ /**
+ * @return Returns the contentSources.
+ */
+ public Set<ContentSource> getContentSources() {
+ return contentSources;
+ }
+
+
+ /**
+ * @param contentSourcesIn The contentSources to set.
+ */
+ public void setContentSources(Set<ContentSource> contentSourcesIn) {
+ this.contentSources = contentSourcesIn;
+ }
+
+ /**
+ * Set the yum content source, if one is already set, it will be replaced
+ * if null or '' is passed in, all content sources will be removed.
+ * @param url the url of the yum repo
+ */
+ public void setYumContentSource(String url) {
+ if (StringUtils.isEmpty(url)) {
+ if (!this.getContentSources().isEmpty()) {
+ this.getContentSources().clear();
+ }
+ }
+ else {
+ if (this.getContentSources().isEmpty()) {
+ ContentSource cs = new ContentSource();
+ cs.setChannel(this);
+ cs.setSourceUrl(url);
+ cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM);
+ this.getContentSources().add(cs);
+ }
+ else {
+ this.getContentSources().iterator().next().setSourceUrl(url);
+ }
+ }
+ ChannelFactory.save(this);
+ }
+
}
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 4837cf1..b2c2abd 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
@@ -14,22 +14,6 @@
*/
package com.redhat.rhn.domain.channel;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.criterion.CriteriaSpecification;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-
import com.redhat.rhn.common.db.datasource.CallableMode;
import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.common.db.datasource.ModeFactory;
@@ -43,6 +27,22 @@ import com.redhat.rhn.domain.rhnpackage.Package;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.manager.channel.ChannelManager;
+import org.apache.log4j.Logger;
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.criterion.CriteriaSpecification;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* ChannelFactory
* @version $Rev$
@@ -52,6 +52,9 @@ public class ChannelFactory extends HibernateFactory {
private static ChannelFactory singleton = new ChannelFactory();
private static Logger log = Logger.getLogger(ChannelFactory.class);
+ public static final ContentSourceType CONTENT_SOURCE_TYPE_YUM =
+ ChannelFactory.lookupContentSourceType("yum");
+
private ChannelFactory() {
super();
}
@@ -110,6 +113,19 @@ public class ChannelFactory extends HibernateFactory {
"Channel.findByLabelAndUserId", params);
}
+
+ /**
+ * Lookup a content source type by label
+ * @param label the label to lookup
+ * @return the ContentSourceType
+ */
+ public static ContentSourceType lookupContentSourceType(String label) {
+ Map params = new HashMap();
+ params.put("label", label);
+ return (ContentSourceType) singleton.lookupObjectByNamedQuery(
+ "ContentSourceType.findByLabel", params);
+ }
+
/**
* Retrieve a list of channel ids associated with the labels provided
* @param labelsIn the labels to search for
@@ -129,7 +145,16 @@ public class ChannelFactory extends HibernateFactory {
public static void save(Channel c) {
singleton.saveObject(c);
}
-
+
+ /**
+ * Insert or Update a content source.
+ * @param c content source to be stored in database.
+ */
+ public static void save(ContentSource c) {
+ singleton.saveObject(c);
+ }
+
+
/**
* Remove a Channel from the DB
* @param c Action to be removed from database.
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
new file mode 100644
index 0000000..2756941
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.channel.ContentSource"
+ table="rhnChannelContentSource" >
+
+ <id name="id" type="long" column="id">
+ <meta attribute="scope-set">protected</meta>
+ <generator class="sequence">
+ <param name="sequence">rhn_chan_content_src_id_seq</param>
+ </generator>
+ </id>
+
+ <property name="sourceUrl" type="string" column="source_url"/>
+ <property name="lastSynced" type="timestamp" column="last_synced"/>
+ <property name="created" type="timestamp" column="created" insert="false" update="false" />
+ <property name="modified" type="timestamp" column="modified" insert="false" update="false" />
+
+
+ <many-to-one
+ name="type"
+ class="com.redhat.rhn.domain.channel.ContentSourceType"
+ column="type_id"/>
+
+ <many-to-one
+ name="channel"
+ class="com.redhat.rhn.domain.channel.Channel"
+ column="channel_id" />
+
+
+ </class>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
new file mode 100644
index 0000000..70a54e8
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
@@ -0,0 +1,114 @@
+/**
+ * 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.
+ */
+package com.redhat.rhn.domain.channel;
+
+import com.redhat.rhn.domain.BaseDomainHelper;
+
+import java.util.Date;
+
+/**
+ * ContentSourceType
+ * @version $Rev$
+ */
+public class ContentSource extends BaseDomainHelper {
+
+ private Long id;
+ private Channel channel;
+ private ContentSourceType type;
+ private String sourceUrl;
+ private Date lastSynced;
+
+
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param idIn The id to set.
+ */
+ public void setId(Long idIn) {
+ this.id = idIn;
+ }
+
+
+
+ /**
+ * @return Returns the chan.
+ */
+ public Channel getChannel() {
+ return channel;
+ }
+
+
+ /**
+ * @param chanIn The chan to set.
+ */
+ public void setChannel(Channel chanIn) {
+ this.channel = chanIn;
+ }
+
+
+ /**
+ * @return Returns the type.
+ */
+ public ContentSourceType getType() {
+ return type;
+ }
+
+
+ /**
+ * @param typeIn The type to set.
+ */
+ public void setType(ContentSourceType typeIn) {
+ this.type = typeIn;
+ }
+
+
+ /**
+ * @return Returns the sourceUrl.
+ */
+ public String getSourceUrl() {
+ return sourceUrl;
+ }
+
+
+ /**
+ * @param sourceUrlIn The sourceUrl to set.
+ */
+ public void setSourceUrl(String sourceUrlIn) {
+ this.sourceUrl = sourceUrlIn;
+ }
+
+ /**
+ * @return Returns the lastSynced.
+ */
+ public Date getLastSynced() {
+ return lastSynced;
+ }
+
+
+ /**
+ * @param lastSyncedIn The lastSynced to set.
+ */
+ public void setLastSynced(Date lastSyncedIn) {
+ this.lastSynced = lastSyncedIn;
+ }
+
+
+
+}
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml
new file mode 100644
index 0000000..f44342d
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.channel.ContentSourceType"
+ table="rhnContentSourceType" mutable="false">
+ <cache usage="read-only"/>
+ <id name="id" type="long" column="id">
+ <meta attribute="scope-set">protected</meta>
+ <generator class="sequence">
+ <param name="sequence">rhn_content_source_type_id_seq</param>
+ </generator>
+ </id>
+
+ <property name="label" type="string" column="label"/>
+ <property name="created" type="date" column="created"/>
+ <property name="modified" type="date" column="modified"/>
+
+ </class>
+
+
+ <query name="ContentSourceType.findByLabel">
+ <![CDATA[from com.redhat.rhn.domain.channel.ContentSourceType as c where c.label = :label]]>
+ </query>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java
new file mode 100644
index 0000000..9757457
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ */
+package com.redhat.rhn.domain.channel;
+
+import com.redhat.rhn.domain.BaseDomainHelper;
+
+/**
+ * ContentSourceType
+ * @version $Rev$
+ */
+public class ContentSourceType extends BaseDomainHelper {
+
+ private Long id;
+ private String label;
+
+
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param i The id to set.
+ */
+ public void setId(Long i) {
+ this.id = i;
+ }
+
+ /**
+ * @return Returns the label.
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * @param l The label to set.
+ */
+ public void setLabel(String l) {
+ this.label = l;
+ }
+
+
+
+}
diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java
index a27c402..b5e2900 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java
@@ -18,6 +18,7 @@ import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
+import com.redhat.rhn.domain.channel.ContentSource;
import com.redhat.rhn.domain.errata.Errata;
import com.redhat.rhn.domain.errata.test.ErrataFactoryTest;
import com.redhat.rhn.domain.rhnpackage.Package;
@@ -175,4 +176,17 @@ public class ChannelTest extends BaseTestCaseWithUser {
}
}
+
+ public void testContentSource() throws Exception {
+ Channel c = ChannelFactoryTest.createTestChannel(user);
+ ContentSource cs = new ContentSource();
+ cs.setSourceUrl("fake url");
+ cs.setChannel(c);
+ cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM);
+ c.getContentSources().add(cs);
+ c = (Channel) TestUtils.saveAndReload(c);
+ assertNotEmpty(c.getContentSources());
+ }
+
+
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
index 0845b9f..d58ac62 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
@@ -14,30 +14,13 @@
*/
package com.redhat.rhn.frontend.action.channel.manage;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts.action.ActionErrors;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionMessage;
-import org.apache.struts.action.ActionMessages;
-import org.apache.struts.action.DynaActionForm;
-
import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.common.localization.LocalizationService;
import com.redhat.rhn.common.security.PermissionException;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelArch;
import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.channel.ContentSource;
import com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.server.Server;
@@ -59,6 +42,24 @@ import com.redhat.rhn.manager.channel.UpdateChannelCommand;
import com.redhat.rhn.manager.system.SystemManager;
import com.redhat.rhn.manager.user.UserManager;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.action.DynaActionForm;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* EditChannelAction
@@ -332,6 +333,7 @@ public class EditChannelAction extends RhnAction implements Listable {
ucc.setMaintainerPhone((String)form.get("maintainer_phone"));
ucc.setSupportPolicy((String)form.get("support_policy"));
ucc.setAccess((String)form.get("org_sharing"));
+ ucc.setYumUrl((String) form.getString("yum_repo"));
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
@@ -402,6 +404,7 @@ public class EditChannelAction extends RhnAction implements Listable {
ccc.setMaintainerPhone((String)form.get("maintainer_phone"));
ccc.setSupportPolicy((String)form.get("support_policy"));
ccc.setAccess((String)form.get("org_sharing"));
+ ccc.setYumUrl((String) form.getString("yum_repo"));
String parent = (String)form.get("parent");
if (parent == null || parent.equals("")) {
@@ -559,6 +562,23 @@ public class EditChannelAction extends RhnAction implements Listable {
.getMessage("generic.jsp.none"));
}
+ if (c.getContentSources().isEmpty()) {
+ form.set("yum_repo", "");
+ request.setAttribute("last_sync", "");
+ }
+ else {
+ ContentSource cs = c.getContentSources().iterator().next();
+ form.set("yum_repo", cs.getSourceUrl());
+ String lastSync = LocalizationService.getInstance().getMessage(
+ "channel.edit.repo.neversynced");
+ if (cs.getLastSynced() != null) {
+ lastSync = LocalizationService.getInstance().formatDate(
+ cs.getLastSynced());
+ }
+ request.setAttribute("last_sync", lastSync);
+
+ }
+
request.setAttribute("channel_label", c.getLabel());
request.setAttribute("channel_name", c.getName());
request.setAttribute("channel_arch", c.getChannelArch().getName());
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index 12d363a..2499e27 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -8243,6 +8243,9 @@ Follow this url to see the full list of inactive systems:
<trans-unit id="snapshots.configchannel">
<source>Configuration Channels Updated</source>
</trans-unit>
+ <trans-unit id="channel.edit.repo.neversynced">
+ <source>This repo has never been synced.</source>
+ </trans-unit>
<trans-unit id="kickstart.cobbler.distro.syncfail">
<source>
The following is a list of errors gathered while Spacewalk attempts to
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 521532d..2580fb5 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -21329,9 +21329,15 @@ given channel.</source>
<trans-unit id="channel.jsp.repolastbuild">
<source>Last Repo Build</source>
</trans-unit>
-
-
-
+ <trans-unit id="channel.edit.jsp.yumrepo">
+ <source>Associated Yum Repository</source>
+ </trans-unit>
+ <trans-unit id="channel.edit.jsp.repourl">
+ <source>Repository URL</source>
+ </trans-unit>
+ <trans-unit id="channel.edit.jsp.lastsynced">
+ <source>Last Sync Time</source>
+ </trans-unit>
</body>
</file>
</xliff>
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 8ee65e9..b219588 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@ -66,7 +66,10 @@ public class CreateChannelCommand {
protected String maintainerPhone;
protected String supportPolicy;
protected String access = Channel.PRIVATE;
+ protected String yumUrl;
+
+
/**
* default constructor.
*/
@@ -265,6 +268,8 @@ public class CreateChannelCommand {
ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED);
+ c.setYumContentSource(yumUrl);
+
return c;
}
@@ -411,4 +416,12 @@ public class CreateChannelCommand {
throw new InvalidGPGUrlException();
}
}
+
+ /**
+ * @param yumUrlIn The yumUrl to set.
+ */
+ public void setYumUrl(String yumUrlIn) {
+ this.yumUrl = yumUrlIn;
+ }
+
}
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 576fcc9..66d8673 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
@@ -77,6 +77,10 @@ public class UpdateChannelCommand extends CreateChannelCommand {
c.setMaintainerEmail(maintainerEmail);
c.setMaintainerPhone(maintainerPhone);
c.setSupportPolicy(supportPolicy);
+
+
+ c.setYumContentSource(yumUrl);
+
// need to save before calling stored proc below
ChannelFactory.save(c);
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
index d7c45e4..7ee2632 100644
--- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp
@@ -108,6 +108,27 @@
</td>
</tr>
</table>
+
+
+ <h2><bean:message key="channel.edit.jsp.yumrepo"/></h2>
+ <table class="details">
+ <tr>
+ <th>
+ <bean:message key="channel.edit.jsp.repourl"/>:
+ </th>
+ <td>
+ <html:text property="yum_repo" maxlength="512" size="60" />
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <bean:message key="channel.edit.jsp.lastsynced"/>:
+ </th>
+ <td>
+ <c:out value='${last_sync}'/>
+ </td>
+ </tr>
+ </table>
<h2><bean:message key="channel.edit.jsp.contactsupportinfo"/></h2>
<table class="details">
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 5bd6f16..884ac91 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -840,6 +840,7 @@
<form-property name="maintainer_email" type="java.lang.String" />
<form-property name="maintainer_phone" type="java.lang.String" />
<form-property name="support_policy" type="java.lang.String" />
+ <form-property name="yum_repo" type="java.lang.String" />
<form-property name="per_user_subscriptions" type="java.lang.String" />
<form-property name="org_sharing" type="java.lang.String" />
<form-property name="gpg_key_url" type="java.lang.String" />
diff --git a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
new file mode 100644
index 0000000..26c3973
--- /dev/null
+++ b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql
@@ -0,0 +1,59 @@
+--
+-- Copyright (c) 2008 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 table
+rhnChannelContentSource
+(
+ id number
+ constraint rhn_ccs_id_nn not null
+ constraint rhn_ccs_id_pk primary key,
+ channel_id number
+ constraint rhn_ccs_c_nn not null
+ constraint rhn_ccs_c_fk
+ references rhnChannel(id) on delete cascade,
+ type_id number
+ constraint rhn_ccs_type_nn not null
+ constraint rhn_ccs_type_fk
+ references rhnContentSourceType(id),
+ source_url varchar2(512)
+ constraint rhn_ccs_url_nn not null,
+ last_synced date,
+ created date default(sysdate)
+ constraint rhn_ccs_cre_nn not null,
+ modified date default(sysdate)
+ constraint rhn_ccs_mod_nn not null
+)
+ enable row movement
+ ;
+
+
+create sequence rhn_chan_content_src_id_seq start with 500;
+
+
+create unique index rhn_ccs_uq
+ on rhnChannelContentSource(channel_id, type_id, source_url)
+ tablespace [[64k_tbs]]
+ ;
+
+/
+show errors
+
+--
+-- Revision 1.0 2009/06/26 21:54 jlsherrill
+-- Initial file.
+--
diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql
new file mode 100644
index 0000000..6e0ce24
--- /dev/null
+++ b/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql
@@ -0,0 +1,48 @@
+--
+-- Copyright (c) 2008 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 table
+rhnContentSourceType
+(
+ id number
+ constraint rhn_cst_id_nn not null
+ constraint rhn_cst_id_pk primary key,
+ label varchar2(32)
+ constraint rhn_cst_label_nn not null
+ constraint rhn_cst_label_uq unique,
+ created date default(sysdate)
+ constraint rhn_cst_created_nn not null,
+ modified date default(sysdate)
+ constraint rhn_cst_modified_nn not null
+)
+ enable row movement
+ ;
+
+create sequence rhn_content_source_type_id_seq start with 500;
+
+create index rhn_ccst_id_l_idx
+ on rhnContentSourceType(id,label)
+ tablespace [[64k_tbs]]
+ ;
+
+show errors
+
+--
+-- Revision 1.0 2002/11/13 21:50:21 jlsherrill
+-- initial table add
+--
diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql
new file mode 100644
index 0000000..db3424c
--- /dev/null
+++ b/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql
@@ -0,0 +1,21 @@
+--
+-- Copyright (c) 2008 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.
+--
+--
+--
+--
+
+insert into rhnContentSourceType (id, label) values
+(rhn_content_source_type_id_seq.nextval, 'yum');
+
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql
new file mode 100644
index 0000000..546a3e1
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql
@@ -0,0 +1,46 @@
+--
+-- Copyright (c) 2008 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 table
+rhnContentSourceType
+(
+ id number
+ constraint rhn_cst_id_nn not null
+ constraint rhn_cst_id_pk primary key,
+ label varchar2(32)
+ constraint rhn_cst_label_nn not null
+ constraint rhn_cst_label_uq unique,
+ created date default(sysdate)
+ constraint rhn_cst_created_nn not null,
+ modified date default(sysdate)
+ constraint rhn_cst_modified_nn not null
+)
+ enable row movement
+ ;
+
+create sequence rhn_content_source_type_id_seq start with 500;
+
+create index rhn_ccst_id_l_idx
+ on rhnContentSourceType(id,label)
+ tablespace [[64k_tbs]]
+ ;
+
+
+insert into rhnContentSourceType (id, label) values
+(rhn_content_source_type_id_seq.nextval, 'yum');
+
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
new file mode 100644
index 0000000..a1445e1
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql
@@ -0,0 +1,55 @@
+--
+-- Copyright (c) 2008 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 table
+rhnChannelContentSource
+(
+ id number
+ constraint rhn_ccs_id_nn not null
+ constraint rhn_ccs_id_pk primary key,
+ channel_id number
+ constraint rhn_ccs_c_nn not null
+ constraint rhn_ccs_c_fk
+ references rhnChannel(id) on delete cascade,
+ type_id number
+ constraint rhn_ccs_type_nn not null
+ constraint rhn_ccs_type_fk
+ references rhnContentSourceType(id),
+ source_url varchar2(512)
+ constraint rhn_ccs_url_nn not null,
+ last_synced date,
+ created date default(sysdate)
+ constraint rhn_ccs_cre_nn not null,
+ modified date default(sysdate)
+ constraint rhn_ccs_mod_nn not null
+)
+ enable row movement
+ ;
+
+
+create sequence rhn_chan_content_src_id_seq start with 500;
+
+
+create unique index rhn_ccs_uq
+ on rhnChannelContentSource(channel_id, type_id, source_url)
+ tablespace [[64k_tbs]]
+ ;
+
+/
+show errors
+
14 years, 8 months
Branch 'repo-sync' - 4 commits - backend/server client/tools java/code schema/spacewalk
by Justin Sherrill
backend/server/action/configfiles.py | 3
backend/server/configFilesHandler.py | 1
backend/server/handlers/config/rhn_config_management.py | 3
backend/server/handlers/config_mgmt/rhn_config_management.py | 6 -
client/tools/rhncfg/config_common/transactions.py | 20 ++--
client/tools/rhncfg/rhncfg.spec | 1
java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml | 4
java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml | 1
java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java | 17 +++
java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java | 19 ++-
java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java | 4
java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java | 3
java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd | 6 +
java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java | 11 +-
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 7 +
java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java | 1
java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java | 1
java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java | 2
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java | 1
java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java | 32 ++++++
java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java | 2
java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf | 5 +
java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf | 5 +
java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf | 15 +++
java/code/webapp/WEB-INF/struts-config.xml | 1
schema/spacewalk/common/tables/rhnConfigInfo.sql | 23 ++--
schema/spacewalk/oracle/procs/lookup_config_info.sql | 10 +-
schema/spacewalk/postgres/procs/lookup_config_info.sql | 10 +-
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql | 48 ++++++++++
29 files changed, 217 insertions(+), 45 deletions(-)
New commits:
commit b397990514e0aed7cfcb77d5ea83a60664ea51b9
Merge: c273e9e... 074cca0...
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Aug 3 14:06:12 2009 -0400
Merge branch 'master' into repo-sync
commit 074cca0508e8d6b4817453f45b2bfada62ed8623
Author: Joshua Roys <joshua.roys(a)gtri.gatech.edu>
Date: Mon Aug 3 13:25:08 2009 -0400
upgrade script for the previous commit. Patch from Joshua Roys
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql
new file mode 100644
index 0000000..f348e11
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql
@@ -0,0 +1,48 @@
+--
+-- Add in a column for selinux context
+--
+
+ALTER TABLE rhnConfigInfo
+ ADD selinux_ctx VARCHAR(64);
+
+DROP INDEX RHN_CONFINFO_UGF_UQ;
+
+CREATE UNIQUE INDEX rhn_confinfo_ugf_uq
+ ON rhnConfigInfo( username, groupname, filemode, selinux_ctx )
+ tablespace [[4m_tbs]]
+ ;
+
+CREATE OR REPLACE FUNCTION
+lookup_config_info (
+ username_in IN VARCHAR2,
+ groupname_in IN VARCHAR2,
+ filemode_in IN VARCHAR2,
+ selinux_ctx_in IN VARCHAR2
+) RETURN NUMBER
+DETERMINISTIC
+IS
+ PRAGMA AUTONOMOUS_TRANSACTION;
+ v_id NUMBER;
+ CURSOR lookup_cursor IS
+ SELECT id
+ FROM rhnConfigInfo
+ WHERE 1=1
+ AND username = username_in
+ AND groupname = groupname_in
+ AND filemode = filemode_in
+ AND selinux_ctx = selinux_ctx_in;
+BEGIN
+ FOR r IN lookup_cursor LOOP
+ RETURN r.id;
+ END LOOP;
+ -- If we got here, we don't have the id
+ SELECT rhn_confinfo_id_seq.nextval
+ INTO v_id
+ FROM dual;
+ INSERT INTO rhnConfigInfo (id, username, groupname, filemode, selinux_ctx)
+ VALUES (v_id, username_in, groupname_in, filemode_in, selinux_ctx_in);
+ COMMIT;
+ RETURN v_id;
+END lookup_config_info;
+/
+show errors
commit 40785d998874d7e9b022a79a8322bce09af8ac3f
Author: Joshua Roys <joshua.roys(a)gtri.gatech.edu>
Date: Mon Aug 3 13:21:21 2009 -0400
Patch: Selinux Context support for config files
diff --git a/backend/server/action/configfiles.py b/backend/server/action/configfiles.py
index 746a194..db91ca7 100644
--- a/backend/server/action/configfiles.py
+++ b/backend/server/action/configfiles.py
@@ -122,7 +122,8 @@ _query_get_files = rhnSQL.Statement("""
ci.username,
ci.groupname,
ci.filemode,
- cft.label
+ cft.label,
+ ci.selinux_ctx
from
rhnConfigFileState cfs,
rhnConfigContent ccont,
diff --git a/backend/server/configFilesHandler.py b/backend/server/configFilesHandler.py
index 2ac83b8..996d221 100644
--- a/backend/server/configFilesHandler.py
+++ b/backend/server/configFilesHandler.py
@@ -499,4 +499,5 @@ def format_file_results(row, server=None):
'filemode' : row['filemode'],
'encoding' : encoding,
'filetype' : row['label'],
+ 'selinux_ctx' : row['selinux_ctx'] or '',
}
diff --git a/backend/server/handlers/config/rhn_config_management.py b/backend/server/handlers/config/rhn_config_management.py
index 4b16fa9..47834bd 100644
--- a/backend/server/handlers/config/rhn_config_management.py
+++ b/backend/server/handlers/config/rhn_config_management.py
@@ -169,7 +169,8 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
ci.groupname,
ci.filemode,
cft.label,
- cct.priority
+ cct.priority,
+ ci.selinux_ctx
from rhnConfigChannel cc,
rhnConfigInfo ci,
rhnConfigRevision cr,
diff --git a/backend/server/handlers/config_mgmt/rhn_config_management.py b/backend/server/handlers/config_mgmt/rhn_config_management.py
index ff2046f..90a9983 100644
--- a/backend/server/handlers/config_mgmt/rhn_config_management.py
+++ b/backend/server/handlers/config_mgmt/rhn_config_management.py
@@ -260,7 +260,8 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
ci.username,
ci.groupname,
ci.filemode,
- cft.label
+ cft.label,
+ ci.selinux_ctx
from rhnConfigChannel cc,
rhnConfigInfo ci,
rhnConfigRevision cr,
@@ -289,7 +290,8 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
ci.username,
ci.groupname,
ci.filemode,
- cft.label
+ cft.label,
+ ci.selinux_ctx
from rhnConfigChannel cc,
rhnConfigInfo ci,
rhnConfigRevision cr,
diff --git a/client/tools/rhncfg/config_common/transactions.py b/client/tools/rhncfg/config_common/transactions.py
index 9f87700..cdd7ac0 100644
--- a/client/tools/rhncfg/config_common/transactions.py
+++ b/client/tools/rhncfg/config_common/transactions.py
@@ -25,6 +25,7 @@ import string
from config_common import file_utils, utils, cfg_exceptions
from config_common.rhn_log import log_debug
+from selinux import setfilecon
class TargetNotFile(Exception): pass
class DuplicateDeployment(Exception): pass
@@ -102,7 +103,7 @@ class DeployTransaction:
def deploy_callback(self, cb):
self.deployment_cb = cb
- def _chown_chmod(self, temp_file_path, dest_path, file_info, strict_ownership=1):
+ def _chown_chmod_chcon(self, temp_file_path, dest_path, file_info, strict_ownership=1):
uid = file_info.get('uid')
if uid is None:
if file_info.has_key('username'):
@@ -142,6 +143,13 @@ class DeployTransaction:
mode = string.atoi(str(mode), 8)
os.chmod(temp_file_path, mode)
+ if file_info.has_key('selinux_ctx'):
+ sectx = file_info.get('selinux_ctx')
+ if sectx is not None:
+ log_debug(1, "selinux context: " + sectx);
+ if setfilecon(temp_file_path, sectx) < 0:
+ raise Exception("failed to set selinux context on %s" % dest_path)
+
except OSError, e:
if e.errno == errno.EPERM and not strict_ownership:
sys.stderr.write("cannonical file ownership and permissions lost on %s\n" % dest_path)
@@ -170,7 +178,7 @@ class DeployTransaction:
if file_info.get('filetype') == 'directory':
self.dirs.append(file_info)
else:
- self._chown_chmod(processed_file_path, dest_path, file_info, strict_ownership=strict_ownership)
+ self._chown_chmod_chcon(processed_file_path, dest_path, file_info, strict_ownership=strict_ownership)
if self.newtemp_by_path.has_key(dest_path):
raise DuplicateDeployment("Error: %s already added to transaction" % dest_path)
@@ -221,7 +229,7 @@ class DeployTransaction:
#revert the owner/perms of any directories that we changed
for d, val in self.changed_dir_info.items():
log_debug(6, "reverting owner and perms of %s" % d)
- self._chown_chmod(d, d, val)
+ self._chown_chmod_chcon(d, d, val)
log_debug(9, "directory reverted")
#remove any directories created by either mkdir_p or in the deploy
@@ -271,12 +279,12 @@ class DeployTransaction:
entry["gid"] = s[5]
self.changed_dir_info[dirname] = entry
log_debug(3, "directory found, chowning and chmoding to %s as needed: %s" % (dirmode, dirname))
- self._chown_chmod(dirname, dirname, directory)
+ self._chown_chmod_chcon(dirname, dirname, directory)
else:
log_debug(3, "directory not found, creating: %s" % dirname)
dirs_created = utils.mkdir_p(dirname)
self.new_dirs.extend(dirs_created)
- self._chown_chmod(dirname, dirname, directory)
+ self._chown_chmod_chcon(dirname, dirname, directory)
if self.deployment_cb:
self.deployment_cb(dirname)
@@ -315,7 +323,7 @@ class DeployTransaction:
self.new_dirs.extend(temp_new_dirs or [])
# properly chown and chmod it
- self._chown_chmod(self.newtemp_by_path[path], path, dep_file)
+ self._chown_chmod_chcon(self.newtemp_by_path[path], path, dep_file)
log_debug(9, "tempfile written: %s" % self.newtemp_by_path[path])
diff --git a/client/tools/rhncfg/rhncfg.spec b/client/tools/rhncfg/rhncfg.spec
index 8fd9b84..c1162ea 100644
--- a/client/tools/rhncfg/rhncfg.spec
+++ b/client/tools/rhncfg/rhncfg.spec
@@ -14,6 +14,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: docbook-utils
BuildRequires: python
+Requires: libselinux-python
Requires: python
Requires: rhnlib
Provides: rhn-config-action = %{version}
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml
index 84f43dc..dc5c208 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml
@@ -991,8 +991,8 @@ ORDER BY CCon.modified DESC
</mode>
<callable-mode name="lookup_config_info">
- <query params="username_in, groupname_in, filemode_in">
- {:info_id = call lookup_config_info( :username_in, :groupname_in, :filemode_in )}
+ <query params="username_in, groupname_in, filemode_in, selinuxCtx_in">
+ {:info_id = call lookup_config_info( :username_in, :groupname_in, :filemode_in, :selinuxCtx_in )}
</query>
</callable-mode>
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml
index 9aaa100..8895581 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml
@@ -17,6 +17,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="filemode" column="filemode" type="long" />
<property name="created" column="created" type="timestamp" />
<property name="modified" column="modified" type="timestamp" />
+ <property name="selinuxCtx" column="selinux_ctx" type="string" length="64" />
</class>
<query name="ConfigInfo.findWithoutId">
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java
index fcef54f..ca12cfb 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java
@@ -26,6 +26,7 @@ public class ConfigInfo extends BaseDomainHelper {
private String username;
private String groupname;
private Long filemode;
+ private String selinuxCtx;
/**
* protected constructor
@@ -98,4 +99,20 @@ public class ConfigInfo extends BaseDomainHelper {
public void setFilemode(Long filemodeIn) {
this.filemode = filemodeIn;
}
+
+ /**
+ * Getter for selinux context
+ * @return String to get
+ */
+ public String getSelinuxCtx() {
+ return this.selinuxCtx;
+ }
+
+ /**
+ * Setter for selinux context
+ * @param ctxIn to set
+ */
+ public void setSelinuxCtx(String ctxIn) {
+ this.selinuxCtx = ctxIn;
+ }
}
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
index 4eabe31..c20a891 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
@@ -294,13 +294,14 @@ public class ConfigurationFactory extends HibernateFactory {
commit(file);
}
else {
- //ConfigInfos have a unique constraint for their three data fields.
+ //ConfigInfos have a unique constraint for their four data fields.
//The config info object associated with this revision may have been
//changed, so we need to carefully not update the database record.
ConfigInfo info = lookupOrInsertConfigInfo(
revision.getConfigInfo().getUsername(),
revision.getConfigInfo().getGroupname(),
- revision.getConfigInfo().getFilemode());
+ revision.getConfigInfo().getFilemode(),
+ revision.getConfigInfo().getSelinuxCtx());
//if the object did not change, we now have two hibernate objects
//with the same identifier. Evict one so that hibernate doesn't get mad.
getSession().evict(revision.getConfigInfo());
@@ -456,8 +457,8 @@ public class ConfigurationFactory extends HibernateFactory {
}
/**
- * Return a <code>ConfigInfo</code> for the username, groupname, and
- * file mode given. If no corresponding entry exists yet in the database, one will be
+ * Return a <code>ConfigInfo</code> from the username, groupname, file mode, and
+ * selinux context. If no corresponding entry exists yet in the database, one will be
* created.
*
* Uses the stored procedure <code>lookup_config_info</code> to get the id of the
@@ -475,11 +476,12 @@ public class ConfigurationFactory extends HibernateFactory {
* @param username The linux username associated with a file
* @param groupname The linux groupname associated with a file
* @param filemode The three digit file mode (ex: 655)
+ * @param selinuxCtx The SELinux context
* @return The ConfigInfo found or inserted.
*/
public static ConfigInfo lookupOrInsertConfigInfo(String username,
- String groupname, Long filemode) {
- Long id = lookupConfigInfo(username, groupname, filemode);
+ String groupname, Long filemode, String selinuxCtx) {
+ Long id = lookupConfigInfo(username, groupname, filemode, selinuxCtx);
return lookupConfigInfoById(id);
}
@@ -489,9 +491,11 @@ public class ConfigurationFactory extends HibernateFactory {
* @param user The linux username associated with a file
* @param group The linux groupname associated with a file
* @param filemode The three digit file mode (ex: 655)
+ * @param selinuxCtx The SELinux context
* @return The id of the found config info
*/
- private static Long lookupConfigInfo(String user, String group, Long filemode) {
+ private static Long lookupConfigInfo(String user, String group,
+ Long filemode, String selinuxCtx) {
CallableMode m = ModeFactory.getCallableMode("config_queries",
"lookup_config_info");
@@ -501,6 +505,7 @@ public class ConfigurationFactory extends HibernateFactory {
inParams.put("username_in", user);
inParams.put("groupname_in", group);
inParams.put("filemode_in", filemode);
+ inParams.put("selinuxCtx_in", selinuxCtx);
outParams.put("info_id", new Integer(Types.NUMERIC));
Map out = m.execute(inParams, outParams);
diff --git a/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java b/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java
index 3f35c2b..1afdefe 100644
--- a/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java
@@ -151,9 +151,9 @@ public class ConfigurationFactoryTest extends RhnBaseTestCase {
//one problem is that looking up the same thing must be done in such a way that
//hibernate doesn't yell about it.
ConfigInfo info1 = ConfigurationFactory.lookupOrInsertConfigInfo("testman",
- "testgroup", new Long(665));
+ "testgroup", new Long(665), "");
ConfigInfo info2 = ConfigurationFactory.lookupOrInsertConfigInfo("testman",
- "testgroup", new Long(665));
+ "testgroup", new Long(665), "");
assertNotNull(info1.getId());
assertNotNull(info2.getId());
assertEquals(info1.getId(), info2.getId());
diff --git a/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java b/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
index 22440ab..d716da4 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
@@ -57,6 +57,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
public static final String REV_UID = "cffUid";
public static final String REV_GID = "cffGid";
public static final String REV_PERMS = "cffPermissions";
+ public static final String REV_SELINUX_CTX = "cffSELinuxCtx";
public static final String REV_MACROSTART = "cffMacroStart";
public static final String REV_MACROEND = "cffMacroEnd";
public static final String REV_CONTENTS = "contents"; //cffContent
@@ -158,6 +159,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
Long mode = cr.getConfigInfo().getFilemode();
String modeStr = new DecimalFormat("000").format(mode.longValue());
set(ConfigFileForm.REV_PERMS, modeStr);
+ set(ConfigFileForm.REV_SELINUX_CTX, cr.getConfigInfo().getSelinuxCtx());
set(ConfigFileForm.REV_UID, cr.getConfigInfo().getUsername());
set(ConfigFileForm.REV_GID, cr.getConfigInfo().getGroupname());
set(ConfigFileForm.REV_BINARY, new Boolean(cr.getConfigContent().isBinary()));
@@ -310,6 +312,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
data.setGroup(getString(REV_GID));
data.setOwner(getString(REV_UID));
data.setPermissions(getString(REV_PERMS));
+ data.setSelinuxCtx(getString(REV_SELINUX_CTX));
data.setType(extractFileType());
return data;
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd b/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd
index 3732ee8..c2c6eba 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd
+++ b/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd
@@ -20,6 +20,12 @@
<maxLength value="4" />
</simpleType>
</attribute>
+ <attribute name="cffSELinuxCtx">
+ <simpleType baseType="string">
+ <minLength value="0" />
+ <maxLength value="64" />
+ </simpleType>
+ </attribute>
<attribute name="cffMacroStart">
<simpleType baseType="string">
<minLength value="1" />
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 4b67e78..c481649 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -13928,7 +13928,12 @@ centrally-managed configuration channel, {2}; below is a list of systems you may
<context context-type="sourcefile">/rhn/configuration/FileDetails.do</context>
</context-group>
</trans-unit>
-
+ <trans-unit id="filedetails.jsp.tip.selinux">
+<source><strong>Tip:</strong> Enter SELinux context like: user_u:role_r:type_t:s0-s15:c0.c1024 (Note: you don't have to enter all parts)</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/configuration/FileDetails.do</context>
+ </context-group>
+ </trans-unit>
<!-- form error messages -->
<trans-unit id="config-file-form.error.user-invalid">
<source>User must be a valid Linux user name or user id, of 32 characters or less.</source>
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
index df4416e..2ac091e 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
@@ -265,6 +265,7 @@ public class ConfigChannelHandler extends BaseHandler {
validKeys.add("owner");
validKeys.add("group");
validKeys.add("permissions");
+ validKeys.add("selinux_ctx");
validKeys.add("macro-start-delimiter");
validKeys.add("macro-end-delimiter");
validateMap(validKeys, data);
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java
index 4604b2d..df3d61c 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java
@@ -139,6 +139,7 @@ public class XmlRpcConfigChannelHelper {
form.setOwner((String)data.get(ConfigRevisionSerializer.OWNER));
form.setGroup((String)data.get(ConfigRevisionSerializer.GROUP));
form.setPermissions((String)data.get(ConfigRevisionSerializer.PERMISSIONS));
+ form.setSelinuxCtx((String)data.get(ConfigRevisionSerializer.SELINUX_CTX));
ConfigFileBuilder helper = ConfigFileBuilder.getInstance();
try {
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java
index 4786027..d8b755e 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java
@@ -62,6 +62,7 @@ public class ConfigRevisionSerializer implements XmlRpcCustomSerializer {
public static final String PATH = "path";
public static final String OWNER = "owner";
public static final String GROUP = "group";
+ public static final String SELINUX_CTX = "selinux_ctx";
public static final String PERMISSIONS = "permissions";
public static final String PERMISSIONS_MODE = "permissions_mode";
public static final String MACRO_START = "macro-start-delimiter";
@@ -101,6 +102,7 @@ public class ConfigRevisionSerializer implements XmlRpcCustomSerializer {
helper.add("revision", rev.getRevision());
helper.add("creation", rev.getCreated());
helper.add("modified", rev.getModified());
+ helper.add(SELINUX_CTX, rev.getConfigInfo().getSelinuxCtx());
helper.add(OWNER, rev.getConfigInfo().getUsername());
helper.add(GROUP, rev.getConfigInfo().getGroupname());
helper.add(PERMISSIONS, rev.getConfigInfo().getFilemode());
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
index 364dc09..b5dcab0 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
@@ -165,6 +165,7 @@ public class ServerConfigHandler extends BaseHandler {
validKeys.add("owner");
validKeys.add("group");
validKeys.add("permissions");
+ validKeys.add("selinux_ctx");
validKeys.add("macro-start-delimiter");
validKeys.add("macro-end-delimiter");
validateMap(validKeys, data);
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java b/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
index 102e986..d414f1e 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
@@ -49,6 +49,7 @@ public abstract class ConfigFileData {
private String owner;
private String group;
private String permissions;
+ private String selinuxCtx;
private String macroStart;
private String macroEnd;
@@ -71,6 +72,7 @@ public abstract class ConfigFileData {
setPermissions("644");
setOwner("root");
setGroup("root");
+ setSelinuxCtx("");
setType(ConfigFileType.file());
setMacroStart(DEFAULT_MACRO_START);
setMacroEnd(DEFAULT_MACRO_END);
@@ -131,6 +133,20 @@ public abstract class ConfigFileData {
public void setPermissions(String perms) {
this.permissions = perms;
}
+
+ /**
+ * @return the SELinux context
+ */
+ public String getSelinuxCtx() {
+ return selinuxCtx;
+ }
+
+ /**
+ * @param context the SELinux context to set
+ */
+ public void setSelinuxCtx(String context) {
+ this.selinuxCtx = context;
+ }
/**
* @return the macroStart
@@ -188,7 +204,8 @@ public abstract class ConfigFileData {
public ConfigInfo extractInfo() {
ConfigInfo info = ConfigurationFactory.lookupOrInsertConfigInfo(
getOwner(), getGroup(),
- Long.valueOf(getPermissions()));
+ Long.valueOf(getPermissions()),
+ getSelinuxCtx());
return info;
}
@@ -232,6 +249,17 @@ public abstract class ConfigFileData {
if (!getPermissions().matches("^[0-7][0-7][0-7][0-7]?$")) {
msgs.addError(error("mode-invalid"));
}
+
+ // Validate selinux context
+ if (!getSelinuxCtx().matches(
+ // \\w is [a-zA-Z_0-9], or [_[:alnum:]]
+ "^\\w*" + // user
+ "(:\\w*" + // role
+ "(:\\w*" + // type
+ "(:\\w*(\\-\\w+)?" + // sensitivity
+ "(:\\w*(\\.\\w+))?)?)?)?$")) { // category
+ msgs.addError(new ValidatorError("Invalid SELinux context"));
+ }
if (!StringUtils.isBlank(getMacroStart())) {
// Validate macro-start
@@ -327,6 +355,7 @@ public abstract class ConfigFileData {
map.put(ConfigFileForm.REV_UID, getOwner());
map.put(ConfigFileForm.REV_GID, getGroup());
map.put(ConfigFileForm.REV_PERMS, getPermissions());
+ map.put(ConfigFileForm.REV_SELINUX_CTX, getSelinuxCtx());
map.put(ConfigFileForm.REV_MACROSTART, getMacroStart());
map.put(ConfigFileForm.REV_MACROEND, getMacroEnd());
return map;
@@ -363,6 +392,7 @@ public abstract class ConfigFileData {
append("Owner", getOwner()).
append("Group", getGroup()).
append("Permissions", getPermissions()).
+ append("SELinux Context", getSelinuxCtx()).
append("Type", getType()).
append("Macro Start", getMacroStart()).
append("Macro End", getMacroEnd()).
diff --git a/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java b/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java
index a28cd2f..f547dd8 100644
--- a/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java
+++ b/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java
@@ -307,7 +307,7 @@ public class ConfigTestUtils extends Assert {
* @return The newly created ConfigInfo.
*/
public static ConfigInfo createConfigInfo(String user, String group, Long fileMode) {
- return ConfigurationFactory.lookupOrInsertConfigInfo(user, group, fileMode);
+ return ConfigurationFactory.lookupOrInsertConfigInfo(user, group, fileMode, "");
}
/**
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf
index 2eeddbe..0bbaad9 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf
@@ -43,6 +43,11 @@
key="filedetails.jsp.tip.permissions" /></span></td>
</tr>
<tr>
+ <th>SELinux context</th>
+ <td><html:text property="cffSELinuxCtx" size="30" /><br />
+ <span class="small-text"><bean:message key="filedetails.jsp.tip.selinux" /></span></td>
+ </tr>
+ <tr>
<th><bean:message key="filedetails.add_details.jspf.macro" /></th>
<td nowrap="nowrap">
<bean:message key="filedetails.add_details.jspf.macro.start" />
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf
index 13a20c7..e01f323 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf
@@ -48,6 +48,11 @@
key="filedetails.jsp.tip.permissions" /></span></td>
</tr>
<tr>
+ <th>SELinux context</th>
+ <td><html:text property="cffSELinuxCtx" size="30" /><br />
+ <span class="small-text"><bean:message key="filedetails.jsp.tip.selinux" /></span></td>
+ </tr>
+ <tr>
<th><bean:message key="filedetails.add_details.jspf.macro" /></th>
<td nowrap="nowrap">
<bean:message key="filedetails.add_details.jspf.macro.start" />
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf
index 054aadc..cce3995 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf
@@ -53,4 +53,19 @@
<span class="small-text"><bean:message key="filedetails.jsp.tip.permissions" /></span>
</td>
</tr>
+<tr>
+ <th>SELinux context</th>
+ <td>
+ <rhn:require acl="config_channel_editable(${channel.id})"
+ mixins="com.redhat.rhn.common.security.acl.ConfigAclHandler">
+ <html:text property="cffSELinuxCtx" size="24" />
+ </rhn:require>
+ <rhn:require acl="not config_channel_editable(${channel.id})"
+ mixins="com.redhat.rhn.common.security.acl.ConfigAclHandler">
+ ${form.map.cffSELinuxCtx}
+ </rhn:require>
+ <br />
+ <span class="small-text"><bean:message key="filedetails.jsp.tip.selinux" /></span>
+ </td>
+</tr>
</table>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 7a26013..a4d0c32 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -867,6 +867,7 @@
<form-property name="cffPath" type="java.lang.String"/>
<form-property name="cffUid" type="java.lang.String"/>
<form-property name="cffGid" type="java.lang.String"/>
+ <form-property name="cffSELinuxCtx" type="java.lang.String"/>
<form-property name="cffPermissions" type="java.lang.String"/>
<form-property name="cffMacroStart" type="java.lang.String"/>
<form-property name="cffMacroEnd" type="java.lang.String"/>
diff --git a/schema/spacewalk/common/tables/rhnConfigInfo.sql b/schema/spacewalk/common/tables/rhnConfigInfo.sql
index 17786c4..bb62b09 100644
--- a/schema/spacewalk/common/tables/rhnConfigInfo.sql
+++ b/schema/spacewalk/common/tables/rhnConfigInfo.sql
@@ -16,22 +16,23 @@
CREATE TABLE rhnConfigInfo
(
- id NUMBER NOT NULL
- CONSTRAINT rhn_confinfo_id_pk PRIMARY KEY
- USING INDEX TABLESPACE [[2m_tbs]],
- username VARCHAR2(32) NOT NULL,
- groupname VARCHAR2(32) NOT NULL,
- filemode NUMBER NOT NULL,
- created DATE
- DEFAULT (sysdate) NOT NULL,
- modified DATE
- DEFAULT (sysdate) NOT NULL
+ id NUMBER NOT NULL
+ CONSTRAINT rhn_confinfo_id_pk PRIMARY KEY
+ USING INDEX TABLESPACE [[2m_tbs]],
+ username VARCHAR2(32) NOT NULL,
+ groupname VARCHAR2(32) NOT NULL,
+ filemode NUMBER NOT NULL,
+ created DATE
+ DEFAULT (sysdate) NOT NULL,
+ modified DATE
+ DEFAULT (sysdate) NOT NULL,
+ selinux_ctx VARCHAR2(64)
)
ENABLE ROW MOVEMENT
;
CREATE UNIQUE INDEX rhn_confinfo_ugf_uq
- ON rhnConfigInfo (username, groupname, filemode)
+ ON rhnConfigInfo (username, groupname, filemode, selinux_ctx)
TABLESPACE [[4m_tbs]];
CREATE SEQUENCE rhn_confinfo_id_seq;
diff --git a/schema/spacewalk/oracle/procs/lookup_config_info.sql b/schema/spacewalk/oracle/procs/lookup_config_info.sql
index 9255b89..65e238b 100644
--- a/schema/spacewalk/oracle/procs/lookup_config_info.sql
+++ b/schema/spacewalk/oracle/procs/lookup_config_info.sql
@@ -20,7 +20,8 @@ create or replace function
lookup_config_info (
username_in in varchar2,
groupname_in in varchar2,
- filemode_in in varchar2
+ filemode_in in varchar2,
+ selinux_ctx_in in varchar2
) return number
deterministic
is
@@ -32,7 +33,8 @@ is
where 1=1
and username = username_in
and groupname = groupname_in
- and filemode = filemode_in;
+ and filemode = filemode_in
+ and selinux_ctx = selinux_ctx_in;
begin
for r in lookup_cursor loop
return r.id;
@@ -41,8 +43,8 @@ begin
select rhn_confinfo_id_seq.nextval
into v_id
from dual;
- insert into rhnConfigInfo (id, username, groupname, filemode)
- values (v_id, username_in, groupname_in, filemode_in);
+ insert into rhnConfigInfo (id, username, groupname, filemode, selinux_ctx)
+ values (v_id, username_in, groupname_in, filemode_in, selinux_ctx_in);
commit;
return v_id;
end lookup_config_info;
diff --git a/schema/spacewalk/postgres/procs/lookup_config_info.sql b/schema/spacewalk/postgres/procs/lookup_config_info.sql
index 605c502..d307d74 100644
--- a/schema/spacewalk/postgres/procs/lookup_config_info.sql
+++ b/schema/spacewalk/postgres/procs/lookup_config_info.sql
@@ -18,7 +18,8 @@ lookup_config_info
(
username_in in varchar,
groupname_in in varchar,
- filemode_in in numeric
+ filemode_in in numeric,
+ selinux_ctx_in in varchar
)
returns numeric
as
@@ -31,7 +32,8 @@ declare
from rhnConfigInfo
where username = username_in
and groupname = groupname_in
- and filemode = filemode_in;
+ and filemode = filemode_in
+ and selinux_ctx = selinux_ctx_in;
begin
for r in lookup_cursor loop
return r.id;
@@ -39,8 +41,8 @@ begin
-- If we got here, we don't have the id
select nextval('rhn_confinfo_id_seq') into v_id;
insert into rhnConfigInfo
- (id, username, groupname, filemode)
- values (v_id, username_in, groupname_in, filemode_in);
+ (id, username, groupname, filemode, selinux_ctx)
+ values (v_id, username_in, groupname_in, filemode_in, selinux_ctx_in);
return v_id;
end;
$$ language plpgsql;
commit 3022ae5840f925a031c0200fb9820f3cc9004027
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Aug 3 13:08:04 2009 -0400
515219 - We can have a channel with null description. In the packagedetailsaction we call replace on description without checking if its a valid string resulting in Null Pointer Exception.
diff --git a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java
index 078fcb2..9bd7cb0 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java
@@ -100,8 +100,15 @@ public class PackageDetailsAction extends RhnAction {
}
request.setAttribute("pack", pkg);
- request.setAttribute("description",
- pkg.getDescription().replace("\n", "<BR>\n"));
+ // description can be null.
+ if (pkg.getDescription() != null) {
+ request.setAttribute("description",
+ pkg.getDescription().replace("\n", "<BR>\n"));
+ }
+ else {
+ request.setAttribute("description",
+ pkg.getDescription());
+ }
request.setAttribute("packArches",
PackageFactory.findPackagesWithDifferentArch(pkg));
request.setAttribute("pid", pid);
14 years, 8 months
schema/spacewalk
by Pradeep Kilambi
schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql | 48 ++++++++++
1 file changed, 48 insertions(+)
New commits:
commit 074cca0508e8d6b4817453f45b2bfada62ed8623
Author: Joshua Roys <joshua.roys(a)gtri.gatech.edu>
Date: Mon Aug 3 13:25:08 2009 -0400
upgrade script for the previous commit. Patch from Joshua Roys
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql
new file mode 100644
index 0000000..f348e11
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/150-rhnConfigInfo_selinux.sql
@@ -0,0 +1,48 @@
+--
+-- Add in a column for selinux context
+--
+
+ALTER TABLE rhnConfigInfo
+ ADD selinux_ctx VARCHAR(64);
+
+DROP INDEX RHN_CONFINFO_UGF_UQ;
+
+CREATE UNIQUE INDEX rhn_confinfo_ugf_uq
+ ON rhnConfigInfo( username, groupname, filemode, selinux_ctx )
+ tablespace [[4m_tbs]]
+ ;
+
+CREATE OR REPLACE FUNCTION
+lookup_config_info (
+ username_in IN VARCHAR2,
+ groupname_in IN VARCHAR2,
+ filemode_in IN VARCHAR2,
+ selinux_ctx_in IN VARCHAR2
+) RETURN NUMBER
+DETERMINISTIC
+IS
+ PRAGMA AUTONOMOUS_TRANSACTION;
+ v_id NUMBER;
+ CURSOR lookup_cursor IS
+ SELECT id
+ FROM rhnConfigInfo
+ WHERE 1=1
+ AND username = username_in
+ AND groupname = groupname_in
+ AND filemode = filemode_in
+ AND selinux_ctx = selinux_ctx_in;
+BEGIN
+ FOR r IN lookup_cursor LOOP
+ RETURN r.id;
+ END LOOP;
+ -- If we got here, we don't have the id
+ SELECT rhn_confinfo_id_seq.nextval
+ INTO v_id
+ FROM dual;
+ INSERT INTO rhnConfigInfo (id, username, groupname, filemode, selinux_ctx)
+ VALUES (v_id, username_in, groupname_in, filemode_in, selinux_ctx_in);
+ COMMIT;
+ RETURN v_id;
+END lookup_config_info;
+/
+show errors
14 years, 8 months
backend/server client/tools java/code schema/spacewalk
by Pradeep Kilambi
backend/server/action/configfiles.py | 3
backend/server/configFilesHandler.py | 1
backend/server/handlers/config/rhn_config_management.py | 3
backend/server/handlers/config_mgmt/rhn_config_management.py | 6 +
client/tools/rhncfg/config_common/transactions.py | 20 ++++--
client/tools/rhncfg/rhncfg.spec | 1
java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml | 4 -
java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml | 1
java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java | 17 +++++
java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java | 19 +++--
java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java | 4 -
java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java | 3
java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd | 6 +
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 7 +-
java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java | 1
java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java | 1
java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java | 2
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java | 1
java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java | 32 +++++++++-
java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java | 2
java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf | 5 +
java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf | 5 +
java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf | 15 ++++
java/code/webapp/WEB-INF/struts-config.xml | 1
schema/spacewalk/common/tables/rhnConfigInfo.sql | 23 +++----
schema/spacewalk/oracle/procs/lookup_config_info.sql | 10 +--
schema/spacewalk/postgres/procs/lookup_config_info.sql | 10 +--
27 files changed, 160 insertions(+), 43 deletions(-)
New commits:
commit 40785d998874d7e9b022a79a8322bce09af8ac3f
Author: Joshua Roys <joshua.roys(a)gtri.gatech.edu>
Date: Mon Aug 3 13:21:21 2009 -0400
Patch: Selinux Context support for config files
diff --git a/backend/server/action/configfiles.py b/backend/server/action/configfiles.py
index 746a194..db91ca7 100644
--- a/backend/server/action/configfiles.py
+++ b/backend/server/action/configfiles.py
@@ -122,7 +122,8 @@ _query_get_files = rhnSQL.Statement("""
ci.username,
ci.groupname,
ci.filemode,
- cft.label
+ cft.label,
+ ci.selinux_ctx
from
rhnConfigFileState cfs,
rhnConfigContent ccont,
diff --git a/backend/server/configFilesHandler.py b/backend/server/configFilesHandler.py
index 2ac83b8..996d221 100644
--- a/backend/server/configFilesHandler.py
+++ b/backend/server/configFilesHandler.py
@@ -499,4 +499,5 @@ def format_file_results(row, server=None):
'filemode' : row['filemode'],
'encoding' : encoding,
'filetype' : row['label'],
+ 'selinux_ctx' : row['selinux_ctx'] or '',
}
diff --git a/backend/server/handlers/config/rhn_config_management.py b/backend/server/handlers/config/rhn_config_management.py
index 4b16fa9..47834bd 100644
--- a/backend/server/handlers/config/rhn_config_management.py
+++ b/backend/server/handlers/config/rhn_config_management.py
@@ -169,7 +169,8 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
ci.groupname,
ci.filemode,
cft.label,
- cct.priority
+ cct.priority,
+ ci.selinux_ctx
from rhnConfigChannel cc,
rhnConfigInfo ci,
rhnConfigRevision cr,
diff --git a/backend/server/handlers/config_mgmt/rhn_config_management.py b/backend/server/handlers/config_mgmt/rhn_config_management.py
index ff2046f..90a9983 100644
--- a/backend/server/handlers/config_mgmt/rhn_config_management.py
+++ b/backend/server/handlers/config_mgmt/rhn_config_management.py
@@ -260,7 +260,8 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
ci.username,
ci.groupname,
ci.filemode,
- cft.label
+ cft.label,
+ ci.selinux_ctx
from rhnConfigChannel cc,
rhnConfigInfo ci,
rhnConfigRevision cr,
@@ -289,7 +290,8 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
ci.username,
ci.groupname,
ci.filemode,
- cft.label
+ cft.label,
+ ci.selinux_ctx
from rhnConfigChannel cc,
rhnConfigInfo ci,
rhnConfigRevision cr,
diff --git a/client/tools/rhncfg/config_common/transactions.py b/client/tools/rhncfg/config_common/transactions.py
index 9f87700..cdd7ac0 100644
--- a/client/tools/rhncfg/config_common/transactions.py
+++ b/client/tools/rhncfg/config_common/transactions.py
@@ -25,6 +25,7 @@ import string
from config_common import file_utils, utils, cfg_exceptions
from config_common.rhn_log import log_debug
+from selinux import setfilecon
class TargetNotFile(Exception): pass
class DuplicateDeployment(Exception): pass
@@ -102,7 +103,7 @@ class DeployTransaction:
def deploy_callback(self, cb):
self.deployment_cb = cb
- def _chown_chmod(self, temp_file_path, dest_path, file_info, strict_ownership=1):
+ def _chown_chmod_chcon(self, temp_file_path, dest_path, file_info, strict_ownership=1):
uid = file_info.get('uid')
if uid is None:
if file_info.has_key('username'):
@@ -142,6 +143,13 @@ class DeployTransaction:
mode = string.atoi(str(mode), 8)
os.chmod(temp_file_path, mode)
+ if file_info.has_key('selinux_ctx'):
+ sectx = file_info.get('selinux_ctx')
+ if sectx is not None:
+ log_debug(1, "selinux context: " + sectx);
+ if setfilecon(temp_file_path, sectx) < 0:
+ raise Exception("failed to set selinux context on %s" % dest_path)
+
except OSError, e:
if e.errno == errno.EPERM and not strict_ownership:
sys.stderr.write("cannonical file ownership and permissions lost on %s\n" % dest_path)
@@ -170,7 +178,7 @@ class DeployTransaction:
if file_info.get('filetype') == 'directory':
self.dirs.append(file_info)
else:
- self._chown_chmod(processed_file_path, dest_path, file_info, strict_ownership=strict_ownership)
+ self._chown_chmod_chcon(processed_file_path, dest_path, file_info, strict_ownership=strict_ownership)
if self.newtemp_by_path.has_key(dest_path):
raise DuplicateDeployment("Error: %s already added to transaction" % dest_path)
@@ -221,7 +229,7 @@ class DeployTransaction:
#revert the owner/perms of any directories that we changed
for d, val in self.changed_dir_info.items():
log_debug(6, "reverting owner and perms of %s" % d)
- self._chown_chmod(d, d, val)
+ self._chown_chmod_chcon(d, d, val)
log_debug(9, "directory reverted")
#remove any directories created by either mkdir_p or in the deploy
@@ -271,12 +279,12 @@ class DeployTransaction:
entry["gid"] = s[5]
self.changed_dir_info[dirname] = entry
log_debug(3, "directory found, chowning and chmoding to %s as needed: %s" % (dirmode, dirname))
- self._chown_chmod(dirname, dirname, directory)
+ self._chown_chmod_chcon(dirname, dirname, directory)
else:
log_debug(3, "directory not found, creating: %s" % dirname)
dirs_created = utils.mkdir_p(dirname)
self.new_dirs.extend(dirs_created)
- self._chown_chmod(dirname, dirname, directory)
+ self._chown_chmod_chcon(dirname, dirname, directory)
if self.deployment_cb:
self.deployment_cb(dirname)
@@ -315,7 +323,7 @@ class DeployTransaction:
self.new_dirs.extend(temp_new_dirs or [])
# properly chown and chmod it
- self._chown_chmod(self.newtemp_by_path[path], path, dep_file)
+ self._chown_chmod_chcon(self.newtemp_by_path[path], path, dep_file)
log_debug(9, "tempfile written: %s" % self.newtemp_by_path[path])
diff --git a/client/tools/rhncfg/rhncfg.spec b/client/tools/rhncfg/rhncfg.spec
index 8fd9b84..c1162ea 100644
--- a/client/tools/rhncfg/rhncfg.spec
+++ b/client/tools/rhncfg/rhncfg.spec
@@ -14,6 +14,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: docbook-utils
BuildRequires: python
+Requires: libselinux-python
Requires: python
Requires: rhnlib
Provides: rhn-config-action = %{version}
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml
index 84f43dc..dc5c208 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/config_queries.xml
@@ -991,8 +991,8 @@ ORDER BY CCon.modified DESC
</mode>
<callable-mode name="lookup_config_info">
- <query params="username_in, groupname_in, filemode_in">
- {:info_id = call lookup_config_info( :username_in, :groupname_in, :filemode_in )}
+ <query params="username_in, groupname_in, filemode_in, selinuxCtx_in">
+ {:info_id = call lookup_config_info( :username_in, :groupname_in, :filemode_in, :selinuxCtx_in )}
</query>
</callable-mode>
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml
index 9aaa100..8895581 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.hbm.xml
@@ -17,6 +17,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="filemode" column="filemode" type="long" />
<property name="created" column="created" type="timestamp" />
<property name="modified" column="modified" type="timestamp" />
+ <property name="selinuxCtx" column="selinux_ctx" type="string" length="64" />
</class>
<query name="ConfigInfo.findWithoutId">
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java
index fcef54f..ca12cfb 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigInfo.java
@@ -26,6 +26,7 @@ public class ConfigInfo extends BaseDomainHelper {
private String username;
private String groupname;
private Long filemode;
+ private String selinuxCtx;
/**
* protected constructor
@@ -98,4 +99,20 @@ public class ConfigInfo extends BaseDomainHelper {
public void setFilemode(Long filemodeIn) {
this.filemode = filemodeIn;
}
+
+ /**
+ * Getter for selinux context
+ * @return String to get
+ */
+ public String getSelinuxCtx() {
+ return this.selinuxCtx;
+ }
+
+ /**
+ * Setter for selinux context
+ * @param ctxIn to set
+ */
+ public void setSelinuxCtx(String ctxIn) {
+ this.selinuxCtx = ctxIn;
+ }
}
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
index 4eabe31..c20a891 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
@@ -294,13 +294,14 @@ public class ConfigurationFactory extends HibernateFactory {
commit(file);
}
else {
- //ConfigInfos have a unique constraint for their three data fields.
+ //ConfigInfos have a unique constraint for their four data fields.
//The config info object associated with this revision may have been
//changed, so we need to carefully not update the database record.
ConfigInfo info = lookupOrInsertConfigInfo(
revision.getConfigInfo().getUsername(),
revision.getConfigInfo().getGroupname(),
- revision.getConfigInfo().getFilemode());
+ revision.getConfigInfo().getFilemode(),
+ revision.getConfigInfo().getSelinuxCtx());
//if the object did not change, we now have two hibernate objects
//with the same identifier. Evict one so that hibernate doesn't get mad.
getSession().evict(revision.getConfigInfo());
@@ -456,8 +457,8 @@ public class ConfigurationFactory extends HibernateFactory {
}
/**
- * Return a <code>ConfigInfo</code> for the username, groupname, and
- * file mode given. If no corresponding entry exists yet in the database, one will be
+ * Return a <code>ConfigInfo</code> from the username, groupname, file mode, and
+ * selinux context. If no corresponding entry exists yet in the database, one will be
* created.
*
* Uses the stored procedure <code>lookup_config_info</code> to get the id of the
@@ -475,11 +476,12 @@ public class ConfigurationFactory extends HibernateFactory {
* @param username The linux username associated with a file
* @param groupname The linux groupname associated with a file
* @param filemode The three digit file mode (ex: 655)
+ * @param selinuxCtx The SELinux context
* @return The ConfigInfo found or inserted.
*/
public static ConfigInfo lookupOrInsertConfigInfo(String username,
- String groupname, Long filemode) {
- Long id = lookupConfigInfo(username, groupname, filemode);
+ String groupname, Long filemode, String selinuxCtx) {
+ Long id = lookupConfigInfo(username, groupname, filemode, selinuxCtx);
return lookupConfigInfoById(id);
}
@@ -489,9 +491,11 @@ public class ConfigurationFactory extends HibernateFactory {
* @param user The linux username associated with a file
* @param group The linux groupname associated with a file
* @param filemode The three digit file mode (ex: 655)
+ * @param selinuxCtx The SELinux context
* @return The id of the found config info
*/
- private static Long lookupConfigInfo(String user, String group, Long filemode) {
+ private static Long lookupConfigInfo(String user, String group,
+ Long filemode, String selinuxCtx) {
CallableMode m = ModeFactory.getCallableMode("config_queries",
"lookup_config_info");
@@ -501,6 +505,7 @@ public class ConfigurationFactory extends HibernateFactory {
inParams.put("username_in", user);
inParams.put("groupname_in", group);
inParams.put("filemode_in", filemode);
+ inParams.put("selinuxCtx_in", selinuxCtx);
outParams.put("info_id", new Integer(Types.NUMERIC));
Map out = m.execute(inParams, outParams);
diff --git a/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java b/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java
index 3f35c2b..1afdefe 100644
--- a/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/config/test/ConfigurationFactoryTest.java
@@ -151,9 +151,9 @@ public class ConfigurationFactoryTest extends RhnBaseTestCase {
//one problem is that looking up the same thing must be done in such a way that
//hibernate doesn't yell about it.
ConfigInfo info1 = ConfigurationFactory.lookupOrInsertConfigInfo("testman",
- "testgroup", new Long(665));
+ "testgroup", new Long(665), "");
ConfigInfo info2 = ConfigurationFactory.lookupOrInsertConfigInfo("testman",
- "testgroup", new Long(665));
+ "testgroup", new Long(665), "");
assertNotNull(info1.getId());
assertNotNull(info2.getId());
assertEquals(info1.getId(), info2.getId());
diff --git a/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java b/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
index 22440ab..d716da4 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
@@ -57,6 +57,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
public static final String REV_UID = "cffUid";
public static final String REV_GID = "cffGid";
public static final String REV_PERMS = "cffPermissions";
+ public static final String REV_SELINUX_CTX = "cffSELinuxCtx";
public static final String REV_MACROSTART = "cffMacroStart";
public static final String REV_MACROEND = "cffMacroEnd";
public static final String REV_CONTENTS = "contents"; //cffContent
@@ -158,6 +159,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
Long mode = cr.getConfigInfo().getFilemode();
String modeStr = new DecimalFormat("000").format(mode.longValue());
set(ConfigFileForm.REV_PERMS, modeStr);
+ set(ConfigFileForm.REV_SELINUX_CTX, cr.getConfigInfo().getSelinuxCtx());
set(ConfigFileForm.REV_UID, cr.getConfigInfo().getUsername());
set(ConfigFileForm.REV_GID, cr.getConfigInfo().getGroupname());
set(ConfigFileForm.REV_BINARY, new Boolean(cr.getConfigContent().isBinary()));
@@ -310,6 +312,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
data.setGroup(getString(REV_GID));
data.setOwner(getString(REV_UID));
data.setPermissions(getString(REV_PERMS));
+ data.setSelinuxCtx(getString(REV_SELINUX_CTX));
data.setType(extractFileType());
return data;
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd b/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd
index 3732ee8..c2c6eba 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd
+++ b/java/code/src/com/redhat/rhn/frontend/action/configuration/validation/configFileForm.xsd
@@ -20,6 +20,12 @@
<maxLength value="4" />
</simpleType>
</attribute>
+ <attribute name="cffSELinuxCtx">
+ <simpleType baseType="string">
+ <minLength value="0" />
+ <maxLength value="64" />
+ </simpleType>
+ </attribute>
<attribute name="cffMacroStart">
<simpleType baseType="string">
<minLength value="1" />
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 4b67e78..c481649 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -13928,7 +13928,12 @@ centrally-managed configuration channel, {2}; below is a list of systems you may
<context context-type="sourcefile">/rhn/configuration/FileDetails.do</context>
</context-group>
</trans-unit>
-
+ <trans-unit id="filedetails.jsp.tip.selinux">
+<source><strong>Tip:</strong> Enter SELinux context like: user_u:role_r:type_t:s0-s15:c0.c1024 (Note: you don't have to enter all parts)</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/configuration/FileDetails.do</context>
+ </context-group>
+ </trans-unit>
<!-- form error messages -->
<trans-unit id="config-file-form.error.user-invalid">
<source>User must be a valid Linux user name or user id, of 32 characters or less.</source>
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
index df4416e..2ac091e 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
@@ -265,6 +265,7 @@ public class ConfigChannelHandler extends BaseHandler {
validKeys.add("owner");
validKeys.add("group");
validKeys.add("permissions");
+ validKeys.add("selinux_ctx");
validKeys.add("macro-start-delimiter");
validKeys.add("macro-end-delimiter");
validateMap(validKeys, data);
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java
index 4604b2d..df3d61c 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/XmlRpcConfigChannelHelper.java
@@ -139,6 +139,7 @@ public class XmlRpcConfigChannelHelper {
form.setOwner((String)data.get(ConfigRevisionSerializer.OWNER));
form.setGroup((String)data.get(ConfigRevisionSerializer.GROUP));
form.setPermissions((String)data.get(ConfigRevisionSerializer.PERMISSIONS));
+ form.setSelinuxCtx((String)data.get(ConfigRevisionSerializer.SELINUX_CTX));
ConfigFileBuilder helper = ConfigFileBuilder.getInstance();
try {
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java
index 4786027..d8b755e 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigRevisionSerializer.java
@@ -62,6 +62,7 @@ public class ConfigRevisionSerializer implements XmlRpcCustomSerializer {
public static final String PATH = "path";
public static final String OWNER = "owner";
public static final String GROUP = "group";
+ public static final String SELINUX_CTX = "selinux_ctx";
public static final String PERMISSIONS = "permissions";
public static final String PERMISSIONS_MODE = "permissions_mode";
public static final String MACRO_START = "macro-start-delimiter";
@@ -101,6 +102,7 @@ public class ConfigRevisionSerializer implements XmlRpcCustomSerializer {
helper.add("revision", rev.getRevision());
helper.add("creation", rev.getCreated());
helper.add("modified", rev.getModified());
+ helper.add(SELINUX_CTX, rev.getConfigInfo().getSelinuxCtx());
helper.add(OWNER, rev.getConfigInfo().getUsername());
helper.add(GROUP, rev.getConfigInfo().getGroupname());
helper.add(PERMISSIONS, rev.getConfigInfo().getFilemode());
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
index 364dc09..b5dcab0 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
@@ -165,6 +165,7 @@ public class ServerConfigHandler extends BaseHandler {
validKeys.add("owner");
validKeys.add("group");
validKeys.add("permissions");
+ validKeys.add("selinux_ctx");
validKeys.add("macro-start-delimiter");
validKeys.add("macro-end-delimiter");
validateMap(validKeys, data);
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java b/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
index 102e986..d414f1e 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
@@ -49,6 +49,7 @@ public abstract class ConfigFileData {
private String owner;
private String group;
private String permissions;
+ private String selinuxCtx;
private String macroStart;
private String macroEnd;
@@ -71,6 +72,7 @@ public abstract class ConfigFileData {
setPermissions("644");
setOwner("root");
setGroup("root");
+ setSelinuxCtx("");
setType(ConfigFileType.file());
setMacroStart(DEFAULT_MACRO_START);
setMacroEnd(DEFAULT_MACRO_END);
@@ -131,6 +133,20 @@ public abstract class ConfigFileData {
public void setPermissions(String perms) {
this.permissions = perms;
}
+
+ /**
+ * @return the SELinux context
+ */
+ public String getSelinuxCtx() {
+ return selinuxCtx;
+ }
+
+ /**
+ * @param context the SELinux context to set
+ */
+ public void setSelinuxCtx(String context) {
+ this.selinuxCtx = context;
+ }
/**
* @return the macroStart
@@ -188,7 +204,8 @@ public abstract class ConfigFileData {
public ConfigInfo extractInfo() {
ConfigInfo info = ConfigurationFactory.lookupOrInsertConfigInfo(
getOwner(), getGroup(),
- Long.valueOf(getPermissions()));
+ Long.valueOf(getPermissions()),
+ getSelinuxCtx());
return info;
}
@@ -232,6 +249,17 @@ public abstract class ConfigFileData {
if (!getPermissions().matches("^[0-7][0-7][0-7][0-7]?$")) {
msgs.addError(error("mode-invalid"));
}
+
+ // Validate selinux context
+ if (!getSelinuxCtx().matches(
+ // \\w is [a-zA-Z_0-9], or [_[:alnum:]]
+ "^\\w*" + // user
+ "(:\\w*" + // role
+ "(:\\w*" + // type
+ "(:\\w*(\\-\\w+)?" + // sensitivity
+ "(:\\w*(\\.\\w+))?)?)?)?$")) { // category
+ msgs.addError(new ValidatorError("Invalid SELinux context"));
+ }
if (!StringUtils.isBlank(getMacroStart())) {
// Validate macro-start
@@ -327,6 +355,7 @@ public abstract class ConfigFileData {
map.put(ConfigFileForm.REV_UID, getOwner());
map.put(ConfigFileForm.REV_GID, getGroup());
map.put(ConfigFileForm.REV_PERMS, getPermissions());
+ map.put(ConfigFileForm.REV_SELINUX_CTX, getSelinuxCtx());
map.put(ConfigFileForm.REV_MACROSTART, getMacroStart());
map.put(ConfigFileForm.REV_MACROEND, getMacroEnd());
return map;
@@ -363,6 +392,7 @@ public abstract class ConfigFileData {
append("Owner", getOwner()).
append("Group", getGroup()).
append("Permissions", getPermissions()).
+ append("SELinux Context", getSelinuxCtx()).
append("Type", getType()).
append("Macro Start", getMacroStart()).
append("Macro End", getMacroEnd()).
diff --git a/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java b/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java
index a28cd2f..f547dd8 100644
--- a/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java
+++ b/java/code/src/com/redhat/rhn/testing/ConfigTestUtils.java
@@ -307,7 +307,7 @@ public class ConfigTestUtils extends Assert {
* @return The newly created ConfigInfo.
*/
public static ConfigInfo createConfigInfo(String user, String group, Long fileMode) {
- return ConfigurationFactory.lookupOrInsertConfigInfo(user, group, fileMode);
+ return ConfigurationFactory.lookupOrInsertConfigInfo(user, group, fileMode, "");
}
/**
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf
index 2eeddbe..0bbaad9 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/create.jspf
@@ -43,6 +43,11 @@
key="filedetails.jsp.tip.permissions" /></span></td>
</tr>
<tr>
+ <th>SELinux context</th>
+ <td><html:text property="cffSELinuxCtx" size="30" /><br />
+ <span class="small-text"><bean:message key="filedetails.jsp.tip.selinux" /></span></td>
+ </tr>
+ <tr>
<th><bean:message key="filedetails.add_details.jspf.macro" /></th>
<td nowrap="nowrap">
<bean:message key="filedetails.add_details.jspf.macro.start" />
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf
index 13a20c7..e01f323 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/channel/upload.jspf
@@ -48,6 +48,11 @@
key="filedetails.jsp.tip.permissions" /></span></td>
</tr>
<tr>
+ <th>SELinux context</th>
+ <td><html:text property="cffSELinuxCtx" size="30" /><br />
+ <span class="small-text"><bean:message key="filedetails.jsp.tip.selinux" /></span></td>
+ </tr>
+ <tr>
<th><bean:message key="filedetails.add_details.jspf.macro" /></th>
<td nowrap="nowrap">
<bean:message key="filedetails.add_details.jspf.macro.start" />
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf
index 054aadc..cce3995 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/configuration/files/properties.jspf
@@ -53,4 +53,19 @@
<span class="small-text"><bean:message key="filedetails.jsp.tip.permissions" /></span>
</td>
</tr>
+<tr>
+ <th>SELinux context</th>
+ <td>
+ <rhn:require acl="config_channel_editable(${channel.id})"
+ mixins="com.redhat.rhn.common.security.acl.ConfigAclHandler">
+ <html:text property="cffSELinuxCtx" size="24" />
+ </rhn:require>
+ <rhn:require acl="not config_channel_editable(${channel.id})"
+ mixins="com.redhat.rhn.common.security.acl.ConfigAclHandler">
+ ${form.map.cffSELinuxCtx}
+ </rhn:require>
+ <br />
+ <span class="small-text"><bean:message key="filedetails.jsp.tip.selinux" /></span>
+ </td>
+</tr>
</table>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 7a26013..a4d0c32 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -867,6 +867,7 @@
<form-property name="cffPath" type="java.lang.String"/>
<form-property name="cffUid" type="java.lang.String"/>
<form-property name="cffGid" type="java.lang.String"/>
+ <form-property name="cffSELinuxCtx" type="java.lang.String"/>
<form-property name="cffPermissions" type="java.lang.String"/>
<form-property name="cffMacroStart" type="java.lang.String"/>
<form-property name="cffMacroEnd" type="java.lang.String"/>
diff --git a/schema/spacewalk/common/tables/rhnConfigInfo.sql b/schema/spacewalk/common/tables/rhnConfigInfo.sql
index 17786c4..bb62b09 100644
--- a/schema/spacewalk/common/tables/rhnConfigInfo.sql
+++ b/schema/spacewalk/common/tables/rhnConfigInfo.sql
@@ -16,22 +16,23 @@
CREATE TABLE rhnConfigInfo
(
- id NUMBER NOT NULL
- CONSTRAINT rhn_confinfo_id_pk PRIMARY KEY
- USING INDEX TABLESPACE [[2m_tbs]],
- username VARCHAR2(32) NOT NULL,
- groupname VARCHAR2(32) NOT NULL,
- filemode NUMBER NOT NULL,
- created DATE
- DEFAULT (sysdate) NOT NULL,
- modified DATE
- DEFAULT (sysdate) NOT NULL
+ id NUMBER NOT NULL
+ CONSTRAINT rhn_confinfo_id_pk PRIMARY KEY
+ USING INDEX TABLESPACE [[2m_tbs]],
+ username VARCHAR2(32) NOT NULL,
+ groupname VARCHAR2(32) NOT NULL,
+ filemode NUMBER NOT NULL,
+ created DATE
+ DEFAULT (sysdate) NOT NULL,
+ modified DATE
+ DEFAULT (sysdate) NOT NULL,
+ selinux_ctx VARCHAR2(64)
)
ENABLE ROW MOVEMENT
;
CREATE UNIQUE INDEX rhn_confinfo_ugf_uq
- ON rhnConfigInfo (username, groupname, filemode)
+ ON rhnConfigInfo (username, groupname, filemode, selinux_ctx)
TABLESPACE [[4m_tbs]];
CREATE SEQUENCE rhn_confinfo_id_seq;
diff --git a/schema/spacewalk/oracle/procs/lookup_config_info.sql b/schema/spacewalk/oracle/procs/lookup_config_info.sql
index 9255b89..65e238b 100644
--- a/schema/spacewalk/oracle/procs/lookup_config_info.sql
+++ b/schema/spacewalk/oracle/procs/lookup_config_info.sql
@@ -20,7 +20,8 @@ create or replace function
lookup_config_info (
username_in in varchar2,
groupname_in in varchar2,
- filemode_in in varchar2
+ filemode_in in varchar2,
+ selinux_ctx_in in varchar2
) return number
deterministic
is
@@ -32,7 +33,8 @@ is
where 1=1
and username = username_in
and groupname = groupname_in
- and filemode = filemode_in;
+ and filemode = filemode_in
+ and selinux_ctx = selinux_ctx_in;
begin
for r in lookup_cursor loop
return r.id;
@@ -41,8 +43,8 @@ begin
select rhn_confinfo_id_seq.nextval
into v_id
from dual;
- insert into rhnConfigInfo (id, username, groupname, filemode)
- values (v_id, username_in, groupname_in, filemode_in);
+ insert into rhnConfigInfo (id, username, groupname, filemode, selinux_ctx)
+ values (v_id, username_in, groupname_in, filemode_in, selinux_ctx_in);
commit;
return v_id;
end lookup_config_info;
diff --git a/schema/spacewalk/postgres/procs/lookup_config_info.sql b/schema/spacewalk/postgres/procs/lookup_config_info.sql
index 605c502..d307d74 100644
--- a/schema/spacewalk/postgres/procs/lookup_config_info.sql
+++ b/schema/spacewalk/postgres/procs/lookup_config_info.sql
@@ -18,7 +18,8 @@ lookup_config_info
(
username_in in varchar,
groupname_in in varchar,
- filemode_in in numeric
+ filemode_in in numeric,
+ selinux_ctx_in in varchar
)
returns numeric
as
@@ -31,7 +32,8 @@ declare
from rhnConfigInfo
where username = username_in
and groupname = groupname_in
- and filemode = filemode_in;
+ and filemode = filemode_in
+ and selinux_ctx = selinux_ctx_in;
begin
for r in lookup_cursor loop
return r.id;
@@ -39,8 +41,8 @@ begin
-- If we got here, we don't have the id
select nextval('rhn_confinfo_id_seq') into v_id;
insert into rhnConfigInfo
- (id, username, groupname, filemode)
- values (v_id, username_in, groupname_in, filemode_in);
+ (id, username, groupname, filemode, selinux_ctx)
+ values (v_id, username_in, groupname_in, filemode_in, selinux_ctx_in);
return v_id;
end;
$$ language plpgsql;
14 years, 8 months
java/code
by Pradeep Kilambi
java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java | 11 ++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
New commits:
commit 3022ae5840f925a031c0200fb9820f3cc9004027
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Aug 3 13:08:04 2009 -0400
515219 - We can have a channel with null description. In the packagedetailsaction we call replace on description without checking if its a valid string resulting in Null Pointer Exception.
diff --git a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java
index 078fcb2..9bd7cb0 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java
@@ -100,8 +100,15 @@ public class PackageDetailsAction extends RhnAction {
}
request.setAttribute("pack", pkg);
- request.setAttribute("description",
- pkg.getDescription().replace("\n", "<BR>\n"));
+ // description can be null.
+ if (pkg.getDescription() != null) {
+ request.setAttribute("description",
+ pkg.getDescription().replace("\n", "<BR>\n"));
+ }
+ else {
+ request.setAttribute("description",
+ pkg.getDescription());
+ }
request.setAttribute("packArches",
PackageFactory.findPackagesWithDifferentArch(pkg));
request.setAttribute("pid", pid);
14 years, 8 months