This will convert a sequence of access denied messages into
allow-commands.
One problem: even in permissive move, SELinux doesn't generate all possible denied messages. After one enables access and reruns an offending program, one gets more denied messages. It's as if the program didn't completely run the previous time (although it should, in permissive mode).
Here's the perl script:
#------------------------------------cut here---------------------#!/usr/bin/perl
my %rules = ();
#
# format: $rules{ "$scontext|$tcontext|$tclass"}
# = { '$accesstype1' => 1,'$accesstype2' => 1}, etc.,;
#
while ($inline = <ERRFILE>)
{
next unless ($inline =~ /avc:\s*denied\s*\{\s*(\w+)\s*\}/);
my $accesstype = $1;
my $nextline = <ERRFILE>;
$nextline =~ /:(\w+)\s*\Z/;
my $scontext = $1;
$nextline = <ERRFILE>;
$nextline =~ /:(\w+)\s*\Z/;
my $tcontext = $1;
$nextline = <ERRFILE>;
$nextline =~ /=(\w+)\s*\Z/;
my $tclass = $1;
$rules{"$scontext|$tcontext|$tclass" }{$accesstype}=1;
}
# done with the input file
# now generate the rules
foreach $k (sort keys %rules)
{
my ($scontext,$tcontext,$tclass) = split /\|/, $k;
print NEWRULES "allow $scontext $tcontext:$tclass { ";
my $access_types = $rules{$k};
foreach $t (sort keys %$access_types)
{
print NEWRULES "$t ";
}
#-----------------end------------------------------------
-- -- You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with the words "unsubscribe selinux" without quotes as the message.Received on Tue 4 Dec 2001 - 09:10:13 EST
This archive was generated by hypermail 2.2.0 on Wed 11 Jun 2008 - 08:10:26 EDT