Created
August 1, 2021 14:30
-
-
Save ox0xo/d1a609d424e1a470ba6a1338beb883a4 to your computer and use it in GitHub Desktop.
Tripwire Policy Make Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$POLFILE=$ARGV[0]; | |
open(POL,"$POLFILE") or die "open error: $POLFILE" ; | |
my($myhost,$thost) ; | |
my($sharp,$tpath,$cond) ; | |
my($INRULE) = 0 ; | |
while (<POL>) { | |
chomp; | |
if (($thost) = /^HOSTNAME\s*=\s*(.*)\s*;/) { | |
$myhost = `hostname` ; chomp($myhost) ; | |
if ($thost ne $myhost) { | |
$_="HOSTNAME=\"$myhost\";" ; | |
} | |
} | |
elsif ( /^{/ ) { | |
$INRULE=1 ; | |
} | |
elsif ( /^}/ ) { | |
$INRULE=0 ; | |
} | |
elsif ($INRULE == 1 and ($sharp,$tpath,$cond) = /^(\s*\#?\s*)(\/\S+)\b(\s+->\s+.+)$/) { | |
$ret = ($sharp =~ s/\#//g) ; | |
if ($tpath eq '/sbin/e2fsadm' ) { | |
$cond =~ s/;\s+(tune2fs.*)$/; \#$1/ ; | |
} | |
if (! -s $tpath) { | |
$_ = "$sharp#$tpath$cond" if ($ret == 0) ; | |
} | |
else { | |
$_ = "$sharp$tpath$cond" ; | |
} | |
} | |
print "$_\n" ; | |
} | |
close(POL) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment