Hi,

I have attached a patch to change the default password in jabberd during setup. You had code for that in 2009 already but then you did some changes on how you write the config for jabberd and during that change, the code for setting the password to a random string got lost.

The attached patch fixes that.


--
ciao, Uwe Gansert

SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
Home: http://www.suse.de/~ug - Blog: http://suse.gansert.net
commit 160d9e1db857492516f6446f82f84281852a885d
Author: Uwe Gansert <u...@suse.de>
Date:   Thu Aug 9 17:46:07 2012 +0200

    generate a random password for jabberd

diff --git a/spacewalk/spacewalk-setup-jabberd/bin/spacewalk-setup-jabberd b/spacewalk/spacewalk-setup-jabberd/bin/spacewalk-setup-jabberd
index 54fec6c..908563e 100755
--- a/spacewalk/spacewalk-setup-jabberd/bin/spacewalk-setup-jabberd
+++ b/spacewalk/spacewalk-setup-jabberd/bin/spacewalk-setup-jabberd
@@ -26,8 +26,27 @@ my $help = 0;
 my %macros = ('hostname' => Sys::Hostname::hostname(),
               'server_pem' => '/etc/pki/spacewalk/jabberd/server.pem',
               'localhost' => '127.0.0.1',
+              'password'  => '',
               'ipaddress' => '0.0.0.0');
 
+sub generatePassword {
+    my $length = shift;
+    my $password = "";
+
+    my @pool = qw( a b c d e f g h i j k l m n o
+                   p q r s t u v w x y z - _ %
+                   A B C D E F G H I J K L M N O
+                   P Q R S T U V W X Y Z
+                   0 1 2 3 4 5 6 7 8 9 );
+    srand;
+    for (my $i=0; $i < $length ;$i++) {
+        $password .= $pool[int(rand(@pool))];
+    }
+    return $password;
+}
+
+$macros{'password'} = generatePassword(12);
+
 # Try to guess correct path to jabberd's server.pem
 my $q = `rpm -qf /etc/jabberd/server.pem 2> /dev/null`;
 chomp $q;
@@ -61,7 +80,7 @@ if ($macros) {
 	}
 }
 
-foreach my $basename ('c2s', 's2s', 'sm', 'router') {
+foreach my $basename ('c2s', 's2s', 'sm', 'router', 'router-users') {
 	my $configfile = "/etc/jabberd/$basename.xml";
 	my $template = "/usr/share/spacewalk/setup/jabberd/$basename.xsl";
 
diff --git a/spacewalk/spacewalk-setup-jabberd/share/jabberd/c2s.xsl b/spacewalk/spacewalk-setup-jabberd/share/jabberd/c2s.xsl
index ff48d93..8d2a551 100644
--- a/spacewalk/spacewalk-setup-jabberd/share/jabberd/c2s.xsl
+++ b/spacewalk/spacewalk-setup-jabberd/share/jabberd/c2s.xsl
@@ -14,6 +14,12 @@
     </xsl:copy>
 </xsl:template>
 
+<xsl:template match="/c2s/router/pass">
+    <xsl:copy>
+      <xsl:text>@password@</xsl:text>
+    </xsl:copy>
+</xsl:template>
+
 <xsl:template match="/c2s/local/ip">
     <xsl:copy>
       <xsl:text>@ipaddress@</xsl:text>
diff --git a/spacewalk/spacewalk-setup-jabberd/share/jabberd/router-users.xsl b/spacewalk/spacewalk-setup-jabberd/share/jabberd/router-users.xsl
new file mode 100644
index 0000000..c67d306
--- /dev/null
+++ b/spacewalk/spacewalk-setup-jabberd/share/jabberd/router-users.xsl
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
+
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="/users/user/secret">
+    <xsl:copy>
+      <xsl:text>@password@</xsl:text>
+    </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/spacewalk/spacewalk-setup-jabberd/share/jabberd/router.xsl b/spacewalk/spacewalk-setup-jabberd/share/jabberd/router.xsl
index 2399c95..c2bf82e 100644
--- a/spacewalk/spacewalk-setup-jabberd/share/jabberd/router.xsl
+++ b/spacewalk/spacewalk-setup-jabberd/share/jabberd/router.xsl
@@ -14,4 +14,10 @@
     </xsl:copy>
 </xsl:template>
 
+<xsl:template match="/router/local/secret">
+    <xsl:copy>
+      <xsl:text>@password@</xsl:text>
+    </xsl:copy>
+</xsl:template>
+
 </xsl:stylesheet>
diff --git a/spacewalk/spacewalk-setup-jabberd/share/jabberd/s2s.xsl b/spacewalk/spacewalk-setup-jabberd/share/jabberd/s2s.xsl
index ef9f4bc..08a87db 100644
--- a/spacewalk/spacewalk-setup-jabberd/share/jabberd/s2s.xsl
+++ b/spacewalk/spacewalk-setup-jabberd/share/jabberd/s2s.xsl
@@ -14,6 +14,12 @@
   </xsl:copy>
 </xsl:template>
 
+<xsl:template match="/s2s/router/pass">
+  <xsl:copy>
+    <xsl:text>@password@</xsl:text>
+  </xsl:copy>
+</xsl:template>
+
 <xsl:template match="/s2s/local/ip">
   <xsl:copy>
      <xsl:text>@ipaddress@</xsl:text>
diff --git a/spacewalk/spacewalk-setup-jabberd/share/jabberd/sm.xsl b/spacewalk/spacewalk-setup-jabberd/share/jabberd/sm.xsl
index e0270d8..5a69ac6 100644
--- a/spacewalk/spacewalk-setup-jabberd/share/jabberd/sm.xsl
+++ b/spacewalk/spacewalk-setup-jabberd/share/jabberd/sm.xsl
@@ -14,6 +14,12 @@
   </xsl:copy>
 </xsl:template>
 
+<xsl:template match="/sm/router/pass">
+  <xsl:copy>
+    <xsl:text>@password@</xsl:text>
+  </xsl:copy>
+</xsl:template>
+
 <xsl:template match="/sm/id">
   <xsl:copy>
   <xsl:text>@hostname@</xsl:text>
_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to