mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-01 06:45:38 +00:00
tests: Allow profile names that don't match an exec
Allow for the regression tests to specify arbitrary profile names without hitting fatal errors or getting warnings from mkprofile.pl. This allows for a test to have a line like this: genprofile change_profile->':arbitrary_name -- \ image=arbitrary_name addimage:$test In the example above, $test can call aa_change_onexec("arbitrary_name") and then re-exec itself to test behavior across exec transitions. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
@@ -362,7 +362,7 @@ sub emit_flags($) {
|
|||||||
# generate profiles based on cmd line arguments
|
# generate profiles based on cmd line arguments
|
||||||
sub gen_from_args() {
|
sub gen_from_args() {
|
||||||
my $bin = shift @ARGV;
|
my $bin = shift @ARGV;
|
||||||
!(-e $bin || $nowarn) && print STDERR "Warning: execname '$bin': no such file or directory\n";
|
my $addimage = 0;
|
||||||
|
|
||||||
unless ($nodefault) {
|
unless ($nodefault) {
|
||||||
gen_default_rules();
|
gen_default_rules();
|
||||||
@@ -396,12 +396,18 @@ sub gen_from_args() {
|
|||||||
gen_hat($rule);
|
gen_hat($rule);
|
||||||
} elsif ($rule =~ /^addimage:/) {
|
} elsif ($rule =~ /^addimage:/) {
|
||||||
gen_addimage($rule);
|
gen_addimage($rule);
|
||||||
|
$addimage = 1;
|
||||||
} else {
|
} else {
|
||||||
gen_file($rule);
|
gen_file($rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
!(-e $bin || $addimage || $nowarn) && print STDERR "Warning: execname '$bin': no such file or directory\n";
|
||||||
|
|
||||||
print STDOUT "# Profile autogenerated by $__VERSION__\n";
|
print STDOUT "# Profile autogenerated by $__VERSION__\n";
|
||||||
|
if (not substr($bin, 0, 1) eq "/") {
|
||||||
|
print STDOUT "profile "
|
||||||
|
}
|
||||||
print STDOUT "$bin ";
|
print STDOUT "$bin ";
|
||||||
emit_flags('__no_hat');
|
emit_flags('__no_hat');
|
||||||
print STDOUT "{\n";
|
print STDOUT "{\n";
|
||||||
|
@@ -350,10 +350,6 @@ fi
|
|||||||
# mandatory after --
|
# mandatory after --
|
||||||
case "$1" in
|
case "$1" in
|
||||||
image=*) imagename=`echo $1 | sed 's/^image=\([^:]*\).*$/\1/'`
|
image=*) imagename=`echo $1 | sed 's/^image=\([^:]*\).*$/\1/'`
|
||||||
if [ ! -x "$imagename" ]
|
|
||||||
then
|
|
||||||
fatalerror "invalid imagename specified in input '$1'"
|
|
||||||
fi
|
|
||||||
num_emitted=0
|
num_emitted=0
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user