All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuichi Nakamura <ynakam@ori.hitachi-sk.co.jp>
To: selinux@tycho.nsa.gov
Cc: ynakam@ori.hitachi-sk.co.jp, russell@coker.com.au
Subject: newrules.pl's -l option patch (Was: Re: newrules.pl -o option)
Date: Sat, 11 Oct 2003 17:19:50 +0900	[thread overview]
Message-ID: <20031011171950.7f8bfa33.ynakam@ori.hitachi-sk.co.jp> (raw)
In-Reply-To: <20031010190749.51bbd908.ynakam@ori.hitachi-sk.co.jp>

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

On Fri, 10 Oct 2003 19:07:49 +0900
Yuichi Nakamura <ynakam@ori.hitachi-sk.co.jp> wrote:
> I have fixed it. Temporary file has been removed.
> This is a new patch. 

The previous version had bug when input is stdin.
Russell found it and fixed. I would like to thank him.
This is a fixed version of -l option patch.
Please merge this.

---------
Yuichi Nakamura


[-- Attachment #2: newrules.pl.patch --]
[-- Type: application/octet-stream, Size: 2128 bytes --]

--- newrules.pl	2003-09-15 23:03:58.000000000 +0900
+++ /home/ynakam/newrules.pl	2003-10-11 15:46:07.000000000 +0900
@@ -17,13 +17,17 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA     
 #                                        02111-1307  USA
+#    2003 Oct 11: Add -l option by Yuichi Nakamura(ynakam@users.sourceforge.jp)
 
 
+$load_policy_pattern="avc:.*granted.*{.*load_policy.*}";
+
 while ($opt = shift @ARGV) {
         if ($opt eq "-d") { $read_dmesg++; }
         elsif ($opt eq "-v") { $verbose++; }
         elsif ($opt eq "-i") { $input = shift @ARGV; }
         elsif ($opt eq "-o") { $output= shift @ARGV; }
+	elsif ($opt eq "-l") { $load_policy++; }
 	elsif ($opt eq "--help") { &printUsage; }
 		else  { print "unknown option, '$opt'\n\n"; &printUsage; }
 }
@@ -37,11 +41,23 @@
 elsif ($input)   { open (IN, "$input");      }
 else             { open (IN, "-");           }  # STDIN
 
-if ($output)     { open (OUT, ">$output");   }
+if ($output)     { open (OUT, ">>$output");   }
 else             { open (OUT, ">-");         }  # STDOUT
 
+if($load_policy){ #store logs after last "load_policy" in @log_buf
+    while ($line = <IN>) {
+	if($line=~/$load_policy_pattern/) {
+	     #stored logs are unnecessary
+	     undef @log_buf;
+	}
+	else
+	{
+	    push @log_buf,$line;
+	}
+    }
+}
 
-while ($line = <IN>) {
+while ($line=&readNewline) {
     next unless ($line =~ m/avc:\s*denied\s*\{((\w|\s)*)\}/);
     @types=split /\ /,$line;
     $info="";
@@ -121,11 +137,22 @@
 
 exit;
 
+sub readNewline {
+    if($load_policy){
+	$newline=shift @log_buf;
+    }else{
+	$newline=<IN>;
+    }
+    return $newline;
+}
+
 sub printUsage {
-	print "newrules [-d] [-v] [-i <inputfile> ] [-o <outputfile>]
+	print "newrules [-d] [-v] [-l] [-i <inputfile> ] [-o <outputfile>]
         -d      read input from output of /bin/dmesg
         -v      verbose output
+        -l      read input only after last \"load_policy\"
         -i      read input from <inputfile>
         -o      append output to <outputfile>\n";
 	exit;
 }
+

  reply	other threads:[~2003-10-11  8:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-09  1:24 newrules.pl -o option Yuichi Nakamura
     [not found] ` <1065723279.53567.0.camel@vorpal.mcs.drexel.edu>
2003-10-10  0:08   ` Yuichi Nakamura
2003-10-10  6:41     ` Russell Coker
2003-10-10 10:07       ` Yuichi Nakamura
2003-10-11  8:19         ` Yuichi Nakamura [this message]
2003-10-10  8:28     ` Dale Amon
2003-10-10 10:32       ` Dale Amon
2003-10-10 11:16       ` Russell Coker
2003-10-10 13:40         ` Stephen Smalley
2003-10-10 14:40           ` Russell Coker
2003-10-10 14:54             ` Stephen Smalley
2003-10-10 15:35               ` Dale Amon

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=20031011171950.7f8bfa33.ynakam@ori.hitachi-sk.co.jp \
    --to=ynakam@ori.hitachi-sk.co.jp \
    --cc=russell@coker.com.au \
    --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.