This file is indexed.

/usr/share/perl5/SyncUtil/localHashDB.pm is in syncbbdb 2.6-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
#------------------------------------------------------------------------------
#   $Date: 2005/02/13 16:55:08 $
#   RCS: $Id: localHashDB.pm,v 1.2 2005/02/13 16:55:08 aaronkaplan Exp $
#------------------------------------------------------------------------------

package localHashDB;

use strict;
require  Digest::MD5;

require SyncUtil::localDB;
@localHashDB::ISA = qw(localDB);

sub new {
  my $type = shift;
  my $self = localDB->new(shift);

  bless ($self, $type);

  $self->{'hashObj'}  = shift;
  $self->{'hash'} = {};
  $self->{'new-recs'} = [];
  $self->{'mismatch'} = {};

  return $self;
}

sub getRecords {
  my $self = shift;

  die "Subclass must implement getRecords to return all local records.";
}

sub toString {
  my $self = shift;
  my $rec  = shift;

  die ("Subclass must implement toString to return a string containing\n" .
       "all the pertinate information of record.\n"); 
}

sub hashRecord {
  my $self   = shift;
  my $rec = shift;
  my($hash) = new Digest::MD5;
  $hash->add($self->toString($rec));
  return $hash->hexdigest;
}

sub setup {
    my $self = shift;

    $self->localDB::setup(shift, shift);

    foreach my $rec (@{$self->getRecords()}) {

	$self->update(); # Give our host some time...

	my @ids = @{$self->getPilotIDs($rec)};
	
	if (!scalar(@ids)) {
	    push(@{$self->{'new-recs'}}, $rec);
	} else {
	    foreach my $id (@ids) {
		$self->{'hash'}{$id} = $rec;
	    }
	}
    }
}

sub getRec {
  my $self = shift;
  my $id   = shift;
  return $self->{'hash'}{$id};
}

sub addRec {
  my $self = shift;
  my $rec  = shift;
  my $hash = $self->hashRecord($rec);

  foreach my $id (@{$self->getPilotIDs($rec)}) {
      $self->{'hash'}{$id} = $rec;
      $self->{'hashObj'}->setLocalHash($id, $hash);
  }
}

sub deleteRec {
  my $self = shift;
  my $id   = shift;
  
  my $rec  = $self->{'hash'}{$id};
  return if (not defined $rec);

  foreach my $r (@{$self->getRecords()}) {
    if (defined $r) {
      $r = undef if ($r == $rec);
    }
  }

  $self->{'hashObj'}->setLocalHash($id, undef);
  $self->{'hashObj'}->setPilotHash($id, undef);

  return $rec;
}

sub lastSyncDate {
  my $self = shift;
  return $self->{'hashObj'}->syncDate();
}

sub getNew {
  my $self     = shift;

  return $self->{'new-recs'};
}

sub getMod {
  my $self     = shift;

  my @mod = ();

  foreach my $rec (@{$self->getRecords()}) {

    $self->update(); # Give our host some time...

    my @ids = @{$self->getPilotIDs($rec)};
    next if (! scalar(@ids));  ## new record not mod...

    my $old_hash = $self->{'hashObj'}->getLocalHash($ids[0]);

    my $new_hash = $self->hashRecord($rec);

    if (!defined $old_hash)
    {
	# We have a pilot id but our hash isn't in the ids file.
	# Something bad probably happened to our ids list...
	# we will assume this record was modified.
	$self->{'mismatch'}{$ids[0]} = $rec;
	$old_hash = "";  #force it not to match
    }

    if ($new_hash ne $old_hash)
    { 
	push(@mod,$rec); 
	foreach my $id (@ids) {
	    $self->{'hashObj'}->setLocalHash($id, $new_hash);
	}
    }
  }

  my @keys = keys(%{$self->{'mismatch'}});
  if (scalar @keys) 
  {
      my $x = scalar @keys;
      $self->getHost()->output
	  ("Found $x record(s) in BBDB with pilot-id's but not in ids file\n" .
	   "This probably indicates a problem with 'ids' file (deleted?).\n" .
	   "Examples: \n");

      $x=0;
      foreach my $k (@keys) {
	  $self->output($self->{'mismatch'}{$k});
	  last if (++$x == 10);
      }

      if ($x < scalar(@keys)) {
	  $self->getHost()->output("more...");
      }
  }

  return \@mod;
}

sub getDel {
  my $self     = shift;

  my @del = ();
  my $hashObj = $self->{'hashObj'};

  foreach my $id (keys %{$hashObj->{'ids'}}) {

    $self->update(); # Give our host some time...

    ## We have a local hash value for this ID but no record...
    ## must have been deleted...
    if ((!defined $self->{'hash'}{$id}) &&
	(defined $self->{'hashObj'}->getLocalHash($id))) {
      push(@del,$id) ;

      #Remove $id from the hash since it is going away...
      $hashObj->setLocalHash($id,undef);
    }
  }
  return \@del;
}

1;