This file is indexed.

/usr/share/perl5/Debian/DocBase/DB.pm is in doc-base 0.10.8.

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
# vim:cindent:ts=2:sw=2:et:fdm=marker:cms=\ #\ %s
#
# $Id: DB.pm 223 2011-02-28 23:34:22Z robert $
#

package Debian::DocBase::DB;

use strict;
use warnings;

use Debian::DocBase::Common;
use Debian::DocBase::Utils;
use Debian::DocBase::Gettext;
use YAML::Tiny;

my $filesdb  = undef;
my $statusdb = undef;

sub new { # {{{
    my $class   = shift;
    my $dbfile  = shift;
    my $enckey  = shift;
    my $self    = {
        YAML    => YAML::Tiny->new,
        DB      => {},
        FILE    => $dbfile,
        ENCKEY  => $enckey,
        CHANGED => 0
    };
    bless($self, $class);
    $self->_Init();
    return $self;
} # }}}

sub _Init() { #  {{{
  my $self = shift;
#  # read-only access for `install-docs --status or --dump-db' run as non-root user
#  my $readonly = $> != 0;
  my $file = $self->{'FILE'};
  if (-f $file)
  {
    eval { $self->{'YAML'} = YAML::Tiny->read ($file) } 
      or Fatal($ERR_DATABASE, _g("Cannot read file `%s': %s."), $file, $@);
  }
  else
  {
    $self->{'YAML'}->[0] = {};
  }
  $self->{'DB'} = \%{$self->{'YAML'}->[0]};
  
} # }}} 

 sub PutData($$$) { # {{{
    my ($self, $key, $data)  = @_;
    $self->{'DB'}->{$self->EncodeKey($key)}   = $data;
    $self->{'CHANGED'} = 1;
} # }}}

sub GetData($$) { # {{{
  my ($self, $key) = @_;
  return $self->{'DB'}->{$self->EncodeKey($key)}
} # }}}

sub GetDBKeys() { # {{{
  my $self = shift;
  my @keys = grep { ! m|^/internal/| } keys %{$self->{'DB'}};   
  map { $_ = $self->DecodeKey($_) } @keys if $self->{'ENCKEY'};
  return @keys;
} # }}} 

sub _SaveDB() { # {{{ 
  my $self = shift;
  my $file = $self->{'FILE'};
  Debug(_g("Saving `%s' (%d)."), $file, $self->{'CHANGED'});
  return unless $self->{'CHANGED'};
  my $readonly = $> != 0;
  Fatal($ERR_PROCESSING, _g("Needs to be root for this operation.")) if $readonly;
  (my $newfile = $file) =~ s/^[^\.]+/$&-new/g;
  (my $oldfile = $file) =~ s/^[^\.]+/$&-old/g;


  eval { $self->{'YAML'}->write($newfile) }  
    or Fatal($ERR_DATABASE, _g("Cannot save file `%s': %s."), $newfile, $@);
  unlink $oldfile if -f $oldfile;
  rename $file, $oldfile if -f $file;
  rename $newfile, $file 
    or Fatal($ERR_DATABASE, _g("Cannot rename file `%s' to `%s': %s."), $newfile, $file, $!);
  $self->{'CHANGED'} = 0;
} # }}}

sub RemoveData($$) # {{{
{
  my ($self, $key) = @_;
  delete $self->{'DB'}->{$self->EncodeKey($key)};
  $self->{'CHANGED'} = 1;
} # }}}

sub Exists($) { # {{{
  my ($self, $key) = @_;
  my $data = $self->{'DB'}->{$self->EncodeKey($key)};
  return $data && %{$data};
} # }}}

sub DumpDB($) { # {{{
  my $self = shift;
  my $db   = $self->{'DB'};

  Inform(_g("Contents of file `%s':")."\n", $self->{'FILE'});
  print STDOUT YAML::Tiny::Dump($db);
} # }}}

sub EncodeKey($$) { # {{{
  my ($self, $key) = @_;
  return $key unless $self->{'ENCKEY'};
  $key =~ s/\/+/\//go;
  $key =~ s/^~/~~/o;
  $key =~ s/^$CONTROL_DIR/~1/o;
  $key =~ s/^$LOCAL_CONTROL_DIR/~2/o;
  return $key;
 } # }}}

 sub DecodeKey($$) { # {{{ 
  my ($self, $key) = @_;
  return $key unless $self->{'ENCKEY'};

  $key =~ s/^~1/$CONTROL_DIR/o;
  $key =~ s/^~2/$LOCAL_CONTROL_DIR/o;
  $key =~ s/^~~/~/o;
  return $key;
} # }}}

### STATIC FUNCTIONS
sub GetFilesDB() { # {{{
  $filesdb     = Debian::DocBase::DB->new($DB_FILES, 1) unless $filesdb;
  return $filesdb;
} # }}} 

sub GetStatusDB() { # {{{
  $statusdb     = Debian::DocBase::DB->new($DB_STATUS, 0) unless $statusdb;
  return $statusdb;
} # }}} 

sub SaveDatabases()
{
  IgnoreSignals();
  $statusdb->_SaveDB() if $statusdb;
  $filesdb->_SaveDB()  if $filesdb;
  RestoreSignals();
}
1