This file is indexed.

config is in libapache-sessionx-perl 2.01-4.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#! /usr/bin/perl -w

package Debconf::Client::ConfModuleX;

#
# Add the error checking behaviour that I think
# Debconf::Client::ConfModule should have anyway
#

use Debconf::Client::ConfModule;

use base qw(Exporter);

BEGIN {
  *EXPORT_OK = \@Debconf::Client::ConfModule::EXPORT_OK;
  *EXPORT_TAGS = \%Debconf::Client::ConfModule::EXPORT_TAGS;
}

sub AUTOLOAD {
  my $cmd = our $AUTOLOAD;
  $cmd =~ s|.*:||;

  my ($ret, $text) = &{"Debconf::Client::ConfModule::$cmd"}(@_);
  if ($ret == 0 or $ret >= 30 && $ret < 100) {
    # expected return values
    return wantarray ? ($ret, $text) : $text;
  }

  $cmd = uc $cmd;
  my $msg = $text ? "$text ($ret)" : "code $ret";

  require Carp;
  if ($ret < 10 || $ret >= 110) {
    Carp::confess("Debconf $cmd returned reserved error code? $msg");
  } elsif ($ret < 20) {
    # Dump @_ ?
    Carp::croak("Debconf $cmd: invalid parameters: $msg");
  } elsif ($ret < 30) {
    Carp::confess("Debconf $cmd: syntax error: $msg");
  } else { # $ret < 110
    Carp::confess("Debconf $cmd: debconf internal error: $msg");
  }
}

1;



package main;

#use Debconf::Client::ConfModuleX qw(:all);
BEGIN { Debconf::Client::ConfModuleX->import(qw(:all)) }

use strict;

use subs qw(new_store newkey delkey);


# ** Keys must match list in libapache-sessionx-perl/store_type:Choices **
# ** and mixed-case entries match values in postinst:%Store             **
my %types = (File => [name => 'store_name',
		      Directory => 'store_file_directory',
		     ],
	     FileFile => [name => 'store_name',
			  Directory => 'store_file_directory',
			  LockDirectory => 'store_file_lockdirectory',
			 ],
	     DB_File => [name => 'store_name',
			 FileName => 'store_dbfile_filename',
			 LockDirectory => 'store_file_lockdirectory',
			],
	     Mysql => [name => 'store_name',
		       [DataSource => 'store_mysql_datasource',
			UserName => 'store_mysql_username',
			Password => 'store_mysql_password'],
		      ],
	     MysqlMysql => [name => 'store_name',
			    [DataSource => 'store_mysql_datasource',
			     UserName => 'store_mysql_username',
			     Password => 'store_mysql_password'],
			    [LockDataSource => 'store_mysql_lockdatasource',
			     LockUserName => 'store_mysql_lockusername',
			     LockPassword => 'store_mysql_lockpassword'],
			   ],
	     Oracle => [name => 'store_name',
			[DataSource => 'store_oracle_datasource',
			 UserName => 'store_oracle_username',
			 Password => 'store_oracle_password'],
		       ],
	     Sybase => [name => 'store_name',
			[DataSource => 'store_sybase_datasource',
			 UserName => 'store_sybase_username',
			 Password => 'store_sybase_password'],
		       ],
	     Postgres => [name => 'store_name',
			  [DataSource => 'store_postgres_datasource',
			   UserName => 'store_postgres_username',
			   Password => 'store_postgres_password'],
			 ],
	    );
sub mkquestions {
  my $key = shift;
  my $opts = shift;
  my @res = ();
  while (my $arg = shift) {
    if (ref($arg)) {
      $opts->{beginblock}->() if $opts->{beginblock};
      push @res, mkquestions($key, $opts, @$arg);
      $opts->{endblock}->() if $opts->{endblock};
    } else {
      my $tmpl = shift;
      my $lcarg = lc $arg;
      my $q = "libapache-sessionx-perl/store_${key}_${lcarg}";

      $opts->{question}->($q, $tmpl) if $opts->{question};

      push @res, $q;
    }
  }
  @res;
}


my $debug = $ENV{DEBIAN_APACHE_SESSIONX_DEBUG};

title 'Apache::SessionX Configuration';

my ($ret) = version '2.0';
die "debconf too old\n" if $ret == 30;

my %capb = ();
$capb{$_} = 1 foreach capb('backup');
#die "frontend doesn't support multiselect\n" unless $capb{multiselect};

my @stores = map {
  my $name = get "libapache-sessionx-perl/store_${_}_name";
  my $type = get "libapache-sessionx-perl/store_${_}_type";
  { key => $_, name => $name, type => $type };
} split /,/, get 'libapache-sessionx-perl/priv_keys';

unless (@stores) {
  # no keys -> create default file stores
  new_store 'File',
    type => 'File',
    Directory => '/var/lib/libapache-sessionx-perl/File';
  new_store 'FileFile',
    type => 'FileFile',
    Directory => '/var/lib/libapache-sessionx-perl/FileFile',
    LockDirectory => '/var/lib/libapache-sessionx-perl/FileFile/locks';
  new_store 'DB_File',
    type => 'DB_File',
    FileName => '/var/lib/libapache-sessionx-perl/DB_File/sessions.db',
    LockDirectory => '/var/lib/libapache-sessionx-perl/DB_File';
  set 'libapache-sessionx-perl/default_store', 'File';
  fset 'libapache-sessionx-perl/default_store', seen => 'false';
}

my @history = ();
my $state;

my $store;			# FIXME: put this in @history

STATE:
while (1) {
  $state ||= 'main';
  my $thisstate = $state;

  if ($debug) {
    warn "state is $state. history is ", join(',', @history);
    require Data::Dumper;
    warn "stores are: ", Data::Dumper::Dumper(\@stores);
  }

  if ($state eq 'main') {

    my $q = 'libapache-sessionx-perl/action';

    set $q, 'Finished';		# avoid really bad loops
    subst $q, stores => join(', ', map($_->{name}, @stores));
    input medium => $q;

    my ($ret) = go;
    if ($ret == 30) { $state = pop @history; next STATE }

    my $action = get $q;
    if ($action eq 'Finished') {
      $state = 'default';
    } elsif ($action eq 'Add New') {
      $state = 'new';
    } else {
      # find $store called $action
      foreach (@stores) {
	if ($action eq $_->{name}) {
	  $store = $_;
	  last;
	}
      }
      $state = 'modify_delete';
    }

  } elsif ($state eq 'new') {

    my $key = newkey;		# FIXME: what about if we reached here by going back?
    $store = $stores[-1];

    my $q = "libapache-sessionx-perl/store_${key}_type";

    register 'libapache-sessionx-perl/store_type', $q;
    input critical => $q;

    my ($ret) = go;
    if ($ret == 30) {
      delkey $key;
      unregister $q;
      $state = pop @history;
      next STATE
    }

    $store->{type} = get $q;

    $state = 'configure_store';

  } elsif ($state eq 'configure_store') {

    my $type = $store->{type};
    my $key = $store->{key};

    # seed questions for $type
    my @qs = mkquestions($key, {question => sub {
				  register "libapache-sessionx-perl/$_[1]", $_[0];
				  input high => $_[0];
				},
				beginblock => \&beginblock,
				endblock => \&endblock,
			       },
			 @{$types{$type}});

    my ($ret) = go;
    if ($ret == 30) {
      unregister($_) foreach @qs;
      $state = pop @history; next STATE;
    }

    $store->{name} = get "libapache-sessionx-perl/store_${key}_name";

    # most likely, we want the store we just configured ..
    set 'libapache-sessionx-perl/default_store', $store->{name};
    #  .. but we might not
    fset 'libapache-sessionx-perl/default_store', seen => 'false';

    $state = 'main';

  } elsif ($state eq 'default') {

    my $q = 'libapache-sessionx-perl/default_store';

    if (@stores == 0) {
      # skip question altogether
      $state = 'last';
      next STATE;

    } elsif (@stores == 1) {
      # skip question altogether, after choosing the only option
      set $q, $stores[0]{name};
      $state = 'last';
      next STATE;

    } else {
      my $found;
      if (my $default = get $q) {
	foreach (@stores) {
	  if ($_->{name} eq $default) {
	    $found = 1; last;
	  }
	}
      }

      unless ($found) {
	# existing default not found, reset and ask again
	fset $q, seen => 'false';
	reset $q;
      }

      subst $q,	stores => join(', ', map($_->{name}, @stores));

      input medium => $q;

      my ($ret) = go;
      if ($ret == 30) { $state = pop @history; next STATE }

      # exit main loop
      $state = 'last';
    }

  } elsif ($state eq 'modify_delete') {

    my $q = 'libapache-sessionx-perl/store_action';

    reset $q;
    subst $q, store => $store->{name};
    input critical => $q;

    my ($ret) = go;
    if ($ret == 30) { $state = pop @history; next STATE }

    my $action = get $q;
    if ($action eq 'Modify') {
      $state = 'modify_store';
    } elsif ($action eq 'Delete') {
      delkey $store->{key};
      @history = ();		# FIXME: can't go back now..
      $state = 'main';
      next STATE;		# avoid pushing current state onto history
    } else {
      require Carp;
      Carp::confess("unknown action: $action");
    }

  } elsif ($state eq 'modify_store') {

    my $type = $store->{type};
    my $key = $store->{key};

    # seed questions for $type
    my @qs = mkquestions($key, {question => sub {
				  fset $_[0], seen => 'false'; # reask
				  input high => $_[0];
				},
				beginblock => \&beginblock,
				endblock => \&endblock,
			       },
			 @{$types{$type}});

    my ($ret) = go;
    if ($ret == 30) { $state = pop @history; next STATE }

    $store->{name} = get "libapache-sessionx-perl/store_${key}_name";

    $state = 'main';

  } elsif ($state eq 'last') {

    # break out of loop
    last STATE;

  } else {

    require Carp;
    Carp::confess("unknown state: $state");

  }

  push @history, $thisstate;
}

sub new_store {
  my ($name, %args) = @_;

  #FIXME: probably better to decide on a case
  foreach (keys %args) {
    my $lc = lc;
    $args{$lc} = $args{$_} if $lc ne $_;
  }

  my $key = newkey;

  my $type = $args{type};
  $args{name} = $name;

  mkquestions $key,
    {question => sub {
       my ($q, $tmpl) = @_;
       register "libapache-sessionx-perl/$tmpl", $q;
       $q =~ m,/store_${key}_(.*)$,;
       set $q, $args{$1};
     },
    },
    (type => 'store_type',
     name => 'store_name',
     @{$types{$type}},
    );

  my $store = $stores[-1];
  $store->{name} = $name;
  $store->{type} = $type;
  $store;
}

sub newkey {
  my $next = @stores ? $stores[-1]{key} + 1 : 1;
  push @stores, {key => $next};
  set 'libapache-sessionx-perl/priv_keys',
    join(',', map($_->{key}, @stores));
  $next;
}

sub delkey {
  my $key = shift;
  for (my $i = 0; $i < @stores; $i++) {
    if ($stores[$i]{key} == $key) {
      # found -> delete
      unregister($_) foreach mkquestions $key;
      splice @stores, $i, 1;
      set 'libapache-sessionx-perl/priv_keys',
	join(',', map($_->{key}, @stores));
      last;
    }
  }
}