2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 14:25:52 +00:00

Regression testsuite: rename 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.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Steve Beattie
2012-01-12 11:49:32 +01:00
parent a0fbc1f26c
commit 44ca1c0f11

View File

@@ -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{'__no_hat'}}) {
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";