Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 424d6ead

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 424d6eadbe8a0c863a4f6a4ea5e60a86a309de50
  • Vorgänger af281b3c
  • Nachfolger 5aaa3c62

In Konfiguration angegebene Anwendungen in PATH suchen

Fix für Bug 1690.

Unterschiede anzeigen:

SL/Dispatcher.pm
81 81
  my ($self) = @_;
82 82

  
83 83
  SL::LxOfficeConf->read;
84
  _init_environment();
85 84

  
86 85
  eval {
87 86
    package main;
......
370 369
  return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR);
371 370
}
372 371

  
373
sub _init_environment {
374
  my %key_map = ( lib  => { name => 'PERL5LIB', append_path => 1 },
375
                  path => { name => 'PATH',     append_path => 1 },
376
                );
377
  my $cfg     = $::lx_office_conf{environment} || {};
378

  
379
  while (my ($key, $value) = each %{ $cfg }) {
380
    next unless $value;
381

  
382
    my $info = $key_map{$key} || {};
383
    $key     = $info->{name}  || $key;
384

  
385
    if ($info->{append_path}) {
386
      $value = ':' . $value unless $value =~ m/^:/ || !$ENV{$key};
387
      $value = $ENV{$key} . $value;
388
    }
389

  
390
    $ENV{$key} = $value;
391
  }
392
}
393

  
394 372
sub _check_for_old_config_files {
395 373
  my @old_files = grep { -f "config/${_}" } qw(authentication.pl console.conf lx-erp.conf lx-erp-local.conf);
396 374
  return unless @old_files;
SL/LxOfficeConf.pm
5 5
use Config::Std;
6 6
use Encode;
7 7

  
8
my $environment_initialized;
9

  
8 10
sub read {
9 11
  my ($class, $file_name) = @_;
10 12

  
......
18 20
    _decode_recursively(\%local_conf);
19 21
    _flat_merge(\%::lx_office_conf, \%local_conf);
20 22
  }
23

  
24
  _init_environment();
25
  _determine_application_paths();
21 26
}
22 27

  
23 28
sub _decode_recursively {
......
45 50
  }
46 51
}
47 52

  
53
sub _init_environment {
54
  return if $environment_initialized;
55

  
56
  my %key_map = ( lib  => { name => 'PERL5LIB', append_path => 1 },
57
                  path => { name => 'PATH',     append_path => 1 },
58
                );
59
  my $cfg     = $::lx_office_conf{environment} || {};
60

  
61
  while (my ($key, $value) = each %{ $cfg }) {
62
    next unless $value;
63

  
64
    my $info = $key_map{$key} || {};
65
    $key     = $info->{name}  || $key;
66

  
67
    if ($info->{append_path}) {
68
      $value = ':' . $value unless $value =~ m/^:/ || !$ENV{$key};
69
      $value = $ENV{$key} . $value;
70
    }
71

  
72
    $ENV{$key} = $value;
73
  }
74

  
75
  $environment_initialized = 1;
76
}
77

  
78
sub _determine_application_paths {
79
  my @paths = grep { $_ } split m/:/, $ENV{PATH};
80

  
81
  foreach my $key (keys %{ $::lx_office_conf{applications} }) {
82
    my ($program) = split m/\s+/, $::lx_office_conf{applications}->{$key};
83
    next if $program =~ m|/|;
84

  
85
    foreach my $path (@paths) {
86
      next unless -f "${path}/${program}";
87
      $::lx_office_conf{applications}->{$key} = "${path}/" . $::lx_office_conf{applications}->{$key};
88
      last;
89
    }
90
  }
91
}
92

  
48 93
1;

Auch abrufbar als: Unified diff