Commit | Line | Data |
---|---|---|
eafe3d52 AC |
1 | structure ChooseDomain :> CHOOSE_DOMAIN = struct |
2 | ||
3 | fun domains user = | |
4 | let | |
5 | val proc = Unix.execute ("/bin/sh", ["-c", "DOMTOOL_USER=hcoop /usr/local/bin/domtool-admin perms " ^ user]) | |
6 | val inf = Unix.textInstreamOf proc | |
7 | ||
8 | fun loop () = | |
9 | case TextIO.inputLine inf of | |
10 | NONE => [] | |
11 | | SOME line => | |
12 | case String.tokens (fn ch => ch = #":") line of | |
13 | ["domain", domains] => String.tokens Char.isSpace domains | |
14 | | _ => loop () | |
15 | in | |
16 | loop () | |
17 | before ignore (Unix.reap proc) | |
18 | end | |
19 | ||
20 | fun yourDomain {user, domain} = List.exists (fn x => x = domain) (domains user) | |
21 | ||
22 | end |