chiark / gitweb /
Major overhaul. Now uses DSA signatures rather than the bogus symmetric
[become] / src / rule.h
1 /* -*-c-*-
2  *
3  * $Id: rule.h,v 1.6 1998/04/23 13:27:31 mdw Exp $
4  *
5  * Managing rule sets
6  *
7  * (c) 1998 EBI
8  */
9
10 /*----- Licensing notice --------------------------------------------------*
11  *
12  * This file is part of `become'
13  *
14  * `Become' is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * `Become' is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with `become'; if not, write to the Free Software Foundation,
26  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  */
28
29 /*----- Revision history --------------------------------------------------*
30  *
31  * $Log: rule.h,v $
32  * Revision 1.6  1998/04/23 13:27:31  mdw
33  * Export structure of the rule list, for `bcquery's benefit.
34  *
35  * Revision 1.5  1998/01/12 16:46:26  mdw
36  * Fix copyright date.
37  *
38  * Revision 1.4  1997/09/17  10:27:17  mdw
39  * Use rewritten class handler.
40  *
41  * Revision 1.3  1997/08/20  16:22:49  mdw
42  * Rename `rule_reinit' to `rule_end' for more sensible restart.
43  *
44  * Revision 1.2  1997/08/04 10:24:25  mdw
45  * Sources placed under CVS control.
46  *
47  * Revision 1.1  1997/07/21  13:47:45  mdw
48  * Initial revision
49  *
50  */
51
52 #ifndef RULE_H
53 #define RULE_H
54
55 #ifdef __cplusplus
56   extern "C" {
57 #endif
58
59 /*----- Required headers --------------------------------------------------*/
60
61 #include <sys/types.h>
62 #include <sys/socket.h>
63 #include <netinet/in.h>
64 #include <arpa/inet.h>
65
66 #ifndef BECOME_H
67 #  include "become.h"
68 #endif
69
70 #ifndef CLASS_H
71 #  include "class.h"
72 #endif
73
74 /*----- Type definitions --------------------------------------------------*/
75
76 /* --- Rule block --- */
77
78 typedef struct rule {
79   struct rule *next;                    /* Next rule in the list */
80   class_node *host;                     /* Hosts this rule applies to */
81   class_node *from;                     /* From users in this class */
82   class_node *to;                       /* To users in this class */
83   class_node *cmd;                      /* To run commands in this class */
84 } rule;
85
86 /*----- Functions provided ------------------------------------------------*/
87
88 /* --- @rule_init@ --- *
89  *
90  * Arguments:   ---
91  *
92  * Returns:     ---
93  *
94  * Use:         Intialises the rule database.
95  */
96
97 extern void rule_init(void);
98
99 /* --- @rule_end@ --- *
100  *
101  * Arguments:   ---
102  *
103  * Returns:     ---
104  *
105  * Use:         Empties the rule database.
106  */
107
108 extern void rule_end(void);
109
110 /* --- @rule_list@ --- *
111  *
112  * Arguments:   ---
113  *
114  * Returns:     The list of rules.
115  *
116  * Use:         Returns the address of the first node in the rule list.
117  */
118
119 extern rule *rule_list(void);
120
121 /* --- @rule_add@ --- *
122  *
123  * Arguments:   @class_node *host@ = class of hosts this rule applies to
124  *              @class_node *from@ = class of users allowed to change
125  *              @class_node *to@ = class of users allowed to be changed to
126  *              @class_node *cmd@ = class of commands allowed
127  *
128  * Returns:     ---
129  *
130  * Use:         Registers another rule.
131  */
132
133 extern void rule_add(class_node */*host*/, class_node */*from*/,
134                      class_node */*to*/, class_node */*cmd*/);
135
136 /* --- @rule_check@ --- *
137  *
138  * Arguments:   @request *r@ = pointer to a request block
139  *
140  * Returns:     Zero if disallowed, nonzero if allowed.
141  *
142  * Use:         Checks a request to see if it's allowed.
143  */
144
145 extern int rule_check(request */*r*/);
146
147 /* --- @rule_dump@ --- *
148  *
149  * Arguments:   ---
150  *
151  * Returns:     ---
152  *
153  * Use:         Dumps a map of the current ruleset to the trace output.
154  */
155
156 extern void rule_dump(void);
157
158 /*----- That's all, folks -------------------------------------------------*/
159
160 #ifdef __cplusplus
161   }
162 #endif
163
164 #endif