From 4e2ac985c48ca1e7e92fbba4586df44666bd7da6 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 24 Mar 2009 15:38:21 +0000 Subject: [PATCH] Passgen (admin part) --- config.sig | 2 ++ config.sml | 2 ++ passgen.mlt | 21 +++++++++++++++++++++ passgen.sig | 3 +++ passgen.sml | 16 ++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 passgen.mlt create mode 100644 passgen.sig create mode 100644 passgen.sml diff --git a/config.sig b/config.sig index 22145f9..a18551b 100644 --- a/config.sig +++ b/config.sig @@ -8,4 +8,6 @@ val dbstring : string val kerberosSuffix : string val passwordFiles : string +val passgenDbstring : string + end diff --git a/config.sml b/config.sml index acb31cc..4cef3b4 100644 --- a/config.sml +++ b/config.sml @@ -11,4 +11,6 @@ val kerberosSuffix = "@HCOOP.NET" val passwordFiles = "/var/lib/portal/" +val passgenDbstring = "dbname='passgen' user='www-data'" + end diff --git a/passgen.mlt b/passgen.mlt new file mode 100644 index 0000000..48be3b4 --- /dev/null +++ b/passgen.mlt @@ -0,0 +1,21 @@ +<% @header[("title", ["Generated passwords"])]; + +Group.requireGroupNum 0; + +if $"id" <> "" then + val id = Web.stoi ($"id"); + switch PassGen.lookup id of + NONE => %>ID not found!<% + | SOME pass => %> + + +
ID: <% id %>
Password: <% pass %>
<% + end +end %> + +

+ + +
ID:

+ +<% @footer[] %> \ No newline at end of file diff --git a/passgen.sig b/passgen.sig new file mode 100644 index 0000000..da099d4 --- /dev/null +++ b/passgen.sig @@ -0,0 +1,3 @@ +signature PASSGEN = sig + val lookup : int -> string option +end diff --git a/passgen.sml b/passgen.sml new file mode 100644 index 0000000..794c1f4 --- /dev/null +++ b/passgen.sml @@ -0,0 +1,16 @@ +structure PassGen :> PASSGEN = struct + +open Sql Init + +fun lookup id = + let + val db = C.conn Config.passgenDbstring + in + (case C.oneOrNoRows db ($`SELECT pass FROM Pass WHERE id = ^(C.intToSql id)`) of + NONE => NONE + | SOME [pass] => SOME (C.stringFromSql pass) + | _ => raise Fail "Bad \"SELECT pass\" row") + before C.close db + end + +end -- 2.20.1