Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Tool to copy local configuration files to portal of [DFN-MailSupport](https://portal.mailsupport.dfn.de/)

# Use case

Currently, it’s only possible to edit filter lists via the Web interface the DFN-MailSupport portal. As these are text files, we would like to have these under revision control. To achieve this, the solution here is to copy the file content of the filter lists from the DFN-MailSupport portal to a local directory, and, in our case, git is used as VCS.

# Build

Build with

$ cargo build --release

The binary is placed as `target/release/dfnmscp`.

# Example

`misc` contains the script `validate.pl` and `Makefile` as used in the MPIMG
environment.

Please find `blacklist_client` as an example below.

$ head blacklist_client
# DO NOT EDIT via DFN-MailSupport Portal
#
# maintained in /project/mx/dfn/ as blacklist_client

some.domain.example.net (#c1)
[…]

# Support

Feel free to create an issue or to send an email to helpdesk@.
69 changes: 69 additions & 0 deletions misc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
DFNMSCP=/project/mx/etc/dfn/dfnmscp -u buczek@molgen.mpg.de -c /project/mx/etc/dfn/.dfnpw

.PHONY: default
default: put-if

.PHONY: put-if
put-if: .blacklist_sender.uploaded .spamassassin-rules.uploaded .blacklist_client.uploaded
put-if: .blacklist_header_rx.uploaded
put-if: .blacklist_sender_rx.uploaded
put-if: .blacklist_client_cidr.uploaded
put-if: .blacklist_helo.uploaded

.blacklist_sender.uploaded: blacklist_sender
./validate.pl blacklist_sender
${DFNMSCP} put blacklist_sender postfix/124-1/blacklist_sender && touch $@

.spamassassin-rules.uploaded: spamassassin-rules
${DFNMSCP} put spamassassin-rules spamassassin/124-1/rules && touch $@

.blacklist_client.uploaded: blacklist_client
./validate.pl blacklist_client
${DFNMSCP} put blacklist_client postfix/124-1/blacklist_client && touch $@

.blacklist_header_rx.uploaded: blacklist_header_rx
./validate.pl blacklist_header_rx
${DFNMSCP} put blacklist_header_rx postfix/124-1/blacklist_header_rx && touch $@

.blacklist_sender_rx.uploaded: blacklist_sender_rx
./validate.pl blacklist_sender_rx
${DFNMSCP} put blacklist_sender_rx postfix/124-1/blacklist_sender_rx && touch $@

.blacklist_client_cidr.uploaded: blacklist_client_cidr
./validate.pl blacklist_client_cidr
${DFNMSCP} put blacklist_client_cidr postfix/124-1/blacklist_client_cidr && touch $@

.blacklist_helo.uploaded: blacklist_helo
./validate.pl blacklist_helo
${DFNMSCP} put blacklist_helo postfix/124-1/blacklist_helo && touch $@

test:
${DFNMSCP} test

.PHONY: get-blacklist-sender
get-blacklist-sender:
${DFNMSCP} get postfix/124-1/blacklist_sender blacklist_sender

.PHONY: get-blacklist-sender-rx
get-blacklist-sender-rx:
${DFNMSCP} get postfix/124-1/blacklist_sender_rx blacklist_sender_rx

.PHONY: get-spamassassin-rules
get-spamassassin-rules:
${DFNMSCP} get spamassassin/124-1/rules spamassassin-rules

.PHONY: get-blacklist_client
get-blacklist_client:
${DFNMSCP} get postfix/124-1/blacklist_client blacklist_client

.PHONY: get-blacklist_header_rx
get-blacklist_header_rx:
${DFNMSCP} get postfix/124-1/blacklist_header_rx blacklist_header_rx

.PHONY: get-blacklist_client_cidr
get-blacklist_client_cidr:
${DFNMSCP} get postfix/124-1/blacklist_client_cidr blacklist_client_cidr

.PHONY: get-blacklist_helo
get-blacklist_helo:
${DFNMSCP} get postfix/124-1/blacklist_helo blacklist_helo
63 changes: 63 additions & 0 deletions misc/validate.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#! /usr/bin/perl
use strict;
use warnings;

sub do_blacklist {
my ($filename, $tag, $is_regexp) = @_;
open my $in, '<', $filename or die "$filename: $!\n";
my $errors = 0;
my $last_id = 0;
while (<$in>) {
chomp;
/^#/ and next;
/\S/ or next;
my $re;
if ($is_regexp) {
$re = qr"^/(.+)/ REJECT \(#$tag(\d+)\)$";
} else {
$re = qr"^(\S+) \(#$tag(\d+)\)$";
}
if (my ($inner, $id) = $_ =~ $re) {
if ($is_regexp) {
eval {
my $test = qr/$inner/;
};
if ($@) {
$@ =~ s / at \S+ line .+\n$//;
warn "$filename: $. : $@\n";
$errors++;
}
}
if ($id > $last_id) {
$last_id = $id;
} else {
$errors++;
warn "$filename:$. : ident not increasing: $_\n";
}
next;
}

warn "$filename:$. : bad format: $_\n";
$errors++;
}
exit 1 if $errors;
}


@ARGV == 1 or die "usage: $0 filename\n";
my ($filename) = @ARGV;
if ($filename eq "blacklist_header_rx") {
do_blacklist($filename, 'h', 1)
} elsif ($filename eq 'blacklist_sender_rx') {
do_blacklist($filename, 'sx', 1)
} elsif ($filename eq 'blacklist_sender') {
do_blacklist($filename, 's', 0)
} elsif ($filename eq 'blacklist_client') {
do_blacklist($filename, 'c', 0)
} elsif ($filename eq 'blacklist_client_cidr') {
warn "todo\n";
} elsif ($filename eq 'blacklist_helo') {
do_blacklist($filename, 'he', 0)
} else {
die "unknown filename: $filename\n";
}