mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-03 07:45:50 +00:00
This patch makes the utils tools consistent with the initscript as to
which sets of files they ignore (rpm backups, dotfiles, and emacs backups). It moves the tests into a common function so that modifications only need to occur in one location.
This commit is contained in:
@@ -87,6 +87,8 @@ our @EXPORT = qw(
|
|||||||
|
|
||||||
checkProfileSyntax
|
checkProfileSyntax
|
||||||
checkIncludeSyntax
|
checkIncludeSyntax
|
||||||
|
|
||||||
|
isSkippableFile
|
||||||
);
|
);
|
||||||
|
|
||||||
our $confdir = "/etc/apparmor";
|
our $confdir = "/etc/apparmor";
|
||||||
@@ -2305,6 +2307,16 @@ sub contains ($$) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# isSkippableFile - return true if filename matches something that
|
||||||
|
# should be skipped (rpm backup files, dotfiles, emacs backup files
|
||||||
|
sub isSkippableFile($) {
|
||||||
|
my $path = shift;
|
||||||
|
|
||||||
|
return ($path =~ /(^|\/)\.[^\/]*$/
|
||||||
|
|| $path =~ /\.rpm(save|new)$/
|
||||||
|
|| $path =~ /\~$/);
|
||||||
|
}
|
||||||
|
|
||||||
sub checkIncludeSyntax($) {
|
sub checkIncludeSyntax($) {
|
||||||
my $errors = shift;
|
my $errors = shift;
|
||||||
|
|
||||||
@@ -2315,7 +2327,7 @@ sub checkIncludeSyntax($) {
|
|||||||
if (opendir(SDDIR, "$profiledir/$id")) {
|
if (opendir(SDDIR, "$profiledir/$id")) {
|
||||||
for my $path (grep { !/^\./ } readdir(SDDIR)) {
|
for my $path (grep { !/^\./ } readdir(SDDIR)) {
|
||||||
chomp($path);
|
chomp($path);
|
||||||
next if $path =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($path);
|
||||||
if (-f "$profiledir/$id/$path") {
|
if (-f "$profiledir/$id/$path") {
|
||||||
my $file = "$id/$path";
|
my $file = "$id/$path";
|
||||||
$file =~ s/$profiledir\///;
|
$file =~ s/$profiledir\///;
|
||||||
@@ -2342,7 +2354,7 @@ sub checkProfileSyntax ($) {
|
|||||||
opendir(SDDIR, $profiledir)
|
opendir(SDDIR, $profiledir)
|
||||||
or fatal_error "Can't read AppArmor profiles in $profiledir.";
|
or fatal_error "Can't read AppArmor profiles in $profiledir.";
|
||||||
for my $file (grep { -f "$profiledir/$_" } readdir(SDDIR)) {
|
for my $file (grep { -f "$profiledir/$_" } readdir(SDDIR)) {
|
||||||
next if $file =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($file);
|
||||||
my $err = readprofile("$profiledir/$file", \&printMessageErrorHandler);
|
my $err = readprofile("$profiledir/$file", \&printMessageErrorHandler);
|
||||||
if (defined $err and $err ne 1) {
|
if (defined $err and $err ne 1) {
|
||||||
push @$errors, $err;
|
push @$errors, $err;
|
||||||
@@ -2361,7 +2373,7 @@ sub readprofiles () {
|
|||||||
opendir(SDDIR, $profiledir)
|
opendir(SDDIR, $profiledir)
|
||||||
or fatal_error "Can't read AppArmor profiles in $profiledir.";
|
or fatal_error "Can't read AppArmor profiles in $profiledir.";
|
||||||
for my $file (grep { -f "$profiledir/$_" } readdir(SDDIR)) {
|
for my $file (grep { -f "$profiledir/$_" } readdir(SDDIR)) {
|
||||||
next if $file =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($file);
|
||||||
readprofile("$profiledir/$file", \&fatal_error);
|
readprofile("$profiledir/$file", \&fatal_error);
|
||||||
}
|
}
|
||||||
closedir(SDDIR);
|
closedir(SDDIR);
|
||||||
@@ -3004,9 +3016,9 @@ sub loadincludes {
|
|||||||
|
|
||||||
while (my $id = shift @incdirs) {
|
while (my $id = shift @incdirs) {
|
||||||
if (opendir(SDDIR, "$profiledir/$id")) {
|
if (opendir(SDDIR, "$profiledir/$id")) {
|
||||||
for my $path (grep { !/^\./ } readdir(SDDIR)) {
|
for my $path (readdir(SDDIR)) {
|
||||||
chomp($path);
|
chomp($path);
|
||||||
next if $path =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($path);
|
||||||
if (-f "$profiledir/$id/$path") {
|
if (-f "$profiledir/$id/$path") {
|
||||||
my $file = "$id/$path";
|
my $file = "$id/$path";
|
||||||
$file =~ s/$profiledir\///;
|
$file =~ s/$profiledir\///;
|
||||||
|
@@ -92,6 +92,8 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Mar 23 2007 - sbeattie@suse.de
|
||||||
|
- ignore emacs backup files, make consistent with initscript
|
||||||
* Wed Jan 17 2007 - sbeattie@suse.de
|
* Wed Jan 17 2007 - sbeattie@suse.de
|
||||||
- Fall back to Date::Manip if Date::Parse is not available
|
- Fall back to Date::Manip if Date::Parse is not available
|
||||||
* Wed Jan 17 2007 - sbeattie@suse.de
|
* Wed Jan 17 2007 - sbeattie@suse.de
|
||||||
|
@@ -97,7 +97,7 @@ for my $profiling (@profiling) {
|
|||||||
next unless -f $filename;
|
next unless -f $filename;
|
||||||
|
|
||||||
# skip rpm backup files
|
# skip rpm backup files
|
||||||
next if $filename =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($filename);
|
||||||
|
|
||||||
printf(gettext('Setting %s to audit mode.'), $fqdbin);
|
printf(gettext('Setting %s to audit mode.'), $fqdbin);
|
||||||
print "\n";
|
print "\n";
|
||||||
|
@@ -97,7 +97,7 @@ for my $profiling (@profiling) {
|
|||||||
next unless -f $filename;
|
next unless -f $filename;
|
||||||
|
|
||||||
# skip rpm backup files
|
# skip rpm backup files
|
||||||
next if $filename =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($filename);
|
||||||
|
|
||||||
printf(gettext('Setting %s to complain mode.'), $fqdbin);
|
printf(gettext('Setting %s to complain mode.'), $fqdbin);
|
||||||
print "\n";
|
print "\n";
|
||||||
|
@@ -96,7 +96,7 @@ for my $profiling (@profiling) {
|
|||||||
next unless -f $filename;
|
next unless -f $filename;
|
||||||
|
|
||||||
# skip rpm backup files
|
# skip rpm backup files
|
||||||
next if $filename =~ /\.rpm(save|new)$/;
|
next if isSkippableFile($filename);
|
||||||
|
|
||||||
printf(gettext('Setting %s to enforce mode.'), $fqdbin);
|
printf(gettext('Setting %s to enforce mode.'), $fqdbin);
|
||||||
print "\n";
|
print "\n";
|
||||||
|
Reference in New Issue
Block a user