This file is indexed.

/usr/share/perl5/EB/Main.pm is in eekboek 2.02.05+dfsg-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
#! perl --			-*- coding: utf-8 -*-

use utf8;

# Author          : Johan Vromans
# Created On      : Thu Jul  7 15:53:48 2005
# Last Modified By: Johan Vromans
# Last Modified On: Sat Aug 11 21:13:47 2012
# Update Count    : 1009
# Status          : Unknown, Use with caution!

################ Common stuff ################

package main;

our $cfg;
our $dbh;

package EB::Main;

use strict;
use warnings;

use EekBoek;
use EB;
use EB::DB;
use Getopt::Long 2.13;

################ The Process ################

sub run {
    my ( $pkg, $opts ) = @_;
    $opts = {} unless defined $opts;
    binmode(STDOUT, ":encoding(utf8)");
    binmode(STDERR, ":encoding(utf8)");

    # Preliminary initialize config.
    EB->app_init( { app => $EekBoek::PACKAGE } );

    # Command line options.
    $opts =
      { interactive   => -t,		# runs interactively
	#command,			# command to process
	#echo,				# echo input
	confirm	      => 0,		# NYI
	#journal,			# show journal
	#inexport,			# in/export
	#file,				# file voor in/export
	#dir,				# directory voor in/export
	#title,				# title for export
	#errexit			# disallow errors in batch
	verbose	      => 0,		# verbose processing
	#boekjaar,			# boekjaar

	# Development options (not shown with -help).
	debug	     => 0,		# debugging
	trace	     => 0,		# trace (show process)
	test	     => 0,		# test mode.

	# Let supplied options override.
	%$opts,
      };

    # Process command line options.
    app_options($opts);

    # Post-processing.
    $opts->{trace} |= ($opts->{debug} || $opts->{test});

    # Initialize config.
    EB->app_init( { app => $EekBoek::PACKAGE, %$opts } );
    if ( $opts->{printconfig} ) {
	$cfg->printconf( \@ARGV );
	exit;
    }

    my $userdir = $cfg->user_dir;
    mkdir($userdir) unless -d $userdir;

    unless ( defined($opts->{wizard}) && !$opts->{wizard} ) {
      if ( $opts->{wizard}
	 or
	 !$opts->{config}
	 && ( ( -e $cfg->std_config || -e $cfg->std_config_alt ) ? $cfg->val( qw(general wizard), 0 ) : 1 )
       ) {
	require EB::IniWiz;
	EB::IniWiz->run($opts); # sets $opts->{runeb}
	die("?"._T("Geen administratie geselecteerd")."\n") unless $opts->{runeb};
	EB->app_init( { app => $EekBoek::PACKAGE, %$opts } );
      }
    }

    $opts->{echo} = "eb> " if $opts->{echo};

    my $dataset = $cfg->val(qw(database name), undef);

    unless ( $dataset ) {
	die("?"._T("Geen EekBoek database opgegeven.".
		   " Specificeer een database in de configuratiefile,".
		   " of selecteer een andere configuratiefile".
		   " op de command line met \"--config=...\".").
	    "\n");
    }

    $cfg->newval(qw(database name), $dataset);
    $cfg->newval(qw(preferences journal), $opts->{journal})
      if defined $opts->{journal};

    $dbh = EB::DB->new(trace => $opts->{trace});

    my $createdb;
    if ( defined $opts->{inexport} ) {
	if ( $opts->{inexport} ) {
	    $opts->{command} = 1;
	    $createdb = 1;
	    @ARGV = qw(import --noclean);
	    push(@ARGV, "--file", $opts->{file})
	      if defined $opts->{file};
	    push(@ARGV, "--dir", $opts->{dir})
	      if defined $opts->{dir};
	}
	else {
	    $opts->{command} = 1;
	    @ARGV = qw(export);
	    push(@ARGV, "--file", $opts->{file})
	      if defined $opts->{file};
	    push(@ARGV, "--dir", $opts->{dir})
	      if defined $opts->{dir};
	    push(@ARGV, "--titel", $opts->{title})
	      if defined $opts->{title};
	}
    }

    if ( $createdb ) {
	$dbh->createdb($dataset);
	warn("%".__x("Lege database {db} is aangemaakt", db => $dataset)."\n");
    }

    return 0 if $opts->{command} && !@ARGV;

    require EB::Shell;
    my $shell = EB::Shell->new
      ({ HISTFILE	   => $userdir."/history",
	 command	   => $opts->{command},
	 interactive	   => $opts->{interactive},
	 errexit	   => defined($opts->{errexit})?$opts->{errexit}:$cfg->val(qw(shell errexit),0),
	 verbose	   => $opts->{verbose},
	 trace		   => $opts->{trace},
	 journal	   => $cfg->val(qw(preferences journal), 0),
	 echo		   => $opts->{echo},
	 prompt		   => lc($cfg->app),
	 boekjaar	   => $opts->{boekjaar},
       });

    $| = 1;

    $shell->run;

}

################ Subroutines ################

################ Subroutines ################

sub app_options {
    my ( $opts ) = @_;

    # Process options, if any.
    # Make sure defaults are set before returning!
    return unless @ARGV > 0;

    Getopt::Long::Configure(qw(no_ignore_case));

    if ( !GetOptions( $opts,
		      'command|c'    => sub {
			  $opts->{command} = 1;
			  die("!FINISH\n");
		      },
		      'import'       => sub {
			  $opts->{inexport} = 1;
		      },
		      'export'       => sub {
			  $opts->{inexport} = 0;
		      },
		      'init'         => sub {
			  $opts->{inexport} = 1;
			  $opts->{dir} = ".";
		      },
		      'define|D=s%',
		      'printconfig|P',
		      'nostdconf|X',
		      'config|f=s',
		      'title|titel=s',
		      'echo|e!',
		      'ident',
		      'journaal',
		      'boekjaar=s',
		      'verbose',
		      'dir=s',
		      'file=s',
		      'interactive!',
		      'wizard!',
		      'errexit!',
		      'trace',
		      'help|?',
		      'debug',
		    ) or $opts->{help} )
    {
	app_usage(2);
    }
    app_usage(2) if @ARGV && !($opts->{command} || $opts->{printconfig});
    app_ident() if $opts->{ident};
}

sub app_ident {
    return;
    print STDERR (__x("Dit is {pkg} [{name} {version}]",
		      pkg     => $EekBoek::PACKAGE,
		      name    => "Shell",
		      version => $EekBoek::VERSION) . "\n");
}

sub app_usage {
    my ($exit) = @_;
    app_ident();
    print STDERR __x(<<EndOfUsage, prog => $0);
Gebruik: {prog} [options] [file ...]

    --command  -c	voer de rest van de opdrachtregel uit als command
    --echo  -e		toon ingelezen opdrachten
    --boekjaar=XXX	specificeer boekjaar
    --import		importeer een nieuwe administratie
    --export		exporteer een administratie
    --dir=XXX		directory voor im/export
    --file=XXX		bestand voor im/export
    --titel=XXX		omschrijving voor export
    --init		(re)creƫer administratie
    --help		deze hulpboodschap
    --ident		toon identificatie
    --verbose		geef meer uitgebreide information

Voor experts:

    --config=XXX -f	specificeer configuratiebestand
    --nostdconf -X	gebruik uitsluitend dit configuratiebestand
    --define=XXX -D	definieer configuratiesetting
    --printconfig -P	print config waarden
    --[no]interactive	forceer [non]interactieve modus
    --[no]errexit	stop direct na een fout in de invoer
EndOfUsage
    CORE::exit $exit if defined $exit && $exit != 0;
}

1;