[apparmor] [patch 2/8] testsuite - mkprofile function renaming/added prototypes
John Johansen
john.johansen at canonical.com
Thu Jan 12 10:17:28 UTC 2012
On 01/12/2012 10:08 AM, Steve Beattie wrote:
> This patch renames the emit_ functions to gen_ which reflects their
> purpose a little more accurately; renames the dump_flags to emit_flags
> for the same reason, and also adds a modicum a function prototype
> information to the function declarations.
>
Acked-by: John Johansen <john.johansen at canonical.com>
> ---
> tests/regression/apparmor/mkprofile.pl | 32 ++++++++++++++++----------------
> 1 file changed, 16 insertions(+), 16 deletions(-)
>
> Index: b/tests/regression/apparmor/mkprofile.pl
> ===================================================================
> --- a/tests/regression/apparmor/mkprofile.pl
> +++ b/tests/regression/apparmor/mkprofile.pl
> @@ -34,7 +34,7 @@ sub usage {
>
> &usage && exit 0 if ($help || @ARGV < 1);
>
> -sub emit_netdomain {
> +sub gen_netdomain($) {
> my $rule = shift;
> # only split on single ':'s
> my @rules = split (/(?<!:):(?!:)/, $rule);
> @@ -43,13 +43,13 @@ sub emit_netdomain {
> push (@{$output_rules{$hat}}, " @rules,\n");
> }
>
> -sub emit_network {
> +sub gen_network($) {
> my $rule = shift;
> my @rules = split (/:/, $rule);
> push (@{$output_rules{$hat}}, " @rules,\n");
> }
>
> -sub emit_cap {
> +sub gen_cap($) {
> my $rule = shift;
> my @rules = split (/:/, $rule);
> if (@rules != 2) {
> @@ -59,7 +59,7 @@ sub emit_cap {
> }
> }
>
> -sub emit_file {
> +sub gen_file($) {
> my $rule = shift;
> my @rules = split (/:/, $rule);
> # default: file rules
> @@ -78,7 +78,7 @@ sub emit_file {
> }
> }
>
> -sub emit_flag {
> +sub gen_flag($) {
> my $rule = shift;
> my @rules = split (/:/, $rule);
> if (@rules != 2) {
> @@ -88,7 +88,7 @@ sub emit_flag {
> }
> }
>
> -sub emit_hat {
> +sub gen_hat($) {
> my $rule = shift;
> my @rules = split (/:/, $rule);
> if (@rules != 2) {
> @@ -104,27 +104,27 @@ my $bin = shift @ARGV;
> !(-e $bin || $nowarn) && print STDERR "Warning: execname '$bin': no such file or directory\n";
>
> # give every profile/hat access to change_hat
> -emit_file("/proc/*/attr/current:w");
> +gen_file("/proc/*/attr/current:w");
>
> for my $rule (@ARGV) {
> #($fn, @rules) = split (/:/, $rule);
> if ($rule =~ /^(tcp|udp)/) {
> # netdomain rules
> - emit_netdomain($rule);
> + gen_netdomain($rule);
> } elsif ($rule =~ /^network:/) {
> - emit_network($rule);
> + gen_network($rule);
> } elsif ($rule =~ /^cap:/) {
> - emit_cap($rule);
> + gen_cap($rule);
> } elsif ($rule =~ /^flag:/) {
> - emit_flag($rule);
> + gen_flag($rule);
> } elsif ($rule =~ /^hat:/) {
> - emit_hat($rule);
> + gen_hat($rule);
> } else {
> - emit_file($rule);
> + gen_file($rule);
> }
> }
>
> -sub dump_flags {
> +sub emit_flags($) {
> my $hat = shift;
>
> if (exists $flags{$hat}) {
> @@ -139,7 +139,7 @@ sub dump_flags {
>
> print STDOUT "# Profile autogenerated by $__VERSION__\n";
> print STDOUT "$bin ";
> -dump_flags('__no_hat');
> +emit_flags('__no_hat');
> print STDOUT "{\n";
> foreach my $outrule (@{$output_rules{'__no_hat'}}) {
> print STDOUT $outrule;
> @@ -147,7 +147,7 @@ foreach my $outrule (@{$output_rules{'__
> foreach my $hat (keys %output_rules) {
> if (not $hat =~ /^__no_hat$/) {
> print STDOUT "\n ^$hat";
> - dump_flags($hat);
> + emit_flags($hat);
> print STDOUT " {\n";
> foreach my $outrule (@{$output_rules{$hat}}) {
> print STDOUT " $outrule";
>
>
> -- AppArmor mailing list AppArmor at lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
>
More information about the AppArmor
mailing list