This file is indexed.

/usr/share/perl5/NOTEDB.pm is in note 1.3.7-1.

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

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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#
# this is a generic module, used by note database
# backend modules.
#
# Copyright (c) 2000-2004 Thomas Linden <tom@daemon.de>


package NOTEDB;

use Exporter ();
use vars qw(@ISA @EXPORT $crypt_supported);

$NOTEDB::VERSION = "1.31";

BEGIN {
    # make sure, it works, otherwise encryption
    # is not supported on this system!
    eval { require Crypt::CBC; };
    if($@) {
	$NOTEDB::crypt_supported = 0;
    }
    else {
	$NOTEDB::crypt_supported = 1;
    }
}


sub no_crypt {
    $NOTEDB::crypt_supported = 0;
}


sub use_crypt {
    my($this,$key,$method) = @_;
    my($cipher);
    if($NOTEDB::crypt_supported == 1) {
	eval {
	    $cipher = new Crypt::CBC($key, $method);
	};
	if($@) {
	  print "warning: Crypt::$method not supported by system!\n";
	  $NOTEDB::crypt_supported = 0;
	}
	else {
	    $this->{cipher} = $cipher;
	}
    }
    else{
	print "warning: Crypt::CBC not supported by system!\n";
    }
}


sub use_cache {
    #
    # this sub turns on cache support
    #
    my $this = shift;
    $this->{use_cache} = 1;
    $this->{changed}   = 1;
}

sub cache {
    #
    # store the whole db as hash
    # if use_cache is turned on
    #
    my $this = shift;
    if ($this->{use_cache}) {
	my %res = @_;
	%{$this->{cache}} = %res;
    }
}

sub unchanged {
    #
    # return true if $this->{changed} is true, this will
    # be set to true by writing subs using $this->changed().
    #
    my $this = shift;
    return 0 if(!$this->{use_cache});
    if ($this->{changed}) {
	$this->{changed} = 0;
	return 0;
    }
    else {
	print "%\n";
	return 1;
    }
}

sub changed {
    #
    # turn on $this->{changed}
    # this will be used by update or create subs.
    #
    my $this = shift;
    $this->{changed} = 1;
}


sub generate_search {
    #
    # get user input and create perlcode ready for eval
    #  sample input:
    # "ann.a OR eg???on AND u*do$"
    #  resulting output:
    # "$match = 1 if(/ann\.a/i or /eg...on/i and /u.*do\$/i );
    #
    my($this, $string) = @_;

    my $case = "i";

    if ($string =~ /^\/.+?\/$/) {
      return $string;
    }
    elsif (!$string) {
      return "/^/";
    }

    # we will get a / in front of the first word too!
    $string = " " . $string . " ";

    # check for apostrophs
    $string =~ s/(?<=\s)(\(??)("[^"]+"|\S+)(\)??)(?=\s)/$1 . $this->check_exact($2) . $3/ge;

    # remove odd spaces infront of and after »and« and »or«
    $string =~ s/\s\s*(AND|OR)\s\s*/ $1 /g;

    # remove odd spaces infront of »(« and after »)«
    $string =~ s/(\s*\()/\(/g;
    $string =~ s/(\)\s*)/\)/g;

    # remove first and last space so it will not masked!
    $string =~ s/^\s//;
    $string =~ s/\s$//;

    # mask spaces if not infront of or after »and« and »or«
    $string =~ s/(?<!AND)(?<!OR)(\s+?)(?!AND|OR)/'\s' x length($1)/ge;

    # add first space again
    $string = " " . $string;

    # lowercase AND and OR
    $string =~ s/(\s??OR\s??|\s??AND\s??)/\L$1\E/g;

    # surround brackets with at least one space
    $string =~ s/(?<!\\)(\)|\()/ $1 /g;

    # surround strings with slashes
    $string =~ s/(?<=\s)(\S+)/ $this->check_or($1, $case) /ge;

    # remove slashes on »and« and »or«
    $string =~ s/\/(and|or)\/$case/$1/g;

    # remove spaces inside /string/ constructs
    $string =~ s/(?<!and)(?<!or)\s*\//\//g;

    $string =~ s/\/\s*(?!and|or)/\//g;

    #my $res = qq(\$match = 1 if($string););
    return qq(\$match = 1 if($string););
    #print $res . "\n";
    #return $res;
}

sub check_or {
  #
  # surrounds string with slashes if it is not
  # »and« or »or«
  #
  my($this, $str, $case) = @_;
  if ($str =~ /^\s*(or|and)\s*$/) {
    return " $str ";
  }
  elsif ($str =~ /(?<!\\)[)(]/) {
    return $str;
  }
  else {
    return " \/$str\/$case ";
  }
}


sub check_exact {
  #
  # helper for generate_search()
  # masks special chars if string
  # not inside ""
  #
  my($this, $str) = @_;

  my %wildcards = (
		   '*' => '.*',
		   '?' => '.',
		   '[' => '[',
		   ']' => ']',
		   '+' => '\+',
		   '.' => '\.',
		   '$' => '\$',
		   '@' => '\@',
		   '/' => '\/',
		   '|' => '\|',
		   '}' => '\}',
		   '{' => '\{',
	      );

  my %escapes  = (
		  '*' => '\*',
		  '?' => '\?',
		  '[' => '[',
		  ']' => ']',
		  '+' => '\+',
		  '.' => '\.',
		  '$' => '\$',
		  '@' => '\@',
		  '(' => '\(',
		  ')' => '\)',
		  '/' => '\/',
		  '|' => '\|',
		  '}' => '\}',
		  '{' => '\{',
		 );

  # mask backslash
  $str =~ s/\\/\\\\/g;


  if ($str =~ /^"/ && $str =~ /"$/) {
    # mask bracket-constructs
      $str =~ s/(.)/$escapes{$1} || "$1"/ge;
  }
  else {
      $str =~ s/(.)/$wildcards{$1} || "$1"/ge;
  }

  $str =~ s/^"//;
  $str =~ s/"$//;

  # mask spaces
  $str =~ s/\s/\\s/g;
  return $str;
}




sub lock {
  my ($this) = @_;

  if (-e $this->{LOCKFILE}) {
    open LOCK, "<$this->{LOCKFILE}" or die "could not open $this->{LOCKFILE}: $!\n";
    my $data = <LOCK>;
    close LOCK;
    chomp $data;
    print "-- waiting for lock by $data --\n";
    print "-- remove the lockfile if you are sure: \"$this->{LOCKFILE}\" --\n";
  }

  my $timeout = 60;

  eval {
    local $SIG{ALRM} = sub { die "timeout" };
    local $SIG{INT}  = sub { die "interrupted"   };
    alarm $timeout - 2;
    while (1) {
      if (! -e $this->{LOCKFILE}) {
	umask 022;
	open LOCK, ">$this->{LOCKFILE}" or die "could not open $this->{LOCKFILE}: $!\n";
	flock LOCK, LOCK_EX;

	my $now = scalar localtime();
	print LOCK "$ENV{USER} since $now (PID: $$)\n";

	flock LOCK, LOCK_UN;
	close LOCK;
	alarm 0;
	return 0;
      }
      printf " %0d\r", $timeout;
      $timeout--;
      sleep 1;
    }
  };
  if($@) {
    if ($@ =~ /^inter/) {
      print " interrupted\n";
    }
    else {
      print $@;
      print " timeout\n";
    }
    return 1;
  }
  return 0;
}

sub unlock {
  my ($this) = @_;
  unlink $this->{LOCKFILE};
}



1;