Hello all,
In the hope of someone else finding these useful, here are some patches
we've been kicking around for a while and seem to work as expected.
Joshua Roys (3):
Add task to schedule config file comparisons
Set CompareConfigFilesTask to run at 11pm
Show number of differing config files in overview
Joshua Roys (1):
Diff SELinux contexts
Joshua Roys (4):
Fix system comparison file/dir/symlink counts
Plug fd leak
Fix two more fd leaks
Make debugging osa* network/jabber issues easier
Thanks,
Josh
>From 747bac770dd7a81a3b2f91b8441080333c885de3 Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Thu, 8 Oct 2009 09:36:04 -0400
Subject: [PATCH 1/3] Add task to schedule config file comparisons
---
.../common/db/datasource/xml/System_queries.xml | 12 +++
.../common/db/datasource/xml/config_queries.xml | 18 ++++
.../configuration/ConfigurationManager.java | 21 ++++-
.../redhat/rhn/manager/system/SystemManager.java | 12 +++-
.../taskomatic/task/CompareConfigFilesTask.java | 90 ++++++++++++++++++++
5 files changed, 150 insertions(+), 3 deletions(-)
create mode 100644
java/code/src/com/redhat/rhn/taskomatic/task/CompareConfigFilesTask.java
diff --git
a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index 3c59835..1a3a87e 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -422,6 +422,18 @@ ORDER BY UPPER(NVL(S.name, '(none)')), S.id
<elaborator name="is_virtual_host" />
</mode>
+<mode name="all_systems" class="com.redhat.rhn.frontend.dto.SystemOverview">
+ <query>
+ SELECT DISTINCT S.id,
+ S.name AS SERVER_NAME,
+ (SELECT 1
+ FROM rhnServerFeaturesView SFV
+ WHERE SFV.server_id = S.id
+ AND SFV.label = 'ftr_system_grouping') AS selectable
+ FROM rhnServer S
+ </query>
+ <elaborator name="system_overview" />
+</mode>
<mode name="most_critical_systems"
class="com.redhat.rhn.frontend.dto.SystemOverview">
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 bc769f1..f79b2a2 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
@@ -1265,6 +1265,24 @@ ORDER BY CFN.path
<elaborator name="file_name_elab" />
</mode>
+<mode name="automated_file_names_for_system"
class="com.redhat.rhn.frontend.dto.ConfigFileNameDto">
+ <query params="sid">
+SELECT DISTINCT CFN.id, CFN.path
+ FROM rhnConfigFileName CFN, rhnServerConfigChannel SCC,
+ rhnConfigFile CF, rhnUserServerPerms USP,
+ rhnConfigChannel CC, rhnConfigChannelType CCT
+ WHERE SCC.server_id = :sid
+ AND USP.server_id = SCC.server_id
+ AND SCC.config_channel_id = CF.config_channel_id
+ AND SCC.config_channel_id = CC.id
+ AND CC.confchan_type_id = CCT.id
+ AND CCT.label != 'server_import'
+ AND CF.config_file_name_id = CFN.id
+ORDER BY CFN.path
+ </query>
+ <elaborator name="file_name_elab" />
+</mode>
+
<mode name="file_names_for_system"
class="com.redhat.rhn.frontend.dto.ConfigFileNameDto">
<query params="sid, user_id">
SELECT DISTINCT CFN.id, CFN.path
diff --git
a/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
b/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
index 4d7a5cf..b7c487e 100644
---
a/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
+++
b/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
@@ -517,8 +517,25 @@ public class ConfigurationManager extends BaseManager {
DataResult dr = makeDataResult(params, elabParams, pc, m);
return dr;
}
-
-
+
+ /**
+ * Lists the file names to which the given server is subscribed
+ * Finds the deployable revisions for each file name.
+ * @param server The server to which these files must be relevant
+ * @return A list of config file names in DTO format.
+ */
+ public DataResult <ConfigFileNameDto> listAllFileNamesForSystem(Server
server) {
+ SelectMode m = ModeFactory.getMode("config_queries",
+ "automated_file_names_for_system");
+ Map params = new HashMap();
+ Map elabParams = new HashMap();
+ params.put("sid", server.getId());
+ elabParams.put("sid", server.getId());
+ DataResult dr = makeDataResult(params, elabParams, null, m);
+ dr.elaborate();
+ return dr;
+ }
+
/**
* Lists the file names to which the given server is subscribed
* Finds the deployable revisions for each file name.
diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
index b393eee..6e1221c 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -288,7 +288,17 @@ public class SystemManager extends BaseManager {
return makeDataResult(params, elabParams, pc, m);
}
-
+ /**
+ * Returns a list of all systems
+ * @return list of SystemOverviews
+ */
+ public static DataResult<SystemOverview> listAllSystems() {
+ SelectMode m = ModeFactory.getMode("System_queries", "all_systems");
+ DataResult dr = makeDataResult(new HashMap(), new HashMap(), null, m);
+ dr.elaborate();
+ return dr;
+ }
+
/**
* Returns list of all systems that are visible to user
* but not in the given server group.
diff --git
a/java/code/src/com/redhat/rhn/taskomatic/task/CompareConfigFilesTask.java
b/java/code/src/com/redhat/rhn/taskomatic/task/CompareConfigFilesTask.java
new file mode 100644
index 0000000..e433a89
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/CompareConfigFilesTask.java
@@ -0,0 +1,90 @@
+
+package com.redhat.rhn.taskomatic.task;
+
+import com.redhat.rhn.domain.action.Action;
+import com.redhat.rhn.domain.action.ActionFactory;
+import com.redhat.rhn.domain.action.config.ConfigAction;
+import com.redhat.rhn.domain.config.ConfigFile;
+import com.redhat.rhn.domain.config.ConfigRevision;
+import com.redhat.rhn.domain.config.ConfigurationFactory;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.server.ServerFactory;
+import com.redhat.rhn.frontend.dto.ConfigFileNameDto;
+import com.redhat.rhn.frontend.dto.SystemOverview;
+import com.redhat.rhn.manager.configuration.ConfigurationManager;
+import com.redhat.rhn.manager.system.SystemManager;
+
+import org.apache.log4j.Logger;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+/**
+ * Compare Config Files
+ * Schedules a comparison of config files on all systems
+ *
+ * @version $Rev$
+ */
+public class CompareConfigFilesTask implements Job {
+
+ /**
+ * Used to log stats in the RHNDAEMONSTATE table
+ */
+ public static final String DISPLAY_NAME = "compare_config_files";
+
+ private static Logger log = Logger.getLogger(CompareConfigFilesTask.class);
+
+ /**
+ * Default constructor
+ */
+ public CompareConfigFilesTask() {
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public void execute(JobExecutionContext context)
+ throws JobExecutionException {
+
+ log.info("running config compare");
+
+ ConfigurationManager cm = ConfigurationManager.getInstance();
+
+ for (SystemOverview sys : SystemManager.listAllSystems()) {
+ Action act =
ActionFactory.createAction(ActionFactory.TYPE_CONFIGFILES_DIFF);
+ ConfigAction cfact = (ConfigAction) act;
+ Server server = ServerFactory.lookupById(sys.getId());
+
+ if (server.isInactive()) {
+ continue;
+ }
+
+ // set up needed fields for the action
+ act.setName(act.getActionType().getName());
+ act.setOrg(server.getOrg());
+
+ // add the server to the action
+ ActionFactory.addServerToAction(server, act);
+
+ // add file revisions to the action
+ for (ConfigFileNameDto cfn : cm.listAllFileNamesForSystem(server))
{
+ Long cfid = cfn.getConfigFileId();
+ ConfigFile cf =
ConfigurationFactory.lookupConfigFileById(cfid);
+ ConfigRevision crev = cf.getLatestConfigRevision();
+
+ ActionFactory.addConfigRevisionToAction(crev, server, cfact);
+ }
+
+ if (act.getServerActions().size() < 1) {
+ continue;
+ }
+ if (cfact.getConfigRevisionActions().size() < 1) {
+ continue;
+ }
+
+ ActionFactory.save(act);
+ }
+ }
+}
+
+// vim: ts=4:expandtab
--
1.6.4
>From f9b3ee52858487245094993f7ab3366ee52e9263 Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Thu, 8 Oct 2009 10:06:39 -0400
Subject: [PATCH 2/3] Set CompareConfigFilesTask to run at 11pm
---
java/conf/default/rhn_taskomatic.conf | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/java/conf/default/rhn_taskomatic.conf
b/java/conf/default/rhn_taskomatic.conf
index 6fe0b3c..fea70a6 100644
--- a/java/conf/default/rhn_taskomatic.conf
+++ b/java/conf/default/rhn_taskomatic.conf
@@ -22,7 +22,8 @@ com.redhat.rhn.taskomatic.task.ErrataCacheTask,\
com.redhat.rhn.taskomatic.task.CobblerSyncTask,\
com.redhat.rhn.taskomatic.task.ChannelRepodata,\
com.redhat.rhn.taskomatic.task.KickstartFileSyncTask,\
-com.redhat.rhn.taskomatic.task.RepoSyncTask
+com.redhat.rhn.taskomatic.task.RepoSyncTask,\
+com.redhat.rhn.taskomatic.task.CompareConfigFilesTask
# additional tasks
taskomatic.tasks =
@@ -70,6 +71,7 @@
taskomatic.com.redhat.rhn.taskomatic.task.CleanCurrentAlerts.schedule = 0 35 4 ?
# Once a day at 11:00 PM
taskomatic.com.redhat.rhn.taskomatic.task.SummaryPopulation.schedule = 0 0 23
? * *
+taskomatic.com.redhat.rhn.taskomatic.task.CompareConfigFilesTask.schedule = 0
0 23 ? * *
# Once a day at 5:00:00 AM
taskomatic.com.redhat.rhn.taskomatic.task.DailySummary.schedule = 0 0 5 ? * *
--
1.6.4
>From 62908f1fdcb898227c82f85b4ddef1e0de5a32b9 Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Fri, 9 Oct 2009 11:28:02 -0400
Subject: [PATCH 3/3] Show number of differing config files in overview
---
.../common/db/datasource/xml/System_queries.xml | 3 +
.../redhat/rhn/frontend/dto/SystemOverview.java | 13 +++
.../frontend/strings/jsp/StringResource_en_US.xml | 7 ++
.../fragments/systems/system_listdisplay.jspf | 17 +++-
.../spacewalk/oracle/views/rhnServerOverview.sql | 20 ++++-
.../151-rhnServerOverview.sql | 100 ++++++++++++++++++++
6 files changed, 158 insertions(+), 2 deletions(-)
create mode 100644
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/151-rhnServerOverview.sql
diff --git
a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index 1a3a87e..9e03fea 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -1100,6 +1100,7 @@ ORDER BY S.ID
SELECT /*+ RULE */ SERVER_ID AS ID, OUTDATED_PACKAGES, SERVER_NAME,
security_errata, bug_errata, enhancement_errata,
SERVER_ADMINS, GROUP_COUNT, NOTE_COUNT, MODIFIED, CHANNEL_LABELS,
CHANNEL_ID, HISTORY_COUNT,
LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE,
SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED,
+ config_files_with_differences,
( SELECT DECODE(
MAX(DECODE(PS.state, 'OK', 1, 'PENDING', 2, 'UNKNOWN', 3,
'WARNING', 4, 'CRITICAL', 5)),
1, 'OK', 2, 'PENDING', 3, 'UNKNOWN', 4, 'WARNING', 5,
'CRITICAL') ST
@@ -1132,6 +1133,7 @@ select distinct sgm.server_id as ID, 1 as virtual_host
SELECT SERVER_ID AS ID, SECURITY_ERRATA, BUG_ERRATA, ENHANCEMENT_ERRATA,
OUTDATED_PACKAGES, SERVER_NAME,
SERVER_ADMINS, GROUP_COUNT, NOTE_COUNT, MODIFIED, CHANNEL_LABELS,
HISTORY_COUNT,
LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE,
SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED,
+ config_files_with_differences,
( SELECT DECODE(
MAX(DECODE(PS.state, 'OK', 1, 'PENDING', 2, 'UNKNOWN', 3,
'WARNING', 4, 'CRITICAL', 5)),
1, 'OK', 2, 'PENDING', 3, 'UNKNOWN', 4, 'WARNING', 5,
'CRITICAL') ST
@@ -1149,6 +1151,7 @@ ORDER BY SECURITY_ERRATA DESC, BUG_ERRATA DESC,
ENHANCEMENT_ERRATA DESC
SERVER_ID as system_id, SECURITY_ERRATA, BUG_ERRATA,
ENHANCEMENT_ERRATA, OUTDATED_PACKAGES, SERVER_NAME,
SERVER_ADMINS, GROUP_COUNT, NOTE_COUNT, OV.MODIFIED, CHANNEL_LABELS,
CHANNEL_ID, HISTORY_COUNT,
LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE,
SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED,
+ config_files_with_differences,
( SELECT DECODE(
MAX(DECODE(PS.state, 'OK', 1, 'PENDING', 2, 'UNKNOWN', 3,
'WARNING', 4, 'CRITICAL', 5)),
1, 'OK', 2, 'PENDING', 3, 'UNKNOWN', 4, 'WARNING', 5,
'CRITICAL') ST
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/SystemOverview.java
b/java/code/src/com/redhat/rhn/frontend/dto/SystemOverview.java
index ff7c41d..5a18f5c 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/SystemOverview.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/SystemOverview.java
@@ -39,6 +39,7 @@ public class SystemOverview extends BaseDto implements
Serializable {
private Long bugErrata = 0L;
private Long enhancementErrata = 0L;
private Long outdatedPackages;
+ private Long configFilesWithDifferences;
private String serverName;
private Long serverAdmins;
private Long groupCount;
@@ -318,6 +319,18 @@ public class SystemOverview extends BaseDto implements
Serializable {
this.outdatedPackages = outdatedPackagesIn;
}
/**
+ * @return Returns the configFilesWithDifferences.
+ */
+ public Long getConfigFilesWithDifferences() {
+ return configFilesWithDifferences;
+ }
+ /**
+ * @param configFilesWithDifferencesIn The configFilesWithDifferences to
set.
+ */
+ public void setConfigFilesWithDifferences(Long
configFilesWithDifferencesIn) {
+ this.configFilesWithDifferences = configFilesWithDifferencesIn;
+ }
+ /**
* @return Returns the pendingUpdates.
*/
public Long getPendingUpdates() {
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 279a9dc..12d5ca8 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
@@ -5280,6 +5280,13 @@ value for this entitlement, excluding the default
organization's consumption.</s
</context-group>
</trans-unit>
+ <trans-unit id="systemlist.jsp.configfiles">
+<source>Configs</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/SystemList</context>
+ </context-group>
+ </trans-unit>
+
<trans-unit id="systemlist.jsp.packages">
<source>Packages</source>
<context-group name="ctx">
diff --git
a/java/code/webapp/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf
b/java/code/webapp/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf
index 6a48ef8..7110391 100644
---
a/java/code/webapp/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf
+++
b/java/code/webapp/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf
@@ -85,7 +85,22 @@
</c:choose>
</rl:column>
</c:if>
-
+ <c:if test = "${empty noConfigFiles}">
+ <rl:column sortable="false"
+ bound="false"
+ headerkey="systemlist.jsp.configfiles"
+ styleclass="center"
+ headerclass="thin-column">
+ <c:choose>
+ <c:when
test="${(current.configFilesWithDifferences) == 0}">
+ <c:out value="0" />
+ </c:when>
+ <c:otherwise>
+ <c:out value="<a
href='/rhn/systems/details/configuration/Overview.do?sid=${current.id}'>${current.configFilesWithDifferences}</a>"
escapeXml="false" />
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ </c:if>
<!-- Name Channel Column -->
<rl:column sortable="true"
bound="false"
diff --git a/schema/spacewalk/oracle/views/rhnServerOverview.sql
b/schema/spacewalk/oracle/views/rhnServerOverview.sql
index 274da86..cd9d51f 100644
--- a/schema/spacewalk/oracle/views/rhnServerOverview.sql
+++ b/schema/spacewalk/oracle/views/rhnServerOverview.sql
@@ -31,6 +31,7 @@ rhnServerOverview
bug_errata,
enhancement_errata,
outdated_packages,
+ config_files_with_differences,
last_checkin_days_ago,
last_checkin,
pending_updates,
@@ -77,7 +78,24 @@ select
where
snpc.server_id = S.id
and p.id = snpc.package_id
- ),
+ ),
+ ( select count(*)
+ from rhnActionConfigRevision ACR
+ INNER JOIN rhnActionConfigRevisionResult ACRR on ACR.id =
ACRR.action_config_revision_id
+ where ACR.server_id = S.id
+ and ACR.action_id = (
+ select MAX(rA.id)
+ from rhnAction rA
+ INNER JOIN rhnServerAction rSA on rSA.action_id = rA.id
+ INNER JOIN rhnActionStatus rAS on rAS.id = rSA.status
+ INNER JOIN rhnActionType rAT on rAT.id = rA.action_type
+ where rSA.server_id = S.id
+ and rAS.name in ('Completed', 'Failed')
+ and rAT.label = 'configfiles.diff'
+ )
+ and ACR.failure_id is null
+ and ACRR.result is not null
+ ),
( select sysdate - checkin from rhnServerInfo where server_id = S.id ),
( select TO_CHAR(checkin, 'YYYY-MM-DD HH24:MI:SS') from rhnServerInfo
where server_id = S.id ),
( select count(1)
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/151-rhnServerOverview.sql
b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/151-rhnServerOverview.sql
new file mode 100644
index 0000000..fb4eb04
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/151-rhnServerOverview.sql
@@ -0,0 +1,100 @@
+--
+-- Add in config_files_with_differences
+--
+
+create or replace view
+rhnServerOverview
+(
+ org_id,
+ server_id,
+ server_name,
+ note_count,
+ modified,
+ server_admins,
+ group_count,
+ channel_id,
+ channel_labels,
+ history_count,
+ security_errata,
+ bug_errata,
+ enhancement_errata,
+ outdated_packages,
+ config_files_with_differences,
+ last_checkin_days_ago,
+ last_checkin,
+ pending_updates,
+ os,
+ release,
+ server_arch_name,
+ locked
+)
+as
+select
+ s.org_id, s.id, s.name, 0, s.modified,
+ ( select count(user_id) from rhnUserServerPerms ap
+ where server_id = s.id ),
+ ( select count(server_group_id) from rhnVisibleServerGroupMembers
+ where server_id = s.id ),
+ ( select C.id
+ from rhnChannel C,
+ rhnServerChannel SC
+ where SC.server_id = S.id
+ and SC.channel_id = C.id
+ and C.parent_channel IS NULL),
+ NVL(( select C.name
+ from rhnChannel C,
+ rhnServerChannel SC
+ where SC.server_id = S.id
+ and SC.channel_id = C.id
+ and C.parent_channel IS NULL), '(none)'),
+ ( select count(id) from rhnServerHistory
+ where
+ server_id = S.id),
+ ( select count(*) from rhnServerErrataTypeView setv
+ where
+ setv.server_id = s.id
+ and setv.errata_type = 'Security Advisory'),
+ ( select count(*) from rhnServerErrataTypeView setv
+ where
+ setv.server_id = s.id
+ and setv.errata_type = 'Bug Fix Advisory'),
+ ( select count(*) from rhnServerErrataTypeView setv
+ where
+ setv.server_id = s.id
+ and setv.errata_type = 'Product Enhancement Advisory'),
+ ( select count(distinct p.name_id) from rhnPackage p,
rhnServerNeededPackageCache snpc
+ where
+ snpc.server_id = S.id
+ and p.id = snpc.package_id
+ ),
+ ( select count(*)
+ from rhnActionConfigRevision ACR
+ INNER JOIN rhnActionConfigRevisionResult ACRR on ACR.id =
ACRR.action_config_revision_id
+ where ACR.server_id = S.id
+ and ACR.action_id = (
+ select MAX(rA.id)
+ from rhnAction rA
+ INNER JOIN rhnServerAction rSA on rSA.action_id = rA.id
+ INNER JOIN rhnActionStatus rAS on rAS.id = rSA.status
+ INNER JOIN rhnActionType rAT on rAT.id = rA.action_type
+ where rSA.server_id = S.id
+ and rAS.name in ('Completed', 'Failed')
+ and rAT.label = 'configfiles.diff'
+ )
+ and ACR.failure_id is null
+ and ACRR.result is not null
+ ),
+ ( select sysdate - checkin from rhnServerInfo where server_id = S.id ),
+ ( select TO_CHAR(checkin, 'YYYY-MM-DD HH24:MI:SS') from rhnServerInfo
where server_id = S.id ),
+ ( select count(1)
+ from rhnServerAction
+ where server_id = S.id
+ and status in (0, 1)),
+ os,
+ release,
+ ( select name from rhnServerArch where id = s.server_arch_id),
+ NVL((select 1 from rhnServerLock SL WHERE SL.server_id = S.id), 0)
+from
+ rhnServer S
+/
+
--
1.6.4
>From 4e8cf5679bccf2aa6d5d467ebf2c6790d9a898b3 Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Fri, 25 Sep 2009 07:25:09 -0400
Subject: [PATCH] Diff SELinux contexts
---
client/tools/rhncfg/config_common/file_utils.py | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/client/tools/rhncfg/config_common/file_utils.py
b/client/tools/rhncfg/config_common/file_utils.py
index c34c605..3e19550 100644
--- a/client/tools/rhncfg/config_common/file_utils.py
+++ b/client/tools/rhncfg/config_common/file_utils.py
@@ -18,6 +18,12 @@ import time
import tempfile
import base64
from config_common.rhn_log import log_debug
+try:
+ from selinux import lgetfilecon
+except:
+ # on rhel4 we do not support selinux
+ def lgetfilecon(path):
+ return [0, '']
from config_common import utils
@@ -81,7 +87,13 @@ class FileProcessor:
temp_file, temp_dirs = self.process(file_struct)
path = file_struct['path']
- result = None
+ sectx_result = ''
+ result = ''
+
+ cur_sectx = lgetfilecon(path)[1]
+ if file_struct.has_key('selinux_ctx'):
+ if cur_sectx != file_struct['selinux_ctx']:
+ sectx_result = "SELinux contexts differ! Current context:
%s\n" % cur_sectx
if file_struct['filetype'] == 'symlink':
try:
@@ -101,7 +113,7 @@ class FileProcessor:
result = pipe.read()
os.unlink(temp_file)
- return result
+ return sectx_result + result
def _validate_struct(self, file_struct):
for k in self.file_struct_fields.keys():
--
1.6.4
>From 408f6b623d2138302ae9488c7ae195cd340233ba Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Fri, 18 Sep 2009 14:40:49 -0400
Subject: [PATCH] Fix system comparison file/dir/symlink counts
---
.../action/configuration/sdc/OverviewAction.java | 36 ++---
.../frontend/strings/java/StringResource_en_US.xml | 164 ++++++++++++++------
2 files changed, 131 insertions(+), 69 deletions(-)
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/configuration/sdc/OverviewAction.java
b/java/code/src/com/redhat/rhn/frontend/action/configuration/sdc/OverviewAction.java
index 9403841..2c08ef9 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/configuration/sdc/OverviewAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/configuration/sdc/OverviewAction.java
@@ -275,30 +275,21 @@ public class OverviewAction extends RhnAction {
ConfigFileCount differing,
String url) {
- int filesSuffix = getSuffix(total.getFiles() + total.getSymlinks());
+ int filesSuffix = getSuffix(total.getFiles());
int dirsSuffix = getSuffix(total.getDirectories());
+ int symlinksSuffix = getSuffix(total.getSymlinks());
String messageKey = DIFF_ACTION_MESSAGE_PREFIX +
- filesSuffix + "_dirs_" + dirsSuffix;
+ filesSuffix + "_dirs_" + dirsSuffix + "_symlinks_" +
symlinksSuffix;
List params = new ArrayList();
// setup the params
- if (filesSuffix == PLURAL) {
- params.add(String.valueOf(successful.getFiles() +
successful.getSymlinks()));
- params.add(String.valueOf(total.getFiles() + total.getSymlinks()));
- }
- else if (filesSuffix == SINGULAR) {
- params.add(String.valueOf(successful.getFiles() +
successful.getSymlinks()));
- }
-
- if (dirsSuffix == PLURAL) {
- params.add(String.valueOf(successful.getDirectories()));
- params.add(String.valueOf(total.getDirectories()));
- }
- else if (dirsSuffix == SINGULAR) {
- params.add(String.valueOf(successful.getDirectories()));
- }
-
+ params.add(String.valueOf(successful.getFiles()));
+ params.add(String.valueOf(total.getFiles()));
+ params.add(String.valueOf(successful.getDirectories()));
+ params.add(String.valueOf(total.getDirectories()));
+ params.add(String.valueOf(successful.getSymlinks()));
+ params.add(String.valueOf(total.getSymlinks()));
params.add(url);
LocalizationService service = LocalizationService.getInstance();
@@ -306,9 +297,10 @@ public class OverviewAction extends RhnAction {
request.setAttribute(DIFF_ACTION_MESSAGE,
service.getMessage(messageKey));
}
- request.setAttribute(DIFF_ACTION_MESSAGE,
- service.getMessage(messageKey,
- params.toArray()));
+ else {
+ request.setAttribute(DIFF_ACTION_MESSAGE,
+ service.getMessage(messageKey, params.toArray()));
+ }
if (successful.getFiles() + successful.getSymlinks() > 0) {
String diffActionKey;
@@ -327,7 +319,7 @@ public class OverviewAction extends RhnAction {
else {
Object [] keyParams = new Object[] {
String.valueOf(differing.getFiles() +
differing.getSymlinks()),
- String.valueOf(successful.getFiles() +
successful.getSymlinks())
+ String.valueOf(successful.getFiles() +
successful.getSymlinks())
};
request.setAttribute(DIFF_DETAILS_MESSAGE,
service.getMessage(diffActionKey, keyParams));
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 99028dd..fc5d8d0 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
@@ -7108,57 +7108,127 @@ Follow this url to see the full list of inactive
systems:
<trans-unit id="sdc.config.diff.noaction">
<source>No system comparisons completed. [<a
href="{0}">Schedule System Comparison</a>]</source>
</trans-unit>
- <trans-unit id="sdc.config.diff.files_0_dirs_0">
- <source>No files or directories were selected for
comparison. [<a href="{0}"> View Details</a>]</source>
- </trans-unit>
- <trans-unit id="sdc.config.diff.files_1_dirs_0">
-<source>{0} of 1 file on the system was successfully compared with
@@PRODUCT_NAME@@-Managed files and directories. [<a href="{1}">
View Details</a>]</source>
- </trans-unit>
-
-
- <trans-unit id="sdc.config.diff.files_2_dirs_0">
- <source>{0} of {1} files on the system were successfully compared
with @@PRODUCT_NAME@@-Managed files and directories. [<a
href="{2}"> View Details</a>]</source>
- </trans-unit>
-
+ <trans-unit id="sdc.config.diff.files_0_dirs_0_symlinks_0">
+ <source>No files, directories or symlinks were selected for
comparison. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
- <trans-unit id="sdc.config.diff.files_0_dirs_1">
-<source>{0} of 1 directory on the system was successfully compared with
@@PRODUCT_NAME@@-Managed files and directories. [<a href="{1}">
View Details</a>]</source>
- </trans-unit>
-
-
- <trans-unit id="sdc.config.diff.files_0_dirs_2">
- <source>{0} of {1} directories on the system were successfully
compared with @@PRODUCT_NAME@@-Managed files and directories. [<a
href="{2}"> View Details</a>]</source>
- </trans-unit>
+ <trans-unit id="sdc.config.diff.files_0_dirs_0_symlinks_1">
+ <source>{4} of 1 symlink on the system was successfully
compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
- <trans-unit id="sdc.config.diff.files_1_dirs_1">
-<source>{0} of 1 file and {1} of 1 directory on the system was successfully
compared with @@PRODUCT_NAME@@-Managed files and directories. [<a
href="{2}"> View Details</a>]</source>
- </trans-unit>
-
-
- <trans-unit id="sdc.config.diff.files_1_dirs_2">
- <source>{0} of 1 file and {1} of {2} directories on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files and directories.
[<a href="{3}"> View Details</a>]</source>
- </trans-unit>
-
- <trans-unit id="sdc.config.diff.files_2_dirs_1">
- <source>{0} of {1} files and {2} of 1 directory on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files and directories.
[<a href="{3}"> View Details</a>]</source>
- </trans-unit>
-
- <trans-unit id="sdc.config.diff.files_2_dirs_2">
- <source>{0} of {1} files and {2} of 1 directory on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files and directories.
[<a href="{3}"> View Details</a>]</source>
- </trans-unit>
-
- <trans-unit id="sdc.config.differing.files_0">
- <source>No existing files in the existing system
differed from the @@PRODUCT_NAME@@-Managed files.</source>
+ <trans-unit id="sdc.config.diff.files_0_dirs_0_symlinks_2">
+ <source>{4} of {5} symlinks on the system were successfully
compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_0_dirs_1_symlinks_0">
+ <source>{2} of 1 directory on the system was successfully
compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_0_dirs_1_symlinks_1">
+ <source>{2} of 1 directory and {4} of 1 symlink on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_0_dirs_1_symlinks_2">
+ <source>{2} of 1 directory and {4} of {5} symlinks on the
system were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_0_dirs_2_symlinks_0">
+ <source>{2} of {3} directories on the system were successfully
compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_0_dirs_2_symlinks_1">
+ <source>{2} of {3} directories and {4} of 1 symlink on the
system were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_0_dirs_2_symlinks_2">
+ <source>{2} of {3} directories and {4} of {5} symlinks on the
system were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_0_symlinks_0">
+ <source>{0} of 1 file on the system was successfully compared
with @@PRODUCT_NAME@@-Managed files. [<a href="{6}">View
Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_0_symlinks_1">
+ <source>{0} of 1 file and {4} of 1 symlink on the system were
successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_0_symlinks_2">
+ <source>{0} of 1 file and {4} of {5} symlinks on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_1_symlinks_0">
+ <source>{0} of 1 file and {2} of 1 directory on the system were
successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_1_symlinks_1">
+ <source>{0} of 1 file and {2} of 1 directory and {4} of 1
symlink on the system were successfully compared with @@PRODUCT_NAME@@-Managed
files. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_1_symlinks_2">
+ <source>{0} of 1 file and {2} of 1 directory and {4} of {5}
symlinks on the system were successfully compared with @@PRODUCT_NAME@@-Managed
files. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_2_symlinks_0">
+ <source>{0} of 1 file and {2} of {3} directories on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_2_symlinks_1">
+ <source>{0} of 1 file and {2} of {3} directories and {4} of 1
symlink on the system were successfully compared with @@PRODUCT_NAME@@-Managed
files. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_1_dirs_2_symlinks_2">
+ <source>{0} of 1 file and {2} of {3} directories and {4} of {5}
symlinks on the system were successfully compared with @@PRODUCT_NAME@@-Managed
files. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_0_symlinks_0">
+ <source>{0} of {1} files on the system were successfully
compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_0_symlinks_1">
+ <source>{0} of {1} files and {4} of 1 symlink on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_0_symlinks_2">
+ <source>{0} of {1} files and {4} of {5} symlinks on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_1_symlinks_0">
+ <source>{0} of {1} files and {2} of 1 directory on the system
were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_1_symlinks_1">
+ <source>{0} of {1} files and {2} of 1 directory and {4} of 1
symlink on the system were successfully compared with @@PRODUCT_NAME@@-Managed
files. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_1_symlinks_2">
+ <source>{0} of {1} files and {2} of 1 directory and {4} of {5}
symlinks on the system were successfully compared with @@PRODUCT_NAME@@-Managed
files. [<a href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_2_symlinks_0">
+ <source>{0} of {1} files and {2} of {3} directories on the
system were successfully compared with @@PRODUCT_NAME@@-Managed files. [<a
href="{6}">View Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_2_symlinks_1">
+ <source>{0} of {1} files and {2} of {3} directories and {4} of
1 symlink on the system were successfully compared with
@@PRODUCT_NAME@@-Managed files. [<a href="{6}">View
Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.diff.files_2_dirs_2_symlinks_2">
+ <source>{0} of {1} files and {2} of {3} directories and {4} of
{5} symlinks on the system were successfully compared with
@@PRODUCT_NAME@@-Managed files. [<a href="{6}">View
Details</a>]</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.differing.files_0">
+ <source>No existing files in the existing system differed from
the @@PRODUCT_NAME@@-Managed files.</source>
</trans-unit>
-
- <trans-unit id="sdc.config.differing.files_1">
- <source>1 of 1 file on the system differed from the
@@PRODUCT_NAME@@-Managed files</source>
- </trans-unit>
- <trans-unit id="sdc.config.differing.files_2">
- <source>{0} of {1} files on the system differed from the
@@PRODUCT_NAME@@-Managed files.</source>
- </trans-unit>
- </group>
+
+ <trans-unit id="sdc.config.differing.files_1">
+ <source>1 of 1 file on the system differed from the
@@PRODUCT_NAME@@-Managed files</source>
+ </trans-unit>
+
+ <trans-unit id="sdc.config.differing.files_2">
+ <source>{0} of {1} files on the system differed from the
@@PRODUCT_NAME@@-Managed files.</source>
+ </trans-unit>
+ </group>
<group>
<context-group name="sdc_actions_time_messages">
--
1.6.4
>From 8bc5c136760915e2fa574f81009ee36ff940511d Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Thu, 8 Oct 2009 15:29:44 -0400
Subject: [PATCH] Plug fd leak
This is possibly disastrous if you have a lot of audit files.
---
.../com/redhat/rhn/manager/audit/AuditManager.java | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
b/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
index 9e11d01..a94706d 100644
--- a/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
+++ b/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
@@ -386,6 +386,8 @@ public class AuditManager /* extends BaseManager */ {
}
}
+ brdr.close();
+
return new AuditReviewDto(machine, new Date(start), new Date(end),
reviewedBy, reviewedOn);
}
--
1.6.4
>From f6d1f262e17aaf3b35d4bf54cce4d1f5d9aa64e8 Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Fri, 9 Oct 2009 09:31:04 -0400
Subject: [PATCH] Fix two more fd leaks
---
.../frontend/action/audit/AuditSearchAction.java | 1 +
.../com/redhat/rhn/manager/audit/AuditManager.java | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/AuditSearchAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/AuditSearchAction.java
index 074aab9..61b51c4 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/audit/AuditSearchAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/audit/AuditSearchAction.java
@@ -134,6 +134,7 @@ public class AuditSearchAction extends RhnAction {
brdr.readLine(); // Argument is required for -m
str = brdr.readLine(); // Valid message types are: ...
str = str.substring(str.indexOf(':') + 2);
+ brdr.close();
}
catch (IOException ioex) {
log.warn("failed to get ausearch types", ioex);
diff --git a/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
b/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
index a94706d..82b154c 100644
--- a/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
+++ b/java/code/src/com/redhat/rhn/manager/audit/AuditManager.java
@@ -445,6 +445,8 @@ public class AuditManager /* extends BaseManager */ {
}
}
+ brdr.close();
+
return events;
}
}
--
1.6.4
>From b197a39b9960a9a3d2580168b65cee813ea938cd Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Mon, 26 Oct 2009 11:35:12 -0400
Subject: [PATCH] Make debugging osa* network/jabber issues easier
---
client/tools/osad/src/jabber_lib.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/client/tools/osad/src/jabber_lib.py
b/client/tools/osad/src/jabber_lib.py
index 5c615ae..344a91b 100644
--- a/client/tools/osad/src/jabber_lib.py
+++ b/client/tools/osad/src/jabber_lib.py
@@ -259,12 +259,15 @@ class Runner:
sys.exit(1)
except socket.error, e:
self.print_message(js, "socket error")
+ log_error(extract_traceback())
continue
except JabberError, e:
self.print_message(js, "JabberError")
+ log_error(extract_traceback())
continue
except SSLError, e:
self.print_message(js, "SSLError")
+ log_error(extract_traceback())
continue
else:
# Ran out of Jabber servers to try
--
1.6.4
_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel