NAME

MasterCFParser

PREFACE

This package provides an objectoriented interface to read/write the postfix superserver configuration file master.cf.

SYNOPSIS

  use MasterCFParser;

  my $msc = new MasterCFParser();
  $msc->readMasterCF();

  if( $msc->addService( { 'service' => 'smtps',
                          'type'    => 'inet',
                          'private' => 'n',
                          'unpriv'  => '-',
                          'chroot'  => 'n',
                          'wakeup'  => '-',
                          'maxproc' => '-',
                          'command' => 'smtpd',
                          'options' => { 'smtpd_tls_wrappermode' => 'yes',
                                         'smtpd_sasl_auth_enable' => 'yes' }
                    }
                      ) ) {
    print "ERROR in addService()\n";
  }

  my $srvs = $msc->getServiceByAttributes( { 'command' => 'pipe',
                                             'maxproc' => '10' } );
  if( ! defined $srvs ) {
    print "ERROR in getServiceByAttributes()\n";
  }

  if( $msc->modifyService( { 'service' => 'cyrus1',
                             'command' => 'pipe',
                             'type'    => 'unix' } ) ) {
    print "ERROR in modifyService()\n";
  }

DESCRIPTION

Each commented line of master.cf is internally presented as an hash containing only one key/value pair, that is

  comment => "# a commented line"

Every other lines are represented as hash which MUST have the keys

  service,type,private,unpriv,chroot,wakeup,maxproc,command

and if present a key 'options'.

'options' can be either a scalar or a hash reference. A scalar for all so called interfaces to non-Postfix software using the 'pipe' command. For all other postfix commands, options must be a hash reference.

METHODS