From 30868bd5a9b2ac3527ac92e63a7fff7c2914339a Mon Sep 17 00:00:00 2001 From: mdw Date: Wed, 17 Sep 1997 10:27:17 +0000 Subject: [PATCH] Use rewritten class handler. --- src/rule.c | 51 +++++++++++++++++++++++++++------------------------ src/rule.h | 19 +++++++++++-------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/rule.c b/src/rule.c index b77cd14..2a40a73 100644 --- a/src/rule.c +++ b/src/rule.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rule.c,v 1.3 1997/08/20 16:22:36 mdw Exp $ + * $Id: rule.c,v 1.4 1997/09/17 10:27:17 mdw Exp $ * * Managing rule sets * @@ -29,7 +29,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: rule.c,v $ - * Revision 1.3 1997/08/20 16:22:36 mdw + * Revision 1.4 1997/09/17 10:27:17 mdw + * Use rewritten class handler. + * + * Revision 1.3 1997/08/20 16:22:36 mdw * Rename `rule_reinit' to `rule_end' for more sensible restart. Don't try * to trace when tracing's turned off. * @@ -72,10 +75,10 @@ typedef struct rule { struct rule *next; /* Next rule in the list */ - classdef *host; /* Hosts this rule applies to */ - classdef *from; /* From users in this class */ - classdef *to; /* To users in this class */ - classdef *cmd; /* To run commands in this class */ + class_node *host; /* Hosts this rule applies to */ + class_node *from; /* From users in this class */ + class_node *to; /* To users in this class */ + class_node *cmd; /* To run commands in this class */ } rule; /*----- Static variables --------------------------------------------------*/ @@ -127,17 +130,17 @@ void rule_end(void) /* --- @rule_add@ --- * * - * Arguments: @classdef *host@ = class of hosts this rule applies to - * @classdef *from@ = class of users allowed to change - * @classdef *to@ = class of users allowed to be changed to - * @classdef *cmd@ = class of commands allowed + * Arguments: @class_node *host@ = class of hosts this rule applies to + * @class_node *from@ = class of users allowed to change + * @class_node *to@ = class of users allowed to be changed to + * @class_node *cmd@ = class of commands allowed * * Returns: --- * * Use: Registers another rule. */ -void rule_add(classdef *host, classdef *from, classdef *to, classdef *cmd) +void rule_add(class_node *host, class_node *from, class_node *to, class_node *cmd) { rule *r = xmalloc(sizeof(*r)); @@ -186,18 +189,18 @@ int rule_check(request *r) IF_TRACING(TRACE_RULE, { trace(TRACE_RULE, "rule: check against rule..."); - trace(TRACE_RULE, " from"); class_dump(rr->from); - trace(TRACE_RULE, " to"); class_dump(rr->to); - trace(TRACE_RULE, " cmd"); class_dump(rr->cmd); - trace(TRACE_RULE, " host"); class_dump(rr->host); + trace(TRACE_RULE, "rule: from"); class_dump(rr->from, 2); + trace(TRACE_RULE, "rule: to"); class_dump(rr->to, 2); + trace(TRACE_RULE, "rule: cmd"); class_dump(rr->cmd, 2); + trace(TRACE_RULE, "rule: host"); class_dump(rr->host, 2); }) /* --- Check the rule --- */ - if (class_userMatch(rr->from, r->from) && - class_userMatch(rr->to, r->to) && - class_commandMatch(rr->cmd, r->cmd) && - class_hostMatch(rr->host, r->host)) { + if (class_matchUser(rr->from, r->from) && + class_matchUser(rr->to, r->to) && + class_matchCommand(rr->cmd, r->cmd) && + class_matchHost(rr->host, r->host)) { T( trace(TRACE_CHECK, "check: rule matched -- granting permission"); ) return (1); } @@ -225,11 +228,11 @@ void rule_dump(void) trace(TRACE_RULE, "rule: dumping rules"); while (rr) { - trace(TRACE_RULE, "rule dump..."); - trace(TRACE_RULE, " from"); class_dump(rr->from); - trace(TRACE_RULE, " to"); class_dump(rr->to); - trace(TRACE_RULE, " cmd"); class_dump(rr->cmd); - trace(TRACE_RULE, " host"); class_dump(rr->host); + trace(TRACE_RULE, "rule: rule dump..."); + trace(TRACE_RULE, "rule: from"); class_dump(rr->from, 2); + trace(TRACE_RULE, "rule: to"); class_dump(rr->to, 2); + trace(TRACE_RULE, "rule: cmd"); class_dump(rr->cmd, 2); + trace(TRACE_RULE, "rule: host"); class_dump(rr->host, 2); rr = rr->next; } trace(TRACE_RULE, "rule: dump finished"); diff --git a/src/rule.h b/src/rule.h index 6b4556b..59fe406 100644 --- a/src/rule.h +++ b/src/rule.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rule.h,v 1.3 1997/08/20 16:22:49 mdw Exp $ + * $Id: rule.h,v 1.4 1997/09/17 10:27:17 mdw Exp $ * * Managing rule sets * @@ -29,7 +29,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: rule.h,v $ - * Revision 1.3 1997/08/20 16:22:49 mdw + * Revision 1.4 1997/09/17 10:27:17 mdw + * Use rewritten class handler. + * + * Revision 1.3 1997/08/20 16:22:49 mdw * Rename `rule_reinit' to `rule_end' for more sensible restart. * * Revision 1.2 1997/08/04 10:24:25 mdw @@ -88,18 +91,18 @@ extern void rule_end(void); /* --- @rule_add@ --- * * - * Arguments: @classdef *host@ = class of hosts this rule applies to - * @classdef *from@ = class of users allowed to change - * @classdef *to@ = class of users allowed to be changed to - * @classdef *cmd@ = class of commands allowed + * Arguments: @class_node *host@ = class of hosts this rule applies to + * @class_node *from@ = class of users allowed to change + * @class_node *to@ = class of users allowed to be changed to + * @class_node *cmd@ = class of commands allowed * * Returns: --- * * Use: Registers another rule. */ -extern void rule_add(classdef */*host*/, classdef */*from*/, - classdef */*to*/, classdef */*cmd*/); +extern void rule_add(class_node */*host*/, class_node */*from*/, + class_node */*to*/, class_node */*cmd*/); /* --- @rule_check@ --- * * -- 2.11.0