From owner-p4-projects@FreeBSD.ORG Wed Feb 21 15:28:22 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5AAAB16F88B; Wed, 21 Feb 2007 15:28:22 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EF58416F7F3 for ; Wed, 21 Feb 2007 15:28:21 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id DF61113C441 for ; Wed, 21 Feb 2007 15:28:21 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l1LFSLaK075744 for ; Wed, 21 Feb 2007 15:28:21 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l1LFSL0t075741 for perforce@freebsd.org; Wed, 21 Feb 2007 15:28:21 GMT (envelope-from millert@freebsd.org) Date: Wed, 21 Feb 2007 15:28:21 GMT Message-Id: <200702211528.l1LFSL0t075741@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 114805 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2007 15:28:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=114805 Change 114805 by millert@millert_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 {