This file is indexed.

/usr/bin/ainsl is in fai-client 5.0.3ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#! /usr/bin/perl

#*********************************************************************
#
# ainsl -- AppendIfNoSuchLine written in Perl
#
# This script is part of FAI (Fully Automatic Installation)
# Copyright (C) 2006-2012 Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# A copy of the GNU General Public License is available as
# '/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html.  You
# can also obtain it by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#*********************************************************************

use strict;

use Getopt::Std;
our ($opt_a,$opt_h,$opt_D,$opt_n,$opt_s,$opt_v,$opt_q,$opt_Q,$opt_N);

my $filename;
my $verbose;
my $debug;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub usage {

  my $exitcode = shift;

  print << "EOF";
ainsl, AppendIfNoSuchLine written in Perl.

   Copyright (C) 2006-2012 by Thomas Lange

Usage: ainsl [OPTION] FILE LINE [PATTERN]

   -a         Autocreate file if not existing.
   -D         Create debug output.
   -h         Show summary of options.
   -n         Print the actions, but do not execute them.
   -Q         Quote all metacharacters in pattern. Uses perl\'s \\Q function.
   -q         Quote * and + metacharacters in pattern.
   -s         Convert blanks in line to '\\s+' regexp.
   -N         Don't prepend '\$AINSL_TARGET/' to filename, even if it is set.
   -v         Create verbose output.

EOF
  exit $exitcode;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub autocreate {

  -f $filename and return;

  # create missing parts of a path. Could be replaced by File::Path
  my $path;
  while ($filename =~ m#([^/]+)/#g) {
    $path.="/$1";
    -d $path and next;
    print "ainsl: create $path\n" if $debug;
    $opt_n and next;
    mkdir $path or die "ainsl: can't create $path $!";
  }

  print "ainsl: create $filename\n" if $verbose;
  $opt_n and return;
  open (FILE,">$filename") or die "ainsl: can't create $filename $!";
  close (FILE);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getopts('aDhsvnQqN') or usage(3);

$opt_h and usage(0);
$verbose = $opt_v || $ENV{verbose} || 0;
$debug   = $opt_D || $ENV{debug}   || 0;

$filename = shift;
my $line     = shift;
my $optpattern  = shift;
my $found = 0;
usage(3) unless defined $line;

if (! $opt_N) {
  $ENV{AINSL_TARGET} and $filename = "$ENV{AINSL_TARGET}/$filename";
}
$filename =~ s#//+#/#g; # multiple slashes -> one slash

print "FILE: $filename\nLINE: $line\nPATTERN: ", $optpattern || "[NO PATTERN SPECIFIED]", "\n" if $debug;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$opt_a and autocreate;

my $pattern = (defined $optpattern) ? $optpattern : $line;
# process pattern and line
# remove ^ and $ in line (only at start and end), but still use it for pattern
# in no explicit pattern was given

unless (defined $optpattern) {
# remove special chars ^ and $ from line
  $line =~ s/^\^//;
  $line =~ s/\$$//;
# escape '(', ')' and '+' if no pattern was given and line is used
  $pattern =~ s/\(/\\(/g;
  $pattern =~ s/\)/\\)/g;
  $pattern =~ s/\+/\\+/g;
}
$opt_s and $pattern =~ s/\s+/\\s+/g;
$opt_q and $pattern =~ s/\*/\\*/g;
$opt_q and $pattern =~ s/\+/\+/g;
$pattern="\Q$pattern\E" if $opt_Q;

print "ainsl: newpattern: $pattern\n" if $debug;
print "ainsl: newline: $line\n" if $debug;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# check if pattern already included in file
-f $filename or die "ainsl: target file $filename does not exist.\n";
open (INFILE, "<$filename") or die "ainsl: Can't open $filename $!\n";
my $lastline = "";
while ($lastline = <INFILE>) {
  if ($lastline =~ /$pattern/o) {
    print "ainsl: Pattern found. Nothing to append.\n" if $debug;
    $found=1;
    last;
  }
}
close(INFILE);
exit 0 if $found; # nothing to append
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Append line to file
print "ainsl: appending to $filename: $line\n" if $verbose;
exit 0 if $opt_n;
open (INFILE, ">>$filename") or die "ainsl: can't open $filename for writing. $!";
if ($lastline && substr($lastline, -1) ne "\n") {
  print INFILE "\n" or die "ainsl: cannot print to file $filename: $!";
}
print INFILE $line, "\n" or die "ainsl: cannot print to file $filename: $!";
close(INFILE) or die "ainsl: error saving file $filename: $!";