portal/cert: clarify intermediate cert requests
[hcoop/portal.git] / sec.mlt
diff --git a/sec.mlt b/sec.mlt
index 7afdced..020c0f9 100644 (file)
--- a/sec.mlt
+++ b/sec.mlt
@@ -2,7 +2,7 @@
 val yourname = Init.getUserName ();
 
 val nodeNum = case $"node" of
-                 "" => 2
+                 "" => 4
                | node => Web.stoi node;
 val nodeName = Init.nodeName nodeNum;
 
@@ -13,7 +13,6 @@ val uname = case $"uname" of
 val socks = Sec.socketPerms {node = nodeNum, uname = uname};
 val tpe = Sec.isTpe {node = nodeNum, uname = uname};
 val cron = Sec.cronAllowed {node = nodeNum, uname = uname};
-val ftp = Sec.ftpAllowed {node = nodeNum, uname = uname};
 
 ref showNormal = true;
 
@@ -55,20 +54,6 @@ elseif $"cmd" = "cron2" then
                %><h3>Error sending e-mail notification</h3><%
        end
        %><h3>Request added</h3><%
-
-elseif $"cmd" = "ftp" then
-       showNormal := false;
-       val ftp = iff $"ftp" = "yes" then "enabled" else "disabled";
-       %>Are you sure you want to request that FTP permissions for <b><% Web.html uname %></b> on <b><% Web.html nodeName %></b> be <b><% ftp %></b>?<br>
-       <a href="sec?cmd=ftp2&node=<% nodeNum %>&uname=<% Web.urlEncode uname %>&ftp=<% ftp %>&msg=<% Web.urlEncode ($"msg") %>">Yes, place the request!</a><%
-elseif $"cmd" = "ftp2" then
-       val ftp = iff $"ftp" = "enabled" then "enable" else "disable";
-       val id = Sec.Req.add {usr = you, node = nodeNum, data = String.concat [uname, ": ", ftp, " FTP access"], msg = $"msg"};
-       if not (Sec.Req.notifyNew id) then
-               %><h3>Error sending e-mail notification</h3><%
-       end
-       %><h3>Request added</h3><%
-
 elseif $"cmd" = "rule" then
        showNormal := false;
        val rule = $"rule";
@@ -84,7 +69,7 @@ elseif $"cmd" = "rule2" then
        val rule = $"rule";
 
        if Sec.validRule rule then
-               val id = Sec.Req.add {usr = you, node = nodeNum, data = String.concat ["Add firewall rule \"", uname, " ", rule, "\""], msg = $"msg"};
+               val id = Sec.Req.add {usr = you, node = nodeNum, data = String.concat ["Add firewall rule \"", nodeName, " ", uname, " ", rule, "\""], msg = $"msg"};
                if not (Sec.Req.notifyNew id) then
                        %><h3>Error sending e-mail notification</h3><%
                end
@@ -132,7 +117,7 @@ elseif $"cmd" = "open" then
 <br><hr><br>
 <table class="blanks">
 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
-<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td></tr>
 <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
 <tr> <td>Request:</td> <td><% #data req %></td> </tr>
 <tr> <td>Msg:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr>
@@ -153,7 +138,7 @@ elseif $"cmd" = "list" then
 <br><hr><br>
 <table class="blanks">
 <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
-<tr> <td>Time:</td> <td colspan="2"><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td></tr>
 <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
 <tr> <td>Request:</td> <td><% #data req %></td> </tr>
 <tr> <td>Reason:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr>
@@ -177,7 +162,7 @@ elseif $"mod" <> "" then
 <input type="hidden" name="save" value="<% id %>">
 <table class="blanks">
 <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
-<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td></tr>
 <tr> <td>Status:</td> <td><select name="status">
        <option value="0"<% if #status req = Sec.Req.NEW then %> selected<% end %>>New</option>
        <option value="1"<% if #status req = Sec.Req.INSTALLED then %> selected<% end %>>Installed</option>
@@ -185,9 +170,9 @@ elseif $"mod" <> "" then
 </select></td> </tr>
 <tr> <td>Node:</td> <td><select name="node">
 <% foreach node in Init.listNodes () do %>
-       <option value="<% #id node %>"<% if nodeNum = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>)</option>
+       <option value="<% #id node %>"<% if #id node = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>)</option>
 <% end %></select></td> </tr>
-<tr> <td>Request:</td> <td><input name="req" value="<% #data req %>"></td> </tr>
+<tr> <td>Request:</td> <td><input name="req" value="<% Web.html (#data req) %>"></td> </tr>
 <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
 <tr> <td><input type="submit" value="Save"></td> </tr>
 </table>
@@ -201,10 +186,8 @@ elseif $"mod" <> "" then
        val oldStatus = #status req;
        val newStatus = Sec.Req.statusFromInt (Web.stoi ($"status"));
        Sec.Req.modify {req with node = nodeNum, data = $"req", msg = $"msg", status = newStatus};
-       if oldStatus <> newStatus then
-               if not (Sec.Req.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
-                       %><h3>Error sending e-mail notification</h3><%
-               end
+       if not (Sec.Req.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
+               %><h3>Error sending e-mail notification</h3><%
        end
        %><h3>Request modified</h3>
        Back to: <a href="sec?cmd=open">open requests</a>, <a href="sec?cmd=list">all requests</a>
@@ -228,129 +211,9 @@ elseif $"mod" <> "" then
 
 <% end;
 
-if showNormal then %>
-
-<table class="blanks">
-<form action="sec" method="post">
-<input type="hidden" name="uname" value="<% Web.html uname %>">
-<tr> <td>Machines:</td> <td><select name="node">
-<% foreach node in Init.listNodes () do %>
-       <option value="<% #id node %>"<% if nodeNum = #id node then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>)</option>
-<% end %></select></td>
-<td><input type="submit" value="Switch"></td> </tr>
-</form>
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<tr> <td>Your users:</td> <td><select name="uname">
-<% foreach name in (yourname :: Sec.findSubusers yourname) do %>
-       <option value="<% name %>"<% if uname = name then %> selected<% end %>><% name %></option>
-<% end %></select></td>
-<td><input type="submit" value="Switch"></td> </tr>
-</form>
-</table>
-
-<h3>Request socket permissions change</h3>
-
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<input type="hidden" name="uname" value="<% uname %>">
-<input type="hidden" name="cmd" value="socks">
-<table class="blanks">
-<tr> <td>New permissions:</td> <td><select name="socks">
-       <option value="none"<% if socks = Sec.NADA then %> selected<% end %>>None</option>
-       <option value="any"<% if socks = Sec.ANY then %> selected<% end %>>Any</option>
-       <option value="client"<% if socks = Sec.CLIENT_ONLY then %> selected<% end %>>Client only</option>
-       <option value="server"<% if socks = Sec.SERVER_ONLY then %> selected<% end %>>Server only</option>
-</select></td> </tr>
-<tr> <td>Reason:</td> <td><textarea name="msg" wrap="soft" rows="3" cols="80"></textarea></td> </tr>
-<tr> <td><input type="submit" value="Request"></td> </tr>
-</table>
-</form>
-
-<h3>Request change to your execute permissions</h3>
-
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<input type="hidden" name="uname" value="<% uname %>">
-<input type="hidden" name="cmd" value="tpe">
-<table class="blanks">
-<tr> <td>Trusted path executables only?</td> <td><select name="tpe">
-       <option value="no"<% if not tpe then %> selected<% end %>>No</option>
-       <option value="yes"<% if tpe then %> selected<% end %>>Yes</option>
-</select></td> </tr>
-<tr> <td>Reason:</td> <td><textarea name="msg" wrap="soft" rows="3" cols="80"></textarea></td> </tr>
-<tr> <td><input type="submit" value="Request"></td> </tr>
-</table>
-</form>
-
-<h3>Request change to your <tt>cron</tt> permissions</h3>
-
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<input type="hidden" name="uname" value="<% uname %>">
-<input type="hidden" name="cmd" value="cron">
-<table class="blanks">
-<tr> <td>Allowed to use cron?</td> <td><select name="cron">
-       <option value="no"<% if not cron then %> selected<% end %>>No</option>
-       <option value="yes"<% if cron then %> selected<% end %>>Yes</option>
-</select></td> </tr>
-<tr> <td>Reason:</td> <td><textarea name="msg" wrap="soft" rows="3" cols="80"></textarea></td> </tr>
-<tr> <td><input type="submit" value="Request"></td> </tr>
-</table>
-</form>
-
-<h3>Request change to your FTP permissions</h3>
-
-<p>Please read <a href="http://wiki.hcoop.net/wiki/FileTransfer">our wiki instructions on file transfer</a> before requesting FTP access. Almost everyone should use alternative protocols to FTP that provide superior security benefits.</p>
-
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<input type="hidden" name="uname" value="<% uname %>">
-<input type="hidden" name="cmd" value="ftp">
-<table class="blanks">
-<tr> <td>Allowed to use FTP?</td> <td><select name="ftp">
-       <option value="no"<% if not ftp then %> selected<% end %>>No</option>
-       <option value="yes"<% if ftp then %> selected<% end %>>Yes</option>
-</select></td> </tr>
-<tr> <td>Reason:</td> <td><textarea name="msg" wrap="soft" rows="3" cols="80"></textarea></td> </tr>
-<tr> <td><input type="submit" value="Request"></td> </tr>
-</table>
-</form>
-
-<% val rules = Sec.findFirewallRules {node = nodeNum, uname = uname};
-switch rules of
-  _::_ => %>
-<h3>Your firewall rules</h3>
-
-<% foreach rule in rules do %>
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<input type="hidden" name="uname" value="<% uname %>">
-<input type="hidden" name="modRule" value="<% Web.html rule %>">
-<input name="rule" value="<% Web.html rule %>">
-<a href="sec?delRule=<% Web.urlEncode rule %>">[Request deletion]</a>
-<input type="submit" value="Request change">
-</form><br>
-<% end
-end%>
-
-<h3>Request a new firewall rule</h3>
-
-<p>You can find a description of rule formats <a href="http://wiki.hcoop.net/wiki/FirewallRules">on our wiki</a>. Enter here the rule you want, without the initial <tt>user</tt> portion.</p>
-
-<p>Please note that <b>your firewall rule will be useless</b> if you don't first request the corresponding socket privileges at the top of this page.</p>
-
-<form action="sec" method="post">
-<input type="hidden" name="node" value="<% nodeNum %>">
-<input type="hidden" name="uname" value="<% uname %>">
-<input type="hidden" name="cmd" value="rule">
-<table class="blanks">
-<tr> <td>Rule</td> <td><input name="rule" size="80"></td> </tr>
-<tr> <td>Reason:</td> <td><textarea name="msg" wrap="soft" rows="3" cols="80"></textarea></td> </tr>
-<tr> <td><input type="submit" value="Request"></td> </tr>
-</table>
-</form>
-
-<% end %>
+if showNormal then
+  @secnormal [("uname", [uname]),
+              ("nodeNum", [Int.toString nodeNum])];
+end %>
 
 <% @footer[] %>
\ No newline at end of file