Hello,

we found out that script contents are not properly displayed in the web UI
in "Systems" -> "Events" -> "History" (it's a perl page ...).

To reproduce:

- choose a system and go to "Remote Command"
- type in some script contents, e.g. "a b c d e f g h"
- schedule the command
- go to "Events" and click on the one just scheduled
- in the "Details" you will see (for the example above):

x23212f62696e2f73680a0a61206220632064206520662020672068

which is the ASCII code for

"
#!/bin/sh
a b c d e f g h
"

The attached patch fixes the problem by converting the ASCII codes into
a string using the pack() function.

Regards,
Johannes

-- 
SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
>From b00d36ff71783dd870e67cc969a9de2f55df4221 Mon Sep 17 00:00:00 2001
From: Johannes Renner <jren...@suse.de>
Date: Tue, 14 Aug 2012 11:46:43 +0200
Subject: [PATCH] Convert script contents from hex to string

---
 web/modules/rhn/RHN/Server.pm |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/web/modules/rhn/RHN/Server.pm b/web/modules/rhn/RHN/Server.pm
index 3022a09..6c12939 100644
--- a/web/modules/rhn/RHN/Server.pm
+++ b/web/modules/rhn/RHN/Server.pm
@@ -491,8 +491,9 @@ sub render {
   # sigh.  there has to be an easier way to filter out ansi control codes...
   $output->{OUTPUT} =~ s{\x1B\[(\d+[ABCDG]|[suK]|2J|(\d+;)*\d+m|=\d+[hl])}{}gism;
 
+  my $script = pack("(H2)*", (substr($action->script_script, 1) =~ m/../g));
   $ret->{server_event_details} .=
-    sprintf(<<EOQ, $run_as, $action->script_timeout || 0, PXT::HTML->htmlify_text($action->script_script));
+    sprintf(<<EOQ, $run_as, $action->script_timeout || 0, PXT::HTML->htmlify_text($script));
 <br/><br/>
 Run as: <strong>%s</strong><br/>
 Timeout: <strong>%d</strong> seconds<br/><br/>
-- 
1.7.7

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to