00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef IPA_HBAC_H_
00027 #define IPA_HBAC_H_
00028
00040 #include <stdint.h>
00041 #include <stdbool.h>
00042 #include <time.h>
00043
00045 enum hbac_eval_result {
00049 HBAC_EVAL_ERROR = -1,
00050
00052 HBAC_EVAL_ALLOW,
00053
00055 HBAC_EVAL_DENY,
00056
00060 HBAC_EVAL_OOM
00061 };
00062
00066 #define HBAC_CATEGORY_NULL 0x0000
00067
00071 #define HBAC_CATEGORY_ALL 0x0001
00072
00076 struct hbac_time_rules;
00077
00084 struct hbac_rule_element {
00092 uint32_t category;
00093
00101 const char **names;
00102
00110 const char **groups;
00111 };
00112
00116 struct hbac_rule {
00117 const char *name;
00118 bool enabled;
00119
00124 struct hbac_rule_element *services;
00125
00130 struct hbac_rule_element *users;
00131
00135 struct hbac_rule_element *targethosts;
00136
00140 struct hbac_rule_element *srchosts;
00141
00145 struct hbac_time_rules *timerules;
00146 };
00147
00151 struct hbac_request_element {
00159 const char *name;
00160
00168 const char **groups;
00169 };
00170
00176 struct hbac_eval_req {
00182 struct hbac_request_element *service;
00183
00189 struct hbac_request_element *user;
00190
00196 struct hbac_request_element *targethost;
00197
00203 struct hbac_request_element *srchost;
00204
00206 time_t request_time;
00207 };
00208
00212 enum hbac_error_code {
00214 HBAC_ERROR_UNKNOWN = -1,
00215
00217 HBAC_SUCCESS,
00218
00220 HBAC_ERROR_NOT_IMPLEMENTED,
00221
00223 HBAC_ERROR_OUT_OF_MEMORY,
00224
00226 HBAC_ERROR_UNPARSEABLE_RULE
00227 };
00228
00230 struct hbac_info {
00236 enum hbac_error_code code;
00237
00242 char *rule_name;
00243 };
00244
00245
00259 enum hbac_eval_result hbac_evaluate(struct hbac_rule **rules,
00260 struct hbac_eval_req *hbac_req,
00261 struct hbac_info **info);
00262
00268 const char *hbac_result_string(enum hbac_eval_result result);
00269
00275 const char *hbac_error_string(enum hbac_error_code code);
00276
00281 void hbac_free_info(struct hbac_info *info);
00282
00284 #define HBAC_RULE_ELEMENT_USERS 0x01
00285
00287 #define HBAC_RULE_ELEMENT_SERVICES 0x02
00288
00290 #define HBAC_RULE_ELEMENT_TARGETHOSTS 0x04
00291
00293 #define HBAC_RULE_ELEMENT_SOURCEHOSTS 0x08
00294
00310 bool hbac_rule_is_complete(struct hbac_rule *rule, uint32_t *missing_attrs);
00311
00312
00316 #endif