chiark / gitweb /
Use rewritten class handler.
authormdw <mdw>
Wed, 17 Sep 1997 10:27:17 +0000 (10:27 +0000)
committermdw <mdw>
Wed, 17 Sep 1997 10:27:17 +0000 (10:27 +0000)
src/rule.c
src/rule.h

index b77cd14b049cf62979e01f9aa79a49f034575c8a..2a40a732f996d06bb425354b0a9e8720cd5afe03 100644 (file)
@@ -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
  *
 /*----- 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.
  *
 
 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");
index 6b4556ba0fa28bbf966657a3a54fedb235622cf6..59fe406dfb40ec5a01a62fd2d17e46e42f402c31 100644 (file)
@@ -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
  *
 /*----- 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@ --- *
  *