Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sbin/veriexecctl Pull up revision 1.10 (requested by elad...



details:   https://anonhg.NetBSD.org/src/rev/7faf32400362
branches:  netbsd-3
changeset: 576354:7faf32400362
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Jul 02 15:46:13 2005 +0000

description:
Pull up revision 1.10 (requested by elad in ticket #487):
Some refactoring and bugfixes:
- Report line numbers correctly.
- Don't perform a 2nd pass when there are were errors during 1st.
- Support multiple, comma-separated flags. This is mostly a reworking of
some parser internals preparing for planned features.

diffstat:

 sbin/veriexecctl/veriexecctl_parse.y |  59 +++++++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 14 deletions(-)

diffs (114 lines):

diff -r 3afd8dcffb56 -r 7faf32400362 sbin/veriexecctl/veriexecctl_parse.y
--- a/sbin/veriexecctl/veriexecctl_parse.y      Sat Jul 02 15:45:45 2005 +0000
+++ b/sbin/veriexecctl/veriexecctl_parse.y      Sat Jul 02 15:46:13 2005 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: veriexecctl_parse.y,v 1.4.2.5 2005/06/10 15:20:55 tron Exp $   */
+/*     $NetBSD: veriexecctl_parse.y,v 1.4.2.6 2005/07/02 15:46:13 tron Exp $   */
 
 /*-
  * Copyright 2005 Elad Efrat <elad%bsd.org.il@localhost>
@@ -48,6 +48,9 @@
 struct veriexec_params params;
 static int convert(u_char *, u_char *);
 
+int have_type = 0;
+
+#define        FIELD_TYPE      1
 %}
 
 %union {
@@ -57,7 +60,7 @@
 
 %token <string> PATH
 %token <string> STRING
-%token EOL
+%token EOL TOKEN_COMMA
 
 %%
 
@@ -100,6 +103,7 @@
        dev_add(sb.st_dev);
 phase_2_end:
        (void)memset(&params, 0, sizeof(params));
+       have_type = 0;
 }
                |       statement eol
                |       statement error eol {
@@ -113,7 +117,7 @@
                ;
 
 type           :       STRING {
-       if (phase != 1) {
+       if (phase == 2) {
                if (strlen($1) >= sizeof(params.fp_type)) {
                        yyerror("Fingerprint type too long");
                        YYERROR;
@@ -126,7 +130,7 @@
 
 
 fingerprint    :       STRING {
-       if (phase != 1) {
+       if (phase == 2) {
                params.fingerprint = malloc(strlen($1) / 2);
                if (params.fingerprint == NULL)
                        err(1, "Fingerprint mem alloc failed");
@@ -145,21 +149,48 @@
        if (phase == 2)
                params.type = VERIEXEC_DIRECT;
 }
-               |       flags flag_spec
+               |       flags_spec
+               ;
+
+flags_spec     :       flag_spec
+               |       flags_spec TOKEN_COMMA flag_spec
                ;
 
 flag_spec      :       STRING {
-       if (phase != 1) {
-               if (strcasecmp($1, "direct") == 0)
-                       params.type = VERIEXEC_DIRECT;
-               else if (strcasecmp($1, "indirect") == 0)
-                       params.type = VERIEXEC_INDIRECT;
-               else if (strcasecmp($1, "file") == 0)
-                       params.type = VERIEXEC_FILE;
-               else {
-                       yyerror("Bad option");
+       if (phase == 2) {
+               int field;
+               int value;
+
+               /*
+                * XXXEE: It might be a good idea to change this into
+                * XXXEE: something less hard-coded. Perhaps loop on
+                * XXXEE: tuples of (name, field, value)?
+                */
+               if (strcasecmp($1, "direct") == 0) {
+                       field = FIELD_TYPE;
+                       value = VERIEXEC_DIRECT;
+               } else if (strcasecmp($1, "indirect") == 0) {
+                       field = FIELD_TYPE;
+                       value = VERIEXEC_INDIRECT;
+               } else if (strcasecmp($1, "file") == 0) {
+                       field = FIELD_TYPE;
+                       value = VERIEXEC_FILE;
+               } else {
+                       yyerror("Bad flag");
                        YYERROR;
                }
+
+               switch (field) {
+               case FIELD_TYPE:
+                       if (have_type) {
+                               yyerror("Mulitple type definitions");
+                               YYERROR;
+                       }
+
+                       params.type = value;
+                       have_type = 1;
+                       break;
+               }
        }
 
 }



Home | Main Index | Thread Index | Old Index