Changeset 11237

Show
Ignore:
Timestamp:
08/19/08 14:54:47 (5 months ago)
Author:
/C=ES/O=Warp Networks S.L./CN=ejhernandez@…
Message:

SOAP location configuration is done refs #1103

Location:
branches/remote-services/ebox
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • branches/remote-services/ebox/debian/dirs

    r10308 r11237  
    11var/lib/ebox/ 
    22var/lib/ebox/conf 
     3var/lib/ebox/conf/remoteservices 
    34var/lib/ebox/tmp 
    45var/lib/ebox/log 
  • branches/remote-services/ebox/src/EBox/RemoteServices.pm

    r10813 r11237  
    2828use warnings; 
    2929 
     30use Error qw(:try); 
     31 
    3032# eBox uses 
     33use EBox::Config; 
     34use EBox::Exceptions::Internal; 
    3135use EBox::Gettext; 
     36use EBox::Global; 
     37use EBox::Sudo; 
     38 
     39# Constants 
     40use constant SERV_DIR      => EBox::Config::conf() . 'remoteservices/'; 
     41use constant CA_DIR        => SERV_DIR . 'ssl-ca/'; 
     42use constant SUBS_DIR      => SERV_DIR . 'subscription/'; 
     43use constant WS_DISPATCHER => __PACKAGE__ . '::WSDispatcher'; 
    3244 
    3345# Group: Protected methods 
     
    7587# Method: _regenConfig 
    7688# 
    77 #        Regenerate the configuration for the events 
     89#        Regenerate the configuration for the remote services module 
    7890# 
    7991# Overrides: 
     
    8193#       <EBox::Module::_regenConfig> 
    8294# 
    83 # Exceptions: 
    84 # 
    85 #       <EBox::Exceptions::External> - if no event watcher and event 
    86 #       dispatcher are enabled 
    87 # 
    8895sub _regenConfig 
    8996{ 
     
    9198      my ($self) = @_; 
    9299 
     100      $self->_confSOAPService(); 
     101 
    93102      return; 
    94103} 
     
    103112sub _stopService 
    104113{ 
    105  
    106114 
    107115} 
     
    204212} 
    205213 
     214# Group: Private methods 
     215 
     216# Configure the SOAP server 
     217# 
     218# if subscribed 
     219# 1. Write soap-loc.mas template 
     220# 2. Write the SSLCACertificatePath directory 
     221# 3. Add include in ebox-apache configuration 
     222# else 
     223# 1. Remove SSLCACertificatePath directory 
     224# 2. Remove include in ebox-apache configuration 
     225# 
     226sub _confSOAPService 
     227{ 
     228    my ($self) = @_; 
     229 
     230    my $confFile = SERV_DIR . 'soap-loc.conf'; 
     231    my $apacheMod = EBox::Global->modInstance('apache'); 
     232    if ($self->eBoxSubscribed()) { 
     233        my @tmplParams = ( 
     234            (soapHandler   => WS_DISPATCHER), 
     235            (domainName    => $self->_confKeys()->{domain}), 
     236            (allowedPrefix => $self->_allowedPrefix()), 
     237            (caPath        => CA_DIR)); 
     238        $self->writeConfFile( $confFile, 'remoteservices/soap-loc.mas', 
     239                              \@tmplParams); 
     240        unless ( -d CA_DIR ) { 
     241            mkdir(CA_DIR); 
     242        } 
     243        my $caLinkPath = $self->_caLinkPath(); 
     244        unless ( -l $caLinkPath ) { 
     245            symlink($self->_caCertPath(), $caLinkPath ); 
     246        } 
     247        $apacheMod->addInclude($confFile); 
     248    } else { 
     249        unlink($confFile); 
     250        # Remove CA_DIR 
     251        opendir(my $dir, CA_DIR); 
     252        while(my $file = readdir($dir)) { 
     253            # Check if it is a symbolic link file to remove it 
     254            next unless (-l CA_DIR . $file); 
     255            unlink(CA_DIR . $file); 
     256        } 
     257        closedir($dir); 
     258        try { 
     259            $apacheMod->removeInclude($confFile); 
     260        } catch EBox::Exceptions::Internal with { 
     261            # Do nothing if it's already remove 
     262            ; 
     263        }; 
     264    } 
     265    $apacheMod->save(); 
     266 
     267} 
     268 
     269# Return the allowed prefix to send jobs 
     270sub _allowedPrefix 
     271{ 
     272    my ($self) = @_; 
     273 
     274    my $mmProxy = $self->_confKeys()->{managementProxy}; 
     275    # Return only the prefix 
     276    my ($prefix) = $mmProxy =~ m:^(.*?)[0-9]*\.:; 
     277    return $prefix; 
     278} 
     279 
     280# Return the given configuration file from the control center 
     281sub _confKeys 
     282{ 
     283    my ($self) = @_; 
     284 
     285    unless ( defined($self->{confFile}) ) { 
     286        my $confDir = SUBS_DIR . $self->eBoxCommonName(); 
     287        $self->{confFile} = (<$confDir/*.conf>)[0]; 
     288    } 
     289    unless ( defined($self->{confKeys}) ) { 
     290        $self->{confKeys} = EBox::Config::configKeysFromFile($self->{confFile}); 
     291    } 
     292    return $self->{confKeys}; 
     293} 
     294 
     295# Return the CA cert path 
     296sub _caCertPath 
     297{ 
     298    my ($self) = @_; 
     299 
     300    return SUBS_DIR . $self->eBoxCommonName() . '/cacert.pem'; 
     301 
     302} 
     303 
     304# Return the link name for the CA certificate in the given format 
     305# hashValue.0 - hash value is the output from openssl ciphering 
     306sub _caLinkPath 
     307{ 
     308    my ($self) = @_; 
     309 
     310    my $caCertPath = $self->_caCertPath(); 
     311    my $hashRet = EBox::Sudo::command("openssl x509 -hash -noout -in $caCertPath"); 
     312 
     313    my $hashValue = $hashRet->[0]; 
     314    chomp($hashValue); 
     315    return CA_DIR . "${hashValue}.0"; 
     316 
     317} 
     318 
    2063191; 
  • branches/remote-services/ebox/src/EBox/RemoteServices/Auth.pm

    r11098 r11237  
    3636 
    3737# Constants 
    38 use constant SERV_SUBDIR => 'remote-services'; 
     38use constant SERV_SUBDIR => 'remoteservices/subscription'; 
    3939 
    4040# Group: Public methods 
  • branches/remote-services/ebox/src/EBox/RemoteServices/Makefile.am

    r11199 r11237  
    44 
    55mods = Alerts.pm Auth.pm Base.pm Backup.pm ProxyBackup.pm SOAPClient.pm \ 
    6         Subscription.pm 
     6        Subscription.pm WSDispatcher.pm 
    77 
    88nobase_perl_DATA = $(mods) 
  • branches/remote-services/ebox/src/EBox/RemoteServices/Model/Subscription.pm

    r11141 r11237  
    152152    $self->SUPER::setTypedRow($id, $paramsRef, %optParams); 
    153153 
     154    # Mark RemoteServices module as changed 
     155    $self->{gconfmodule}->setAsChanged(); 
     156 
    154157    $self->{gconfmodule}->st_set_bool('subscribed', not $subs); 
    155158 
  • branches/remote-services/ebox/src/EBox/RemoteServices/Server/JobReceiver.pm

    r11232 r11237  
    3636use File::Slurp; 
    3737 
    38 use constant JOBS_DIR     => EBox::Config::conf() . 'remote-services/jobs/'; 
     38use constant JOBS_DIR     => EBox::Config::conf() . 'remoteservices/jobs/'; 
    3939use constant INCOMING_DIR => JOBS_DIR . 'incoming/'; 
    4040 
  • branches/remote-services/ebox/src/EBox/RemoteServices/Server/t/jobReceiver.t

    r11233 r11237  
    4747                  script => qq{#!/bin/bash\necho "\$@"}, 
    4848                  arguments => $args); 
    49 my $jobDirPath = EBox::Config::conf() . "remote-services/jobs/$jobId/"; 
     49my $jobDirPath = EBox::Config::conf() . "remoteservices/jobs/$jobId/"; 
    5050my $cmd = new Test::Cmd( 
    5151    prog => "${jobDirPath}script", 
  • branches/remote-services/ebox/src/EBox/RemoteServices/Subscription.pm

    r10813 r11237  
    4040# Constants 
    4141use constant { 
    42     SERV_SUBDIR => 'remote-services', 
     42    SERV_SUBDIR => 'remoteservices/subscription', 
    4343    SERV_CONF_FILE => '78remoteservices.conf', 
    4444}; 
  • branches/remote-services/ebox/src/EBox/RemoteServices/WSDispatcher.pm

    r11199 r11237  
    3030 
    3131my $server = SOAP::Transport::HTTP::Apache 
    32   -> dispatch_to('EBox::RemoteServices::Server::JobReceiver::runJob'); 
     32  ->dispatch_with( 
     33      { 'urn:EBox/Services/Jobs' => 'EBox::RemoteServices::Server::JobReceiver' } 
     34     ); 
    3335 
    3436# Method: handler 
  • branches/remote-services/ebox/src/libexec/ebox-runnerd

    r11233 r11237  
    77use POSIX qw(SIG_IGN SIGHUP); 
    88 
    9 use constant JOBS_DIR      => EBox::Config::conf() . 'remote-services/jobs/'; 
     9use constant JOBS_DIR      => EBox::Config::conf() . 'remoteservices/jobs/'; 
    1010use constant INCOMING_DIR  => JOBS_DIR . 'incoming/'; 
    1111use constant OUTCOMING_DIR => JOBS_DIR . 'outcoming/';