[pve-devel] r6200 - in pve-cluster/trunk/data: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jun 29 10:21:19 CEST 2011


Author: dietmar
Date: 2011-06-29 10:21:19 +0200 (Wed, 29 Jun 2011)
New Revision: 6200

Modified:
   pve-cluster/trunk/data/ChangeLog
   pve-cluster/trunk/data/PVE/Cluster.pm
Log:
supress output when running openssl


Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog	2011-06-29 07:39:45 UTC (rev 6199)
+++ pve-cluster/trunk/data/ChangeLog	2011-06-29 08:21:19 UTC (rev 6200)
@@ -1,3 +1,8 @@
+2011-06-29  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/Cluster.pm (run_silent_cmd): supress output when running
+	openssl.
+
 2011-05-04  Proxmox Support Team  <support at proxmox.com>
 
 	* src/status.c (kvstore_send_update_message): use correct data

Modified: pve-cluster/trunk/data/PVE/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/PVE/Cluster.pm	2011-06-29 07:39:45 UTC (rev 6199)
+++ pve-cluster/trunk/data/PVE/Cluster.pm	2011-06-29 08:21:19 UTC (rev 6200)
@@ -5,7 +5,7 @@
 use Socket;
 use Storable qw(dclone);
 use IO::File;
-use PVE::Tools qw(run_command);
+use PVE::Tools;
 use PVE::INotify;
 use PVE::IPCC;
 use PVE::SafeSyslog;
@@ -49,6 +49,30 @@
     '/qemu-server/' => 1,
 };
 
+# only write output if something fails
+sub run_silent_cmd {
+    my ($cmd) = @_;
+
+    my $outbuf = '';
+
+    my $record_output = sub {
+	$outbuf .= shift;
+	$outbuf .= "\n";
+    };
+
+    eval {
+	PVE::Tools::run_command($cmd, outfunc => $record_output, 
+				errfunc => $record_output);
+    };
+
+    my $err = $@;
+
+    if ($err) {
+	print STDERR $outbuf;
+	die $err;
+    }
+}
+
 sub check_cfs_is_mounted {
     my ($noerr) = @_;
 
@@ -87,10 +111,10 @@
     mkdir $authdir || die "unable to create dir '$authdir' - $!\n";
 
     my $cmd = "openssl genrsa -out '$authprivkeyfn' 2048";
-    run_command($cmd);
+    run_silent_cmd($cmd);
 
     $cmd = "openssl rsa -in '$authprivkeyfn' -pubout -out '$authpubkeyfn'";
-    run_command($cmd)
+    run_silent_cmd($cmd)
 }
 
 sub gen_pveca_key {
@@ -98,7 +122,7 @@
     return if -f $pveca_key_fn;
 
     eval {
-	run_command(['openssl', 'genrsa', '-out', $pveca_key_fn, '2048']);
+	run_silent_cmd(['openssl', 'genrsa', '-out', $pveca_key_fn, '2048']);
     };
 
     die "unable to generate pve ca key:\n$@" if $@;
@@ -117,10 +141,10 @@
     my $nid = (split (/\s/, `md5sum '$pveca_key_fn'`))[0] || time();
 
     eval {
-	run_command(['openssl', 'req', '-batch', '-days', '3650', '-new',
-		     '-x509', '-nodes', '-key',
-		     $pveca_key_fn, '-out', $pveca_cert_fn, '-subj',
-		     "/CN=Proxmox Virtual Environment/OU=$nid/O=PVE Cluster Manager CA/"]);
+	run_silent_cmd(['openssl', 'req', '-batch', '-days', '3650', '-new',
+			'-x509', '-nodes', '-key',
+			$pveca_key_fn, '-out', $pveca_cert_fn, '-subj',
+			"/CN=Proxmox Virtual Environment/OU=$nid/O=PVE Cluster Manager CA/"]);
     };
 
     die "generating pve root certificate failed:\n$@" if $@;
@@ -133,7 +157,7 @@
     return if -f $pvessl_key_fn;
 
     eval {
-	run_command(['openssl', 'genrsa', '-out', $pvessl_key_fn, '2048']);
+	run_silent_cmd(['openssl', 'genrsa', '-out', $pvessl_key_fn, '2048']);
     };
 
     die "unable to generate pve ssl key:\n$@" if $@;
@@ -144,7 +168,7 @@
     return if -f $pvewww_key_fn;
 
     eval {
-	run_command(['openssl', 'genrsa', '-out', $pvewww_key_fn, '2048']);
+	run_silent_cmd(['openssl', 'genrsa', '-out', $pvewww_key_fn, '2048']);
     };
 
     die "unable to generate pve www key:\n$@" if $@;
@@ -211,8 +235,8 @@
     unlink $reqfn;
 
     eval {
-	run_command(['openssl', 'req', '-batch', '-new', '-config', $cfgfn,
-		     '-key', $pvessl_key_fn, '-out', $reqfn]);
+	run_silent_cmd(['openssl', 'req', '-batch', '-new', '-config', $cfgfn,
+			'-key', $pvessl_key_fn, '-out', $reqfn]);
     };
 
     if (my $err = $@) {
@@ -224,10 +248,10 @@
     update_serial("0000000000000000") if ! -f $pveca_srl_fn;
 
     eval {
-	run_command(['openssl', 'x509', '-req', '-in', $reqfn, '-days', '3650',
-		     '-out', $pvessl_cert_fn, '-CAkey', $pveca_key_fn,
-		     '-CA', $pveca_cert_fn, '-CAserial', $pveca_srl_fn,
-		     '-extfile', $cfgfn]);
+	run_silent_cmd(['openssl', 'x509', '-req', '-in', $reqfn, '-days', '3650',
+			'-out', $pvessl_cert_fn, '-CAkey', $pveca_key_fn,
+			'-CA', $pveca_cert_fn, '-CAserial', $pveca_srl_fn,
+			'-extfile', $cfgfn]);
     };
 
     if (my $err = $@) {



More information about the pve-devel mailing list