From: Justin Smith <jsmith@mcs.drexel.edu>
To: selinux@tycho.nsa.gov
Subject: simple Perl script to converse messages to access rules
Date: 04 Dec 2001 08:57:47 -0500 [thread overview]
Message-ID: <1007474267.2028.0.camel@jsmith.org> (raw)
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
open ERRFILE, "< messages";
open NEWRULES, "> newrules";
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 ";
}
print NEWRULES "};\n";
}
#-----------------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.
next reply other threads:[~2001-12-04 14:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-04 13:57 Justin Smith [this message]
2001-12-04 14:24 ` simple Perl script to converse messages to access rules Stephen Smalley
2001-12-04 14:32 ` Justin Smith
2001-12-04 14:36 ` [PATCH] AVC auditing changes Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1007474267.2028.0.camel@jsmith.org \
--to=jsmith@mcs.drexel.edu \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.