1f378856958845ff0b41986f9bdcfa76cc917a45
[hcoop/domtool2.git] / src / domain.sig
1 (* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *)
18
19 (* Domain-related primitive actions *)
20
21 signature DOMAIN = sig
22
23 val declareClient : unit -> unit
24 val fakePrivileges : unit -> unit
25
26 val yourPath : string -> bool
27 val isIdent : char -> bool
28 val validHost : string -> bool
29 val validDomain : string -> bool
30 val validIpv6 : string -> bool
31 val validIp : string -> bool
32 val yourDomain : string -> bool
33 val validUser : string -> bool
34 val validEmailUser : string -> bool
35
36 val ip : string Env.arg
37
38 val registerResetGlobal : (unit -> unit) -> unit
39 val registerResetLocal : (unit -> unit) -> unit
40 (* Register functions for clearing out all Domtool configuration at the global
41 * (AFS) and local levels, respectively. *)
42
43 val resetGlobal : unit -> unit
44 val resetLocal : unit -> unit
45 (* Call all registered functions *)
46
47 val registerBefore : (string -> unit) -> unit
48 val registerAfter : (string -> unit) -> unit
49 (* Register handlers to run just before and after entering a domain
50 * block. *)
51
52 val currentDomain : unit -> string
53
54 val domainFile : {node : string, name : string} -> TextIO.outstream
55 (* Open one of the current domain's configuration files for a particular
56 * node. *)
57
58 val currentAliasDomains : unit -> string list
59 val currentDomains : unit -> string list
60 (* Return the auxiliary domains being configured (not including
61 * currentDomain) or the list of all domains being configured,
62 * respectively. *)
63
64 (* The type of a set of files open for different domains. *)
65 type files = {write : string -> unit, (* Write a string to each. *)
66 writeDom : unit -> unit, (* Write each's domain name to it. *)
67 close : unit -> unit} (* Close all files. *)
68
69 val domainsFile : {node : string, name : string} -> files
70 (* Open a configuration file for every domain being configured. *)
71
72 val dnsMaster : unit -> string option
73 (* Name of the node that is the DNS master for the current domain, if there
74 * is one *)
75
76 val nodes : string list
77 (* Names of all system nodes *)
78 val nodeMap : string Ast.StringMap.map
79 (* Map node names to IP addresses *)
80 val nodeIp : string -> string
81 (* Look up a node in nodeMap *)
82
83 val setUser : string -> unit
84 val getUser : unit -> string
85 (* Name of the UNIX user providing this configuration *)
86
87 val your_domains : unit -> DataStructures.StringSet.set
88 (* The domains the current user may configure *)
89
90 val your_users : unit -> DataStructures.StringSet.set
91 val your_groups : unit -> DataStructures.StringSet.set
92 val your_paths : unit -> DataStructures.StringSet.set
93 (* UNIX users, groups, and paths the user may act with *)
94
95 val get_context : unit -> OpenSSL.context
96 val set_context : OpenSSL.context -> unit
97
98 val hasPriv : string -> bool
99
100 val rmdom : string list -> unit
101 val rmdom' : string -> string list -> unit
102
103 val homedirOf : string -> string
104 val homedir : unit -> string
105
106 type subject = {node : string, domain : string}
107
108 val registerDescriber : (subject -> string) -> unit
109 (* When a user runs [domtool-admin describe $DOM], every function passed to
110 * [registerDescriber] will be run on [$DOM]. *)
111 val describe : string -> string
112 (* Argument is domain to describe, over all nodes. *)
113
114 datatype description =
115 Filename of { filename : string, heading : string, showEmpty : bool }
116 | Extension of { extension : string, heading : string -> string }
117
118 val considerAll : description list -> subject -> string
119 (* Find files in a domain directory matching some patterns and generate
120 * headings and contents listings for them. *)
121
122 (* Callbacks to run whenever the set of Domtool users has changed *)
123 val registerOnUsersChange : (unit -> unit) -> unit
124 val onUsersChange : unit -> unit
125 end