Requests for FTP access
authoradamch <adamch>
Sun, 9 Oct 2005 18:13:37 +0000 (18:13 +0000)
committeradamch <adamch>
Sun, 9 Oct 2005 18:13:37 +0000 (18:13 +0000)
sec.mlt
sec.sig
sec.sml

diff --git a/sec.mlt b/sec.mlt
index b8c863c..9e5c0dd 100644 (file)
--- a/sec.mlt
+++ b/sec.mlt
@@ -8,6 +8,7 @@ val uname = case $"uname" of
 val socks = Sec.socketPerms uname;
 val tpe = Sec.isTpe uname;
 val cron = Sec.cronAllowed uname;
+val ftp = Sec.ftpAllowed uname;
 
 ref showNormal = true;
 
@@ -50,6 +51,19 @@ elseif $"cmd" = "cron2" then
        end
        %><h3><b>Request added</b></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> be <b><% ftp %></b>?<br>
+       <a href="sec?cmd=ftp2&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 (you, String.concat [uname, ": ", ftp, " FTP access"], $"msg");
+       if not (Sec.Req.notifyNew id) then
+               %><h3><b>Error sending e-mail notification</b></h3><%
+       end
+       %><h3><b>Request added</b></h3><%
+
 elseif $"cmd" = "rule" then
        showNormal := false;
        val rule = $"rule";
@@ -246,6 +260,21 @@ if showNormal then %>
 </table>
 </form>
 
+<h3><b>Request change to your FTP permissions</b></h3>
+
+<form action="sec" method="post">
+<input type="hidden" name="uname" value="<% uname %>">
+<input type="hidden" name="cmd" value="ftp">
+<table>
+<tr> <td align="right"><b>Allowed to use FTP?</b></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 align="right" valign="top"><b>Reason:</b></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 uname;
 switch rules of
   _::_ => %>
diff --git a/sec.sig b/sec.sig
index 494e5d7..29882ad 100644 (file)
--- a/sec.sig
+++ b/sec.sig
@@ -13,6 +13,7 @@ signature SEC = sig
     val socketPerms : string -> socket_perms
     val isTpe : string -> bool
     val cronAllowed : string -> bool
+    val ftpAllowed : string -> bool
 
     val findFirewallRules : string -> string list
 end
diff --git a/sec.sml b/sec.sml
index cfa6d69..af3f813 100644 (file)
--- a/sec.sml
+++ b/sec.sml
@@ -99,9 +99,9 @@ fun findFirewallRules uname =
        before TextIO.closeIn inf
     end
 
-fun cronAllowed uname =
+fun somethingAllowed fname uname =
     let
-       val inf = TextIO.openIn "/etc/cron.allow"
+       val inf = TextIO.openIn fname
        val uname' = uname ^ "\n"
 
        fun loop () =
@@ -113,4 +113,7 @@ fun cronAllowed uname =
        before TextIO.closeIn inf
     end
 
+val cronAllowed = somethingAllowed "/etc/cron.allow"
+val ftpAllowed = somethingAllowed "/etc/ftpusers"
+
 end