Lines Matching +full:in +full:- +full:line
39 # pattern $pattern is present in the file. This lets us completely redo
40 # a file, if it isn't the one we put in place on a previous run...
43 # so that it makes backups and only modifies files when we're not in "-v"
64 while (my $line = <BLANK_OLD>) {
66 push @lines,$line;
67 if ($line =~ $pattern) {
74 while ( my $line = shift @lines ) {
75 &B_print(*BLANK_NEW,$line);
94 # in the file matches $pattern. The $line_to_insert will be placed
95 # immediately after $line_to_follow, if it exists. If said line does not
96 # exist, the line will not be inserted and this routine will return 0.
103 # You'd like to insert a line in Apache's configuration file, in a
121 # and the line we are supposed to be inserting after...
124 while (my $line=<INSERT_OLD>) {
125 push (@lines,$line);
126 if ($line =~ $pattern) {
129 if ( ($found_line_to_follow < 1) and ($line =~ $line_to_follow)) {
135 # Log an error if we never found the line we were to insert after
138 … &B_log("ERROR","Never found the line that we were supposed to insert after in $filename\n");
141 # Now print the file back out, inserting our line if we should...
144 while (my $line = shift @lines) {
145 &B_print(*INSERT_NEW,$line);
148 &B_log("ACTION","Inserted the following line in $filename:\n");
159 &B_log("ERROR","Couldn't insert line to $filename, since open failed.");
168 # in the file matches $pattern. The $line_to_insert will be placed
169 # immediately before $line_to_preceed, if it exists. If said line does not
170 # exist, the line will not be inserted and this routine will return 0.
177 # You'd like to insert a line in Apache's configuration file, in a
195 # and the line we are supposed to be inserting after...
198 while (my $line=<INSERT_OLD>) {
199 push (@lines,$line);
200 if ($line =~ $pattern) {
203 if ( ($found_line_to_preceed < 1) and ($line =~ $line_to_preceed)) {
209 # Log an error if we never found the line we were to preceed
212 … &B_log("ERROR","Never found the line that we were supposed to insert before in $filename\n");
215 # Now print the file back out, inserting our line if we should...
218 while (my $line = shift @lines) {
221 &B_log("ACTION","Inserted the following line in $filename:\n");
224 &B_print(*INSERT_NEW,$line);
233 &B_log("ERROR","Couldn't insert line to $filename, since open failed.");
259 # appending $line_to_append unless one or more lines in the file matches
263 # Additionally, if $pattern is set equal to "", the line is always appended.
270 # You'd like to add a root line to /etc/ftpusers if none exists.
271 # You'd like to add a Options Indexes line to Apache's config. file,
284 while (my $line=<APPEND_OLD>) {
285 &B_print(*APPEND_NEW,$line);
286 if ($line =~ $pattern) {
292 # Argument "XX" isn't numeric in ne at ...
295 &B_log("ACTION","Appended the following line to $filename:\n");
302 &B_log("ERROR","# Couldn't append line to $filename, since open failed.");
311 # pre-pending $line_to:prepend unless one or more lines in the file matches
320 # You'd like to insert the line "auth required pam_deny.so" to the top
334 while (my $line=<PREPEND_OLD>) {
335 push (@lines,$line);
336 if ($line =~ $pattern) {
343 while (my $line = shift @lines) {
344 &B_print(*PREPEND_NEW,$line);
350 &B_log("ACTION","Pre-pended the following line to $filename:\n");
355 &B_log("ERROR","Couldn't prepend line to $filename, since open failed.\n");
375 # You'd like to replace any Options lines in Apache's config file with:
386 while (my $line=<REPLACE_OLD>) {
387 unless ($line =~ $pattern) {
388 &B_print(*REPLACE_NEW,$line);
391 # Don't replace the line if it's already there.
392 unless ($line eq $line_to_switch_in) {
396 &B_log("ACTION","File modification in $filename -- replaced line\n" .
397 "$line\n" .
403 &B_print(*REPLACE_NEW,$line);
411 &B_log("ERROR","Couldn't replace line(s) in $filename because open failed.\n");
419 # replacing the line matching the nth $pattern specified in $patterns_and_substitutes->[n]->[0]
420 # with the corresponding substitutes in $patterns_and_substitutes->[n]->-[1]
454 while (my $line = <REPLACE_OLD>) {
456 my $switch_before = $line;
457 chomp($line);
461 my $pattern = $pair->[0] ;
462 my $replace = $pair->[1];
463 my $evalstr = '$line' . "=~ s/$pattern/$replace/";
468 #if ( $line =~ s/$pair->[0]/$pair->[1]/) {
473 &B_print(*REPLACE_NEW,"$line\n");
476 B_log("ACTION","File modification in $filename -- replaced line\n" .
479 "$line\n");
487 &B_log("ERROR","Couldn't replace line(s) in $filename because open failed.\n");
515 while (my $line=<REPLACE_OLD>) {
516 unless ($line =~ $pattern) {
517 &B_print(*REPLACE_NEW,$line);
520 my $orig_line =$line;
521 $line =~ s/$pattern_to_remove/$text_to_switch_in/;
523 &B_print(*REPLACE_NEW,$line);
526 &B_log("ACTION","File modification in $filename -- replaced line\n" .
529 "$line\n\n");
536 &B_log("ERROR","Couldn't pattern-replace line(s) in $filename because open failed.\n");
550 # 0: pattern not in file or the file is not readable
551 # 1: pattern is in file
557 if(-r $file) {
560 # look at each line in the file
561 while (my $line = <FILE>) {
562 # if a line matches the pattern provided then
563 if($line =~ $pattern) {
565 B_log('DEBUG','Pattern: ' . $pattern . ' matched in file: ' .
577 B_log('DEBUG','Pattern: ' . $pattern . ' not matched in file: ' .
579 # the provided pattern was not matched against a line in the file
587 # it's the only content in the file. The only content means it's only but
588 # may have several copies in the file.
591 # 0: pattern not in file or pattern is not the only content
593 # 1: pattern is in file and it's the only content
602 if(-r $file) {
607 while (my $line = <FILED>) {
608 if ($line =~ $pattern) {
626 # This subroutine returns lines in a file matching a given regular
627 # expression, when called in the default list mode. When called in scalar
655 # against the file specified on a line-agnostic form. This allows for
656 # patterns which by necessity must match against a multi-line pattern.
658 # provide multi-line capability not provided by B_replace_line.
661 # 0: pattern not in file or the file is not readable
662 # 1: pattern is in file
678 foreach my $line ( @lines ) {
679 $big_long_line .= $line;
682 # Substitution routines get weird unless last line is terminated with \n
696 # any lines matching $pattern with a "hash-commented" version, like this:
699 # finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd
701 # #finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd
724 my $line;
725 while ($line=<HASH_OLD>) {
726 unless ( ($line =~ $pattern) and ($line !~ /^\s*\#/) ) {
727 &B_print(*HASH_NEW,$line);
730 &B_print(*HASH_NEW,"#$line");
731 &B_log("ACTION","File modification in $filename -- hash commented line\n" .
732 "$line\n" .
734 "#$line\n\n");
735 # while the line has a trailing \ then we should also comment out the line below
736 while($line =~ m/\\\n$/) {
737 if($line=<HASH_OLD>) {
738 &B_print(*HASH_NEW,"#$line");
739 &B_log("ACTION","File modification in $filename -- hash commented line\n" .
740 "$line\n" .
742 "#$line\n\n");
745 $line = "";
755 &B_log("ERROR","Couldn't hash-comment line(s) in $filename because open failed.\n");
766 # #finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd
768 # finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd
782 my $line;
783 while ($line=<HASH_OLD>) {
784 unless ( ($line =~ $pattern) and ($line =~ /^\s*\#/) ) {
785 &B_print(*HASH_NEW,$line);
788 $line =~ /^\s*\#+(.*)$/;
789 $line = "$1\n";
791 &B_print(*HASH_NEW,"$line");
792 &B_log("ACTION","File modification in $filename -- hash uncommented line\n");
793 &B_log("ACTION",$line);
794 # while the line has a trailing \ then we should also uncomment out the line below
795 while($line =~ m/\\\n$/) {
796 if($line=<HASH_OLD>) {
797 $line =~ /^\s*\#+(.*)$/;
798 $line = "$1\n";
799 &B_print(*HASH_NEW,"$line");
800 … &B_log("ACTION","File modification in $filename -- hash uncommented line\n");
801 &B_log("ACTION","#$line");
803 &B_log("ACTION","$line");
806 $line = "";
815 &B_log("ERROR","Couldn't hash-uncomment line(s) in $filename because open failed.\n");
832 # You'd like to remove any timeout= lines in /etc/lilo.conf, so that your
867 foreach my $line ( @lines ) {
868 $big_long_line .= $line;
871 # Substitution routines get weird unless last line is terminated with \n
915 # on any non-commented lines
916 # This (and B_return_matched_lines are only used in this file, though are
946 # on any non-commented lines
947 # This (and B_return_matched_lines are only used in this file, though are
975 foreach my $line (grep(/$inputRegex/,@lines)) {
976 $line =~ /$inputRegex/;
986 &B_log("DEBUG","Could not find regex match in string");
999 # A pending manual action in subsequent reports. Only skip this
1000 # If there's no security-audit relevant action you need the user to
1003 # &B_TODO("------\nInstalling IPFilter\n----\nGo get Ipfilter","IPFilter.install_ipfilter");
1007 # 0 - If error condition
1021 if ( ! -e &getGlobal('BFILE',"TODO") ) {
1022 # Make the TODO list file for HP-UX Distro
1027 "with the date and time in your system administration log. You\n".
1028 "will need that information in case you ever need to revert your\n".
1034 while (my $line = <TODO>) {
1036 $line =~ s/(\\|\||\(|\)|\[|\]|\{|\}|\^|\$|\*|\+|\?|\.)//g;
1037 $multilineString .= $line;
1062 #Note that we only set the flag on the *initial* entry in the TODO File
1064 #complains on a subsequent Bastille run of an already-performed manual
1104 if (-e $todo_flag ) {
1107 foreach my $line (@lines) {
1108 chomp($line);
1109 $GLOBAL_CONFIG{"$line"}{"TODOFlag"}="yes";
1113 return 1; #No-op is okay
1118 #reverted, all the flags will self-clear (file deleted)
1127 if (not( -e $todo_flag)) {
1132 "This will not appear in the file; ensures blanking");