[email protected]
[Top] [All Lists]

PERFORCE change 114805 for review

Subject: PERFORCE change 114805 for review
From: Todd Miller
Date: Wed, 21 Feb 2007 15:28:21 GMT
http://perforce.freebsd.org/chv.cgi?CH=114805

Change 114805 by [email protected]_p4 on 2007/02/21 15:27:45

        Remove dependence on gawk

Affected files ...

.. 
//depot/projects/trustedbsd/sebsd/contrib/sebsd/refpolicy/policy/flask/Makefile#2
 edit
.. 
//depot/projects/trustedbsd/sebsd/contrib/sebsd/refpolicy/policy/flask/mkaccess_vector.sh#2
 edit

Differences ...

==== 
//depot/projects/trustedbsd/sebsd/contrib/sebsd/refpolicy/policy/flask/Makefile#2
 (text+ko) ====

@@ -4,7 +4,7 @@
 # flask needs to know where to export the kernel headers.
 LINUXDIR ?= ../../../linux-2.6
 
-AWK = gawk
+AWK = awk
 
 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
           else if [ -x /bin/bash ]; then echo /bin/bash; \

==== 
//depot/projects/trustedbsd/sebsd/contrib/sebsd/refpolicy/policy/flask/mkaccess_vector.sh#2
 (text+ko) ====

@@ -15,6 +15,23 @@
 av_perm_to_string="av_perm_to_string.h"
 
 cat $* | $awk "
+       # Quicksort function for awk arrays, from The AWK Programming
+       # Language, by Aho, Kernighan and Weinberger.
+       # Call qsort(array, smallestindex, largestindex)
+       function qsort(a,left,right,    i,last) {
+               if (left >= right) return
+               swap(a, left, left + int((right-left+1)*rand()))
+               last = left
+               for (i=left+1; i<=right; i++)
+                   if (a[i] < a[left]) swap(a, ++last, i)
+               swap(a, left, last)
+               qsort(a, left, last-1)
+               qsort(a, last+1, right)
+       }
+       function swap(a,i,j,    t) {
+               t = a[i]; a[i] = a[j]; a[j] = t;
+       }
+
 BEGIN  {
                outfile = \"$av_permissions\"
                inheritfile = \"$av_inherit\"
@@ -102,12 +119,12 @@
                                }
                        }
 
-                        j = 1;
+                        n = 0;
                         for (i in inherited_perms) {
-                            ind[j] = i + 0;
-                            j++;
+                            n++;
+                            ind[n] = i + 0;
                         }
-                        n = asort(ind);
+                        qsort(ind, 1, n);
                        for (i = 1; i <= n; i++) {
                                perm = inherited_perms[ind[i]];
                                printf("#define %s__%s", toupper(tclass), 
toupper(perm)) > outfile; 
@@ -118,7 +135,6 @@
                                        printf(" ") > outfile; 
                                printf("0x%08xUL\n", ind[i]) > outfile; 
                        }
-                       printf("\n") > outfile;
                         for (i in ind) delete ind[i];
                         for (i in inherited_perms) delete inherited_perms[i];
 
@@ -214,8 +230,6 @@
                                printf("TE_(common_%s_perm_to_string)\n\n", 
common_name) > cpermfile; 
                        }
 
-                       printf("\n") > outfile;
-
                        nextstate = "COMMON_OR_AV";
                }
 END    {
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "[email protected]"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 114805 for review, Todd Miller <=