aboutsummaryrefslogtreecommitdiffstats
path: root/fripost-searchalias
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-06-03 22:20:58 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-06-03 22:20:58 +0200
commita3684346f4d60715512c7ca30ba9fc7bb270c38e (patch)
treeb6c4d3a5223faf5801f5e5e7860110fca5efa521 /fripost-searchalias
parent0461d89edb3f8e272697726208ab7747c30a81df (diff)
Merge everything into a single executable.
Diffstat (limited to 'fripost-searchalias')
-rwxr-xr-xfripost-searchalias176
1 files changed, 0 insertions, 176 deletions
diff --git a/fripost-searchalias b/fripost-searchalias
deleted file mode 100755
index 4c4bb9f..0000000
--- a/fripost-searchalias
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/perl
-
-use 5.010_000;
-use strict;
-use warnings;
-use utf8;
-
-=head1 NAME
-
-fripost-searchalias - List matching aliases
-
-=head1 SYNOPSIS
-
-B<fripost-searchalias> [B<--debug>] [B<-f|--from>] [B<-g|--goto>] [address]
-
-B<fripost-searchalias> [B<--man>]
-
-=head1 DESCRIPTION
-
-B<fripost-seardomain> list virtual aliases matching exactly I<from>,
-targetting to I<goto>.
-If no I<from> is given, list all aliases whose target matches I<goto>.
-If neither I<goto> nor I<from> are given, B<fripost-searchalias> list
-all existing virtual aliases.
-
-=head1 OPTIONS
-
-=over 8
-
-=item B<--server_host=>I<host>
-
-The LDAP URI to connect to.
-The default value is read from the configuration file, see B<CONFIGURATION>.
-
-=item B<--bind_dn=>I<binddn>
-
-The Distinguished Name (DN) to bind to the LDAP directory.
-(If not set, B<fripost-searchalias> binds anonymously.)
-The default value is read from the configuration file, see B<CONFIGURATION>.
-
-=item B<--bind_pw=>I<password>
-
-The password to to bind with.
-The default value is read from the configuration file, see B<CONFIGURATION>.
-
-=item B<--base_dn=>I<basedn>
-
-The root DN for everything done by B<fripost-searchalias>.
-The default value is read from the configuration file, see B<CONFIGURATION>.
-
-=item B<-d>, B<--debug>
-
-Debug mode.
-
-=item B<-f>, B<--from>
-
-Match on 'from' addresses.
-The default is to match both the 'from' and 'goto' address.
-
-=item B<-g>, B<--goto>
-
-Match on 'goto' addresses.
-The default is to match both the 'from' and 'goto' address.
-
-=back
-
-=head1 CONFIGURATION
-
-The configuration is read from the file C<$HOME/.fripost.yml>.
-Valid keys include:
-
-=over 4
-
-=item I<server_host>
-
-The LDAP URI to connect to. Defaults to C<ldap://127.0.0.1:389>.
-
-=item I<bind_dn>
-
-The Distinguished Name (DN) to bind to the LDAP directory.
-(If not set, B<fripost-searchalias> binds anonymously.)
-
-=item I<bind_pw>
-
-The password to to bind with.
-
-=item I<base_dn>
-
-The root DN for everything done by B<fripost-searchalias>.
-
-=back
-
-=cut
-
-use FindBin qw($Bin);
-use lib "$Bin/lib";
-
-use Env qw /HOME/;
-use File::Spec::Functions;
-
-use Fripost::Schema;
-use Getopt::Long qw /:config noauto_abbrev no_ignore_case
- gnu_compat bundling permute nogetopt_compat
- auto_version auto_help/;
-use Pod::Usage;
-use YAML::Syck;
-
-
-## Get command line options
-our $conf = LoadFile( catfile ($HOME, '.fripost.yml') );
-
-GetOptions(
- 'server_host=s' => \$conf->{server_host},
- 'base_dn=s' => \$conf->{base_dn},
- 'bind_dn=s' => \$conf->{bind_dn},
- 'bind_pw=s' => \$conf->{bind_pw},
- 'debug|d' => \$conf->{debug},
- 'from|f' => \$conf->{from},
- 'goto|g' => \$conf->{goto},
- 'man' => sub { pod2usage(-exitstatus => 0,
- -verbose => 2) }
-) or pod2usage(2);
-
-
-# Connect to the LDAP server
-my $ldap = Fripost::Schema->new( $conf );
-
-sub perform_search {
- my %alias = @_;
-
- foreach my $alias ($ldap->alias->search( \%alias )->entries) {
- say "" . ($alias->{isActive} ? "ACTIVE" : "INACTIVE")
- . " alias for " . $alias->{goto} . " are "
- . (join ', ', @{$alias->{address}});
- }
-}
-
-my $search = $ARGV[0];
-
-my $f = $conf->{from};
-my $g = $conf->{goto};
-my $from = $f || !$f && !$g;
-my $goto = $g || !$f && !$g;
-
-if ($from) {
- perform_search(address => $search);
-
- my ($u,$d) = split /\@/, $search, 2;
- $d = $u if (defined $u) and not (defined $d);
- $ldap->domain->search({ domain => $d })->count
- or die "Error: Unknown domain `$d'.\n";
-}
-
-if ($goto) {
- perform_search(goto => $search);
-}
-
-$ldap->unbind();
-
-
-=head1 AUTHOR
-
-Guilhem Moulin C<< <guilhem at fripost.org> >>
-
-=head1 COPYRIGHT
-
-Copyright 2012 Guilhem Moulin.
-
-Copyright 2012 Stefan Kangas <skangas@skangas.se>.
-
-=head1 LICENSE
-
-This program is free software; you can redistribute it and/or modify it
-under the same terms as perl itself.
-
-=cut