This file is indexed.

/usr/share/perl5/SyncUtil/pilotDB.pm is in syncbbdb 2.3-6.2.

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
#------------------------------------------------------------------------------
#   $Date: 2000/08/06 19:45:02 $
#   RCS: $Id: pilotDB.pm,v 1.3 2000/08/06 19:45:02 deweese Exp $
#------------------------------------------------------------------------------

package pilotDB;

use strict;

sub new {
  my $type = shift;
  my $self = {};
  bless ($self, $type);

  $self->{'host'} = shift;
  $self->{'dlp'}  = shift;
  $self->{'info'} = shift;

  $self->{'last-time'} = 0;
  $self->{'fast'}      = "";
  $self->{'localDB'}   = "";

  $self->{'hash'}      = {};

  $self->{'new'} = [];
  $self->{'mod'} = [];
  $self->{'del'} = [];
  $self->{'arc'} = [];

  return $self;
}

sub getHost {
  my $self = shift;
  return $self->{'host'};
}

sub lastSyncPC {
  my $self = shift;
  return $self->{'info'}->{'lastSyncPC'};
}

sub lastSyncDate {
  my $self = shift;
  return $self->{'info'}->{'successfulSyncDate'};
}

sub getPilotID {
  my $self = shift;
  my $rec  = shift;
  return $rec->{'id'};
}

sub getNew {
  my $self = shift;
  $self->{'new'};
}

sub getMod {
  my $self = shift;
  $self->{'mod'};
}

sub getDel {
  my $self = shift;
  $self->{'del'};
}

sub update {
  my $self = shift;
  my $ctime = time();
  # at least once a second give host some time...
  if ($self->{'last-time'} != $ctime)
    {
      $self->{'host'}->update();
      $self->{'last-time'} = $ctime;
    }
}

##############################################################################
###
###  This section contains methods that all subclasses MUST implement.
###
##############################################################################


sub slowSync {
  die ("Subclass must implement this to build 'new', 'mod', 'del', & 'arc'\n" .
       "Lists for base class.  This is only called for a SlowSync.\n" .
       "See pilotHashDB.pm for an implementaiton based on MD5 Hashes\n");
}

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

  die ("Subclass must implement dupRec to copy $rec and return the\n"    .
       "copy.  Care must be taken to clear the associated pilot-id in\n" .
       "the new record");
}

sub syncRec {
  my $self      = shift;
  my $local_rec = shift;
  my $pilot_rec = shift;
  
  die ("Subclass must implement syncRec to merge contents of other_rec\n".
       "into this_rec (may be undef in which case create a new record).");

  ## You need to take care to put the new record into local data structures...
  ## Subclasses will need to tack at least the following into the end
  ## of there syncRec function.  
  ## Example:

  ##   # Send the modified record back to the Pilot...
  ##   $self->setRec($pilotRec);
}

##############################################################################
###
###  This section contains methods that many subclasses may want to 
###  override.
###
##############################################################################


sub name {
  my $self = shift;
  return "Pilot DB";
}

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

  ## Subclasses should really implement this to output a human
  ## readable one line description of rec.

  ## output the pilot record id if nothing else...
  $self->getHost()->output($self->getPilotID($rec) . "\n");
}

##############################################################################
###
###  This section contains methods that many subclasses may want to
###  augment. You need to call the base classes version of these
###  methods as well. Example:
###
###   $self->localDB::setup($fast, $pilotDB).
###
##############################################################################

sub setup {
  my $self = shift;

  $self->{'fast'}    = shift;
  $self->{'localDB'} = shift;

  if ($self->{'fast'}) {
    $self->fastSync();
  } else {
    $self->slowSync();
  }
}

sub finish {
  ## Make _SURE_ you call this or do the same thing in subclasses!!!!
  my $self = shift;

  
  $self->{'db'}->purge();       ## remove deleted items.
  $self->{'db'}->resetFlags();  ## reset modified flags.
  $self->{'db'}->close();       ## close the database
}


# Put a record back into the Pilot.
sub setRec {
  my $self = shift;
  my $rec  = shift;

  $rec->{'id'} ||= 0; ## make sure it's set (to zero if nothing else).

  my $id = $self->{'db'}->setRecord($rec);

  if ($id) {
    $rec ->{'id'}        = $id;
    $self->{'hash'}{$id} = $rec;
  }

  return $id;
}

sub getRec {
  my $self = shift;
  my $id   = shift;

  return $self->{'hash'}{$id} if (defined $self->{'hash'}{$id});
  
  my $rec = $self->{'db'}->getRecordByID($id);
  if (defined $rec) {
    $self->{'hash'}{$id} = $rec;
  }
  return $rec;
}

sub deleteRec {
  my $self = shift;
  my $id   = shift;

  my($result) = $self->{'db'}->deleteRecord($id);

  if ($result>=0) {
    delete $self->{'hash'}{$id};
  }

  return $result;
}

sub fastSync {
  # We can trust the pilot to send us all the changed, deleted, etc records...

  ## This may be useful to wrap in a subclass in order to update
  ## important data structures (such as hash information).

  ## This handles the generation of 'new', 'mod', 'del' & 'arc' list
  ## Only called for 'fast' syncs.

  my $self = shift;
  my $db   = $self->{'db'};

  my $r;
  my $i=0;
  while(defined($r = $db->getNextModRecord())) 
  {
      $self->{'host'}->status("Reading Pilot Addresses [fast sync]", $i++);
      $i = 90 if ($i > 98);

      if ($r->{'deleted'}) 
	{
	  push(@{$self->{'arc'}}, $r) if ($r->{'archived'});
	  push(@{$self->{'del'}}, $r->{'id'});
	  
	  #Remove 'id' from the hash since it is going away...
	  $self->{'hashObj'}->setPilotHash($r->{'id'}, undef);
	} 
      else 
	{
	  $self->{'hash'}{$r->{'id'}} = $r;
	  if ($r->{'modified'}) {
	    if (!defined($self-> {'hashObj'}->getPilotHash($r->{'id'}))) {
	      push (@{$self->{'new'}}, $r);
	    } else {
	      push (@{$self->{'mod'}}, $r);
	    }
	}
      }
      
      $self->update();		# Give our host some time...
    }

  $self->{'host'}->status("Reading Pilot Addresses [fast sync]", 100);
}

1;