Commit | Line | Data |
---|---|---|
5a2cf523 CE |
1 | structure Domtool :> DOMTOOL = struct |
2 | ||
3 | fun perms class user = | |
4 | let | |
811dc1e5 | 5 | val proc = Unix.execute ("/bin/sh", ["-c", "DOMTOOL_USER=hcoop.daemon /usr/local/bin/domtool-admin perms " ^ user]) |
5a2cf523 CE |
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 | [class', permissions] => if class' = class then String.tokens Char.isSpace permissions else loop () | |
14 | | _ => loop () | |
15 | in | |
16 | loop () | |
17 | before ignore (Unix.reap proc) | |
18 | end | |
19 | ||
20 | fun hasPerm class user value = | |
21 | List.exists (fn x => x = value) (perms class user) | |
22 | ||
23 | end |