Blob Blame History Raw
From 757976faf59bc2caad63102c1b17463933c1b7fa Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Fri, 19 Feb 2016 06:51:32 +0100
Subject: [PATCH] Allow disabling particular tasks in the manager

Userspace core support is still a bit problematic, so it is not a good
idea to offer this type of tasks to users in the manager.

I decided to move the task forms to separate files because I wanted to
avoid the need to escape strings in Python code.

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 src/Makefile.am                     |  2 ++
 src/config/retrace-server.conf      |  7 +++++++
 src/manager.wsgi                    | 13 +++++++++++++
 src/manager.xhtml                   | 31 ++-----------------------------
 src/manager_usrcore_task_form.xhtml | 17 +++++++++++++++++
 src/manager_vmcore_task_form.xhtml  | 13 +++++++++++++
 6 files changed, 54 insertions(+), 29 deletions(-)
 create mode 100644 src/manager_usrcore_task_form.xhtml
 create mode 100644 src/manager_vmcore_task_form.xhtml

diff --git a/src/Makefile.am b/src/Makefile.am
index dfd3f53..043c416 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,6 +39,8 @@ interface_PYTHON = backtrace.wsgi \
 
 interface_DATA = index.xhtml \
                  manager.xhtml \
+                 manager_vmcore_task_form.xhtml \
+                 manager_usrcore_task_form.xhtml \
                  managertask.xhtml \
                  stats.xhtml
 # interfacedir should probably be $$(pkgdatadir)/retrace
diff --git a/src/config/retrace-server.conf b/src/config/retrace-server.conf
index 28991a7..8eab59f 100644
--- a/src/config/retrace-server.conf
+++ b/src/config/retrace-server.conf
@@ -22,6 +22,12 @@ AllowExternalDir = 0
 # Allow to create tasks owned by task manager (security risk)
 AllowTaskManager = 0
 
+# Allow to create VMCore tasks in the task manager
+AllowVMCoreTask = 1
+
+# Allow to create Userspace core tasks in the task manager
+AllowUsrCoreTask = 1
+
 # If white list is disabled, anyone can delete tasks
 TaskManagerAuthDelete = 0
 
@@ -143,6 +149,7 @@ EmailNotify = 0
 # Who sends the e-mail notifications
 EmailNotifyFrom = retrace@localhost
 
+
 [archhosts]
 i386 =
 x86_64 =
diff --git a/src/manager.wsgi b/src/manager.wsgi
index 93ead9d..59d1372 100644
--- a/src/manager.wsgi
+++ b/src/manager.wsgi
@@ -602,6 +602,18 @@ def application(environ, start_response):
 
     custom_url = "%s/__custom__" % match.group(1)
 
+    vmcore_form = ""
+    if CONFIG["AllowVMCoreTask"]:
+        with open("/usr/share/retrace-server/manager_vmcore_task_form.xhtml") as f:
+            vmcore_form = f.read(1 << 20) # 1MB
+    output = output.replace("{vmcore_task_form}", vmcore_form)
+
+    usrcore_form = ""
+    if CONFIG["AllowUsrCoreTask"]:
+        with open("/usr/share/retrace-server/manager_usrcore_task_form.xhtml") as f:
+            usrcore_form = f.read(1 << 20) # 1MB
+    output = output.replace("{usrcore_task_form}", usrcore_form)
+
     output = output.replace("{title}", title)
     output = output.replace("{sitename}", sitename)
     output = output.replace("{available_str}", available_str)
@@ -619,4 +631,5 @@ def application(environ, start_response):
     output = output.replace("{running}", "\n            ".join(running))
     output = output.replace("{finished}", "\n            ".join(finished))
 
+
     return response(start_response, "200 OK", output, [("Content-Type", "text/html")])
diff --git a/src/manager.xhtml b/src/manager.xhtml
index 041f994..5c3f231 100644
--- a/src/manager.xhtml
+++ b/src/manager.xhtml
@@ -182,35 +182,8 @@
       <input type="text" name="filter" />
       <input type="submit" value="Filter" class="submit" />
     </form>
-    <h2>vmcore</h2>
-    <form method="post" action="{create_custom_url}" id="custom">
-      <div>
-        <span class="formsubhead">Kernel version (e.g. <code>2.6.32-287.el6.x86_64</code>, empty to autodetect):</span> <input type="text" name="vra" />
-        <input type="checkbox" checked="checked" name="debug" class="checkbox" /><span class="formsubhead"> Be more verbose in case of error</span>
-      </div>
-      <div>
-        <span class="formhead">Custom core location:</span> <input type="text" name="custom_url" class="url" />
-        <input type="hidden" name="task_type" value="vmcore">
-        <input type="submit" value="Create vmcore task" class="submit" />
-        <div class="center">Any URL that <code>wget</code> can download or a local path (<code>file:///foo/bar</code> or just <code>/foo/bar</code>)</div>
-      </div>
-    </form>
-    <h2>coredump</h2>
-    <form method="post" action="{create_custom_url}" id="custom">
-      <div>
-        <p>All of these three fields override contents of <code>package</code>, <code>executable</code> and <code>os_release</code> files contained in the coredump archive. If you're uploading you have just the bare (compressed) coredump, you must specify these.</p>
-        <input type="checkbox" checked="checked" name="debug" class="checkbox" /><span class="formsubhead"> Be more verbose in case of error</span><br/>
-        <span class="formsubhead">Package (e.g. <code>coreutils-8.22-11.el7</code>):</span> <input type="text" name="package" /><br/>
-        <span class="formsubhead">Executable (e.g. <code>/usr/bin/sleep</code>):</span> <input type="text" name="executable" /><br/>
-        <span class="formsubhead">OS Release (e.g. <code>Red Hat Enterprise Linux Workstation release 7.0 (Maipo)</code>):</span> <input type="text" name="os_release" />
-      </div>
-      <div>
-        <span class="formhead">Custom core location:</span> <input type="text" name="custom_url" class="url" />
-        <input type="hidden" name="task_type" value="coredump">
-        <input type="submit" value="Create coredump task" class="submit" />
-        <div class="center">Any URL that <code>wget</code> can download or a local path (<code>file:///foo/bar</code> or just <code>/foo/bar</code>)</div>
-      </div>
-    </form>
+{vmcore_task_form}
+{usrcore_task_form}
     <div id="main">
       <div id="left">
         <div id="available">
diff --git a/src/manager_usrcore_task_form.xhtml b/src/manager_usrcore_task_form.xhtml
new file mode 100644
index 0000000..c210600
--- /dev/null
+++ b/src/manager_usrcore_task_form.xhtml
@@ -0,0 +1,17 @@
+    <h2>userspace core</h2>
+    <form method="post" action="{create_custom_url}" id="custom">
+      <div>
+        <p>All of these three fields override contents of <code>package</code>, <code>executable</code> and <code>os_release</code> files contained in the coredump archive. If you're uploading you have just the bare (compressed) coredump, you must specify these.</p>
+        <input type="checkbox" checked="checked" name="debug" class="checkbox" /><span class="formsubhead"> Be more verbose in case of error</span><br/>
+        <span class="formsubhead">Package (e.g. <code>coreutils-8.22-11.el7</code>):</span> <input type="text" name="package" /><br/>
+        <span class="formsubhead">Executable (e.g. <code>/usr/bin/sleep</code>):</span> <input type="text" name="executable" /><br/>
+        <span class="formsubhead">OS Release (e.g. <code>Red Hat Enterprise Linux Workstation release 7.0 (Maipo)</code>):</span> <input type="text" name="os_release" />
+      </div>
+      <div>
+        <span class="formhead">Custom core location:</span> <input type="text" name="custom_url" class="url" />
+        <input type="hidden" name="task_type" value="coredump">
+        <input type="submit" value="Create coredump task" class="submit" />
+        <div class="center">Any URL that <code>wget</code> can download or a local path (<code>file:///foo/bar</code> or just <code>/foo/bar</code>)</div>
+      </div>
+    </form>
+
diff --git a/src/manager_vmcore_task_form.xhtml b/src/manager_vmcore_task_form.xhtml
new file mode 100644
index 0000000..2307b3b
--- /dev/null
+++ b/src/manager_vmcore_task_form.xhtml
@@ -0,0 +1,13 @@
+    <h2>vmcore</h2>
+    <form method="post" action="{create_custom_url}" id="custom">
+      <div>
+        <span class="formsubhead">Kernel version (e.g. <code>2.6.32-287.el6.x86_64</code>, empty to autodetect):</span> <input type="text" name="vra" />
+        <input type="checkbox" checked="checked" name="debug" class="checkbox" /><span class="formsubhead"> Be more verbose in case of error</span>
+      </div>
+      <div>
+        <span class="formhead">Custom core location:</span> <input type="text" name="custom_url" class="url" />
+        <input type="hidden" name="task_type" value="vmcore">
+        <input type="submit" value="Create vmcore task" class="submit" />
+        <div class="center">Any URL that <code>wget</code> can download or a local path (<code>file:///foo/bar</code> or just <code>/foo/bar</code>)</div>
+      </div>
+    </form>
-- 
2.7.1