App-Regather

 view release on metacpan or  search on metacpan

etc/regather.conf.sample  view on Meta::CPAN

(&\
 (objectClass=radiusObjectProfile)\
 (authorizedService=rad@*)\
)\
)
  scope        = sub
  log_base     = cn=umilog

[service ovpn]
#   uid              = openvpn
#   gid              = openvpn
  chmod            = 0640
  ns_attr     = cn
  ns_keyfile  = /usr/local/etc/regather.d/Kdhcpd.+157+43671.private
  ns_ttl      = 300
  ns_txt_pfx  = REGATHER:
#  ns_zone     = dev.vpn.foo.bar.ua
  out_path         = /tmp/2.kill/regather/out_ovpn
  tt_file          = ovpn.tt
#   out_ext         = .ovpn
  ctrl_attr        = umiOvpnCfgConfig

etc/regather.conf.sample  view on Meta::CPAN

  out_path         = /tmp/2.kill/regather/out_sieve
  tt_file          = sieve.tt
  out_file         = .sieve
  out_file_pfx     = homeDirectory
  ctrl_attr        = mu-sieveOnReceive
  ctrl_srv_re      = ^.*,authorizedService=mail@.*,ou=People,.*$
  plugin           = configfile

[service sieve map s]
  createdon         = createTimestamp
  gidNumber	    = gidNumber
  homeDirectory     = homeDirectory
  modifiedon        = modifyTimestamp
  mu_mailBox        = mu-mailBox
  mu_sieveOnReceive = mu-sieveOnReceive
  uid               = uid
  uidNumber	    = uidNumber

[service crl-ovpn]
  chmod            = 0644
  out_path         = /tmp/2.kill/regather/out_crl

lib/App/Regather.pm  view on Meta::CPAN

  $SIG{INT} = $SIG{QUIT} = $SIG{ABRT} = $SIG{TERM} =
    sub { my $sig = @_;
	  $self->l->cc( pr => 'warning', fm => "%s:%s:  SIG %s received, exiting", ls => [ __FILE__,__LINE__, $sig ] );
	  $self->{_opt}{last_forever} = 0;
	};
  $SIG{PIPE} = 'ignore';
  $SIG{USR1} =
    sub { my $sig = @_;
	  $self->l->cc( pr => 'warning', fm => "%s:%s: SIG %s received, doing nothing" ), ls => [ __FILE__,__LINE__, $sig ] };

  if ( $self->cf->is_set(qw(core uid)) && $self->cf->is_set(qw(core gid)) ) {
    setgid ( $self->cf->get(qw(core gid_number)) ) || do { print "setgid went wrong: $!\n\n"; exit 1; };
    setuid ( $self->cf->get(qw(core uid_number)) ) || do { print "setuid went wrong: $!\n\n"; exit 1; };
  }

  $self->l->cc( pr => 'info', fm => "%s:%s: %s v.%s is started.", ls => [ __FILE__,__LINE__, $self->progname, $VERSION ] );
}

sub ldap_search_callback {
  my ( $self, $msg, $obj ) = @_;


lib/App/Regather/Config.pm  view on Meta::CPAN

	    ! $self->is_set( 'ldap', $section, $item );
	}
      }
      last;
    }
  }
}

=item mangle

modify the created source tree. (resolve I<uid/gid> symbolic to number, add I<altroot>)

=cut

sub mangle {
  my $self = shift;
  my ( $section, $item, $k, $v );

  my $re_mod = qr(^Can.t locate.*);

  if ( $self->is_set(qw(core uid)) ) {

lib/App/Regather/Config.pm  view on Meta::CPAN

      $self->{logger}->cc( pr => 'info', fm => "%s: setuid user %s(%s) confirmed",
			   ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->get(qw(core uid)), $item ] )
	if $self->{verbose} > 1;
      $self->set('core', 'uid_number', $item);
    } else {
      print "No user $self->get('uid') found\n\n";
      exit 2;
    }
  }

  if ( $self->is_set(qw(core gid)) ) {
    $item = getgrnam( $self->get(qw(core gid)) );
    if ( defined $item ) {
      $self->{logger}->cc( pr => 'info', fm => "%s: setgid group %s(%s) confirmed",
			   ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->get(qw(core gid)), $item ] )
	if $self->{verbose} > 1;
      $self->set('core', 'gid_number', $item);
    } else {
      print "No group $self->get('gid') found\n\n";
      exit 2;
    }
  }

  foreach my $svc ( $self->names_of('service') ) {
    if ( $self->is_set(qw($svc uid)) ) {
      $item = getpwnam( $self->get(qw($svc uid)) );
      if ( defined $item ) {
	$self->{logger}->cc( pr => 'info', fm => "%s: setuid user %s(%s) confirmed",
			     ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->get(qw($svc uid)), $item ] )
	  if $self->{verbose} > 1;
	$self->set($svc, 'uid_number', $item);
      } else {
	print "No user $self->get('uid') found\n\n";
	exit 2;
      }
    }

    if ( $self->is_set($svc, 'gid') ) {
      $item = getgrnam( $self->get($svc, 'gid') );
      if ( defined $item ) {
	$self->{logger}->cc( pr => 'info', fm => "%s: setgid group %s(%s) confirmed",
			     ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->get(qw($svc gid)), $item ] )
	  if $self->{verbose} > 1;
	$self->set($svc, 'gid_number', $item);
      } else {
	print "No group $self->get('gid') found\n\n";
	exit 2;
      }
    }

    if ( $self->is_set('service', $svc, 'plugin') ) {
      foreach my $plg ( $self->get('service', $svc, 'plugin') ) {

	if ( $plg eq 'nsupdate' ) {
	  eval { require Net::DNS };
	  if ( $@ =~ /$re_mod/ ) {

lib/App/Regather/Config.pm  view on Meta::CPAN



1;


__DATA__

[core]
altroot      = STRING :re="^/tmp/.*" :check=chk_dir
dryrun       = NUMBER :default 0
gid          = STRING
notify       = NUMBER :default 0
notify_email = STRING :mandatory :array :check=chk_notify_email
pid_file     = STRING :check=chk_dir_pid :default /var/run/openldap/regather.pid
tt_debug     = NUMBER :default 0
tt_path      = STRING :check=chk_dir :default /usr/local/etc/regather.d
tt_trim      = NUMBER :default 0
uid          = STRING

[log]
facility     = STRING :default local4

lib/App/Regather/Config.pm  view on Meta::CPAN

ssl          = STRING
sslversion   = STRING
verify       = STRING

[service ANY]
all_attr     = NUMBER :default 0
chmod        = OCTAL  :default 0640
chown	     = NUMBER :default 1
ctrl_attr    = STRING :mandatory :array
ctrl_srv_re  = STRING :mandatory
gid          = STRING
out_ext      = STRING
out_file     = STRING
out_file_pfx = STRING
out_path     = STRING :check=chk_dir
tt_file      = STRING :check=chk_file_tt
uid          = STRING
ns_attr      = STRING
ns_keyfile   = STRING
ns_ttl       = NUMBER :default 600
ns_txt_pfx   = STRING :default REGATHER:

lib/App/Regather/Plugin/configfile.pm  view on Meta::CPAN

      $self->log->cc( pr => 'err', fm => "%s: DRYRUN: chmod %s, %s",
		ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->cf->get('service', $self->service, 'chmod'), $out_to ] );
    } elsif ( $self->cf->is_set(qw(core chmod)) ) {
      $self->log->cc( pr => 'err', fm => "%s: DRYRUN: chmod %s, %s",
		ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->cf->get('core', 'chmod'), $out_to ] );
    }

    if ( $self->cf->is_set($self->service, 'chown') ) {
      $self->log->cc( pr => 'err', fm => "%s: DRYRUN: chown %s, %s, %s",
		ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->obj->get_value('uidNumber'),
			$self->obj->get_value('gidNumber'),
			$out_to ] );
    }
    return;
  }

  my ( $tmp_fh, $tmp_fn );
  eval { $tmp_fh = File::Temp->new( UNLINK => 0, DIR => $dir ); };
  if ( $@ ) {
    $self->log->cc( pr => 'err', fm => "%s: File::Temp->new( DIR => %s ); service \"%s\"; err: \"%s\"",
	      ls => [ sprintf("%s:%s",__FILE__,__LINE__), $dir, $self->service, $@ ] );

lib/App/Regather/Plugin/configfile.pm  view on Meta::CPAN

	  $self->log->cc( pr => 'err', fm => "%s: chmod for %s failed",
		    ls => [ sprintf("%s:%s",__FILE__,__LINE__), $out_to ] );
      } elsif ( $self->cf->is_set(qw(core chmod)) ) {
	chmod oct($self->cf->(qw(core chmod))), $out_to ||
	  $self->log->cc( pr => 'err', fm => "%s: chmod for %s failed",
		    ls => [ sprintf("%s:%s",__FILE__,__LINE__), $out_to ] );
      }

      if ( $self->cf->is_set('service', $self->service, 'chown') ) {
	chown $self->obj->get_value('uidNumber'),
	  $self->obj->get_value('gidNumber'),
	  $out_to ||
	  $self->log->cc( pr => 'err', fm => "%s: chown (%s:%s) %s failed",
		    ls => [ sprintf("%s:%s",__FILE__,__LINE__), $self->obj->get_value('uidNumber'),
			    $self->obj->get_value('gidNumber'),
			    $out_to ] );
      }
    } else {
      $self->log->cc( pr => 'err', fm => "%s: %s disappeared, no such file any more...",
		ls => [ sprintf("%s:%s",__FILE__,__LINE__), $out_to ] );
    }
  }
  $self->log->cc( pr => 'debug', fm => "%s: control %s: dn: %s processed successfully.",
		  ls => [ sprintf("%s:%s",__FILE__,__LINE__), SYNST->[$self->syncstate], $self->obj->dn ] )
    if $self->{v} > 0;



( run in 0.627 second using v1.01-cache-2.11-cpan-ceb78f64989 )