| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * $Id: rule.h,v 1.7 2004/04/08 01:36:20 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 | #ifndef RULE_H |
| 30 | #define RULE_H |
| 31 | |
| 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
| 36 | /*----- Required headers --------------------------------------------------*/ |
| 37 | |
| 38 | #include <sys/types.h> |
| 39 | #include <sys/socket.h> |
| 40 | #include <netinet/in.h> |
| 41 | #include <arpa/inet.h> |
| 42 | |
| 43 | #ifndef BECOME_H |
| 44 | # include "become.h" |
| 45 | #endif |
| 46 | |
| 47 | #ifndef CLASS_H |
| 48 | # include "class.h" |
| 49 | #endif |
| 50 | |
| 51 | /*----- Type definitions --------------------------------------------------*/ |
| 52 | |
| 53 | /* --- Rule block --- */ |
| 54 | |
| 55 | typedef struct rule { |
| 56 | struct rule *next; /* Next rule in the list */ |
| 57 | class_node *host; /* Hosts this rule applies to */ |
| 58 | class_node *from; /* From users in this class */ |
| 59 | class_node *to; /* To users in this class */ |
| 60 | class_node *cmd; /* To run commands in this class */ |
| 61 | } rule; |
| 62 | |
| 63 | /*----- Functions provided ------------------------------------------------*/ |
| 64 | |
| 65 | /* --- @rule_init@ --- * |
| 66 | * |
| 67 | * Arguments: --- |
| 68 | * |
| 69 | * Returns: --- |
| 70 | * |
| 71 | * Use: Intialises the rule database. |
| 72 | */ |
| 73 | |
| 74 | extern void rule_init(void); |
| 75 | |
| 76 | /* --- @rule_end@ --- * |
| 77 | * |
| 78 | * Arguments: --- |
| 79 | * |
| 80 | * Returns: --- |
| 81 | * |
| 82 | * Use: Empties the rule database. |
| 83 | */ |
| 84 | |
| 85 | extern void rule_end(void); |
| 86 | |
| 87 | /* --- @rule_list@ --- * |
| 88 | * |
| 89 | * Arguments: --- |
| 90 | * |
| 91 | * Returns: The list of rules. |
| 92 | * |
| 93 | * Use: Returns the address of the first node in the rule list. |
| 94 | */ |
| 95 | |
| 96 | extern rule *rule_list(void); |
| 97 | |
| 98 | /* --- @rule_add@ --- * |
| 99 | * |
| 100 | * Arguments: @class_node *host@ = class of hosts this rule applies to |
| 101 | * @class_node *from@ = class of users allowed to change |
| 102 | * @class_node *to@ = class of users allowed to be changed to |
| 103 | * @class_node *cmd@ = class of commands allowed |
| 104 | * |
| 105 | * Returns: --- |
| 106 | * |
| 107 | * Use: Registers another rule. |
| 108 | */ |
| 109 | |
| 110 | extern void rule_add(class_node */*host*/, class_node */*from*/, |
| 111 | class_node */*to*/, class_node */*cmd*/); |
| 112 | |
| 113 | /* --- @rule_check@ --- * |
| 114 | * |
| 115 | * Arguments: @request *r@ = pointer to a request block |
| 116 | * |
| 117 | * Returns: Zero if disallowed, nonzero if allowed. |
| 118 | * |
| 119 | * Use: Checks a request to see if it's allowed. |
| 120 | */ |
| 121 | |
| 122 | extern int rule_check(request */*r*/); |
| 123 | |
| 124 | /* --- @rule_dump@ --- * |
| 125 | * |
| 126 | * Arguments: --- |
| 127 | * |
| 128 | * Returns: --- |
| 129 | * |
| 130 | * Use: Dumps a map of the current ruleset to the trace output. |
| 131 | */ |
| 132 | |
| 133 | extern void rule_dump(void); |
| 134 | |
| 135 | /*----- That's all, folks -------------------------------------------------*/ |
| 136 | |
| 137 | #ifdef __cplusplus |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | #endif |