about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTAAProt.h
blob: 22e3d928d370058e5f0f4e961d0a7759bd9cff84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*                                   PROTECTION SETUP FILE

 */

#ifndef HTAAPROT_H
#define HTAAPROT_H

#include <HTGroup.h>
#include <HTAssoc.h>

#ifdef __cplusplus
extern "C" {
#endif
/*

Server's Representation of Document (Tree) Protections

 */ typedef struct {
	char *ctemplate;	/* Template for this protection         */
	char *filename;		/* Current document file                */
	char *uid_name;		/* Effective uid (name of it)           */
	char *gid_name;		/* Effective gid (name of it)           */
	GroupDef *mask_group;	/* Allowed users and IP addresses       */
	HTList *valid_schemes;	/* Valid authentication schemes         */
	HTAssocList *values;	/* Association list for scheme specific */
	/* parameters.                          */
    } HTAAProt;

/*

Callbacks for rule system

   The following three functioncs are called by the rule system:

      HTAA_clearProtections() when starting to translate a filename

      HTAA_setDefaultProtection() when "defprot" rule is matched

      HTAA_setCurrentProtection() when "protect" rule is matched

   Protection setup files are cached by these functions.

 */

/* PUBLIC                                       HTAA_setDefaultProtection()
 *              SET THE DEFAULT PROTECTION MODE
 *              (called by rule system when a
 *              "defprot" rule is matched)
 * ON ENTRY:
 *      cur_docname     is the current result of rule translations.
 *      prot_filename   is the protection setup file (second argument
 *                      for "defprot" rule, optional)
 *      eff_ids         contains user and group names separated by
 *                      a dot, corresponding to the effective uid
 *                      gid under which the server should run,
 *                      default is "nobody.nogroup" (third argument
 *                      for "defprot" rule, optional; can be given
 *                      only if protection setup file is also given).
 *
 * ON EXIT:
 *      returns         nothing.
 *                      Sets the module-wide variable default_prot.
 */
    extern void HTAA_setDefaultProtection(const char *cur_docname,
					  const char *prot_filename,
					  const char *eff_ids);

/* PUBLIC                                       HTAA_setCurrentProtection()
 *              SET THE CURRENT PROTECTION MODE
 *              (called by rule system when a
 *              "protect" rule is matched)
 * ON ENTRY:
 *      cur_docname     is the current result of rule translations.
 *      prot_filename   is the protection setup file (second argument
 *                      for "protect" rule, optional)
 *      eff_ids         contains user and group names separated by
 *                      a dot, corresponding to the effective uid
 *                      gid under which the server should run,
 *                      default is "nobody.nogroup" (third argument
 *                      for "protect" rule, optional; can be given
 *                      only if protection setup file is also given).
 *
 * ON EXIT:
 *      returns         nothing.
 *                      Sets the module-wide variable current_prot.
 */
    extern void HTAA_setCurrentProtection(const char *cur_docname,
					  const char *prot_filename,
					  const char *eff_ids);

/* SERVER INTERNAL                                      HTAA_clearProtections()
 *              CLEAR DOCUMENT PROTECTION MODE
 *              (ALSO DEFAULT PROTECTION)
 *              (called by the rule system)
 * ON ENTRY:
 *      No arguments.
 *
 * ON EXIT:
 *      returns nothing.
 *              Frees the memory used by protection information.
 */
    extern void HTAA_clearProtections(void);

/*

Getting Protection Settings

      HTAA_getCurrentProtection() returns the current protection mode (if there was a
      "protect" rule). NULL, if no "protect" rule has been matched.

      HTAA_getDefaultProtection() sets the current protection mode to what it was set to
      by "defprot" rule and also returns it (therefore after this call also
      HTAA_getCurrentProtection() returns the same structure.

 */

/* PUBLIC                                       HTAA_getCurrentProtection()
 *              GET CURRENT PROTECTION SETUP STRUCTURE
 *              (this is set up by callbacks made from
 *               the rule system when matching "protect"
 *               (and "defprot") rules)
 * ON ENTRY:
 *      HTTranslate() must have been called before calling
 *      this function.
 *
 * ON EXIT:
 *      returns a HTAAProt structure representing the
 *              protection setup of the HTTranslate()'d file.
 *              This must not be free()'d.
 */
    extern HTAAProt *HTAA_getCurrentProtection(void);

/* PUBLIC                                       HTAA_getDefaultProtection()
 *              GET DEFAULT PROTECTION SETUP STRUCTURE
 *              (this is set up by callbacks made from
 *               the rule system when matching "defprot"
 *               rules)
 * ON ENTRY:
 *      HTTranslate() must have been called before calling
 *      this function.
 *
 * ON EXIT:
 *      returns a HTAAProt structure representing the
 *              default protection setup of the HTTranslate()'d
 *              file (if HTAA_getCurrentProtection() returned
 *              NULL, i.e., if there is no "protect" rule
 *              but ACL exists, and we need to know default
 *              protection settings).
 *              This must not be free()'d.
 */
    extern HTAAProt *HTAA_getDefaultProtection(void);

/*

Get User and Group IDs to Which Set to

 */

#ifndef NOUSERS
/* PUBLIC                                                       HTAA_getUid()
 *              GET THE USER ID TO CHANGE THE PROCESS UID TO
 * ON ENTRY:
 *      No arguments.
 *
 * ON EXIT:
 *      returns the uid number to give to setuid() system call.
 *              Default is 65534 (nobody).
 */
    extern int HTAA_getUid(void);

/* PUBLIC                                                       HTAA_getGid()
 *              GET THE GROUP ID TO CHANGE THE PROCESS GID TO
 * ON ENTRY:
 *      No arguments.
 *
 * ON EXIT:
 *      returns the uid number to give to setgid() system call.
 *              Default is 65534 (nogroup).
 */
    extern int HTAA_getGid(void);
#endif				/* !NOUSERS */

/* PUBLIC                                                       HTAA_UidToName
 *              GET THE USER NAME
 * ON ENTRY:
 *      The user-id
 *
 * ON EXIT:
 *      returns the user name
 */
    extern const char *HTAA_UidToName(int uid);

/* PUBLIC                                                       HTAA_NameToUid
 *              GET THE USER ID
 * ON ENTRY:
 *      The user-name
 *
 * ON EXIT:
 *      returns the user id
 */
    extern int HTAA_NameToUid(const char *name);

/* PUBLIC                                                       HTAA_GidToName
 *              GET THE GROUP NAME
 * ON ENTRY:
 *      The group-id
 *
 * ON EXIT:
 *      returns the group name
 */
    extern const char *HTAA_GidToName(int gid);

/* PUBLIC                                                       HTAA_NameToGid
 *              GET THE GROUP ID
 * ON ENTRY:
 *      The group-name
 *
 * ON EXIT:
 *      returns the group id
 */
    extern int HTAA_NameToGid(const char *name);

#ifdef __cplusplus
}
#endif
#endif				/* not HTAAPROT_H */