From mike.gabriel@das-netzwerkteam.de  Sat Feb 20 09:52:03 2016
Received: (at 751) by bugs.x2go.org; 20 Feb 2016 08:52:06 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,URIBL_BLOCKED
	autolearn=ham version=3.3.2
Received: from localhost (localhost [127.0.0.1])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTP id 7D28B5DA94
	for <751@bugs.x2go.org>; Sat, 20 Feb 2016 09:52:03 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at ymir.das-netzwerkteam.de
Received: from ymir.das-netzwerkteam.de ([127.0.0.1])
	by localhost (ymir.das-netzwerkteam.de [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id yMROqem6WpjZ for <751@bugs.x2go.org>;
	Sat, 20 Feb 2016 09:51:57 +0100 (CET)
Received: from freya.das-netzwerkteam.de (freya.das-netzwerkteam.de [88.198.48.199])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id 487ED5DA95
	for <751@bugs.x2go.org>; Sat, 20 Feb 2016 09:51:57 +0100 (CET)
Received: from grimnir.das-netzwerkteam.de (grimnir.das-netzwerkteam.de [78.46.204.98])
	by freya.das-netzwerkteam.de (Postfix) with ESMTPS id D6826152C
	for <751@bugs.x2go.org>; Sat, 20 Feb 2016 09:51:56 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTP id 1C2943BB3C;
	Sat, 20 Feb 2016 09:51:56 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at grimnir.das-netzwerkteam.de
Received: from grimnir.das-netzwerkteam.de ([127.0.0.1])
	by localhost (grimnir.das-netzwerkteam.de [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7LrCV6pP6SVE; Sat, 20 Feb 2016 09:51:50 +0100 (CET)
Received: from das-netzwerkteam.de (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTPS id C467E3B966;
	Sat, 20 Feb 2016 09:51:49 +0100 (CET)
Received: from p5B3BAB0E.dip0.t-ipconnect.de (p5B3BAB0E.dip0.t-ipconnect.de
 [91.59.171.14]) by mail.das-netzwerkteam.de (Horde Framework) with HTTP;
 Sat, 20 Feb 2016 08:51:49 +0000
Date: Sat, 20 Feb 2016 08:51:49 +0000
Message-ID: <20160220085149.Horde.-X7RqXp8EN02AeSqtXVik9A@mail.das-netzwerkteam.de>
From: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
To: 751@bugs.x2go.org
Cc: x2go-project@lists.x2go.org
Subject: new DebBugs scripts: mbox / cleanbug
User-Agent: Horde Application Framework 5
Accept-Language: de,en
Organization: DAS-NETZWERKTEAM
X-Originating-IP: 91.59.171.14
X-Remote-Browser: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Firefox/38.0 Iceweasel/38.5.0
Content-Type: multipart/signed; boundary="=_0os05MFYWClYzphydJOWfb7";
 protocol="application/pgp-signature"; micalg=pgp-sha256
MIME-Version: 1.0

This message is in MIME format and has been PGP signed.

--=_0os05MFYWClYzphydJOWfb7
Content-Type: multipart/mixed; boundary="=_1y9qSnMlIElqjnyW1FN_3nD"

This message is in MIME format.

--=_1y9qSnMlIElqjnyW1FN_3nD
Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Hi all,

last night, I created to new scripts for the debbugs software=20=20
underneath=20bugs.x2go.org.

Both scripts are attached and can be found under /usr/lib/debbugs on=20=20
host=20ymir.das-netzwerkteam.de.

Especially the cleanbug script should be of interested here.

I recently received various abuse notifications from my provider and=20=20
they=20all relate to X2GO bugs containing mails with virus attachments.=20=
=20
These=20need to be cleaned.

I already did so for the reported URLs:

http://bugs.x2go.org/128
http://bugs.x2go.org/232
http://bugs.x2go.org/496
http://bugs.x2go.org/765

But there are more...

Please coordinate in the X2Go core team, who will work on cleaning up=20=20
the=20X2Go bugtracker. Currently, these people have access:


   Heinz
   Mihai
   Mike


You have to log into ymir.das-netzwerkteam.de (aka bugs.x2go.org) as=20=20
user=20locadm and become root via sudo.

The cleanbug script itself is easy to handle:

   # /usr/lib/debbugs/cleanbug <bugno>

Once you triggered the script, you have to look at bug posts on the=20=20
selected=20bug and say yes and no.

At the end you get asked, if you really want to write back the changes=20=
=20
to=20the bug. The answer's question defaults to "no".

You should create some back before manipulating existing bugs. For=20=20
this,=20create copies of <bugno>.log in /var/lib/debbugs/spool/db-h/

Note for archived bugs: for cleaning up archived bugs, you have to=20=20
unarchive=20them first.

Mike


--=20

DAS-NETZWERKTEAM
mike=20gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: mike.gabriel@das-netzwerkteam.de, http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/mailxchange/kronolith/fb.php?u=3Dm.gabriel=
%40das-netzwerkteam.de

--=_1y9qSnMlIElqjnyW1FN_3nD
Content-Type: text/plain; name=cleanbug
Content-Disposition: attachment; size=2497; filename=cleanbug
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/perl

use warnings;
use strict;

use POSIX qw(strftime);

use Debbugs::Config qw(:globals :text);

# for read_log_records
use Debbugs::Log qw(read_log_records write_log_records);
use Debbugs::Common qw(buglog bug_status);
use Debbugs::Status qw( split_status_fields get_bug_status);

use List::Util qw(max);

sub prompt {
	my ($query) =3D @_; # take a prompt string as argument
	local $| =3D 1; # activate autoflush to immediately show the prompt
	print $query;
	chomp(my $answer =3D <STDIN>);
	return $answer;
}

sub prompt_yesno {
	my ($query) =3D @_;
	my $answer =3D prompt("$query (Y/n): ");
	return (lc($answer) ne 'n');
}

sub prompt_noyes {
	my ($query) =3D @_;
	my $answer =3D prompt("$query (N/y): ");
	return (lc($answer) eq 'y');
}

my $ref =3D shift or die;

my %bugusertags;

my $buglog =3D buglog($ref);
my $bug_status =3D bug_status($ref);

my $buglogfh;
my $cleanedbuglogfh;
if ($buglog =3D~ m/\.gz$/) {
    my $oldpath =3D $ENV{'PATH'};
    $ENV{'PATH'} =3D '/bin:/usr/bin';
    $buglogfh =3D IO::File->new("zcat $buglog |") or die("open log for $ref=
: $!");
    $ENV{'PATH'} =3D $oldpath;
} else {
    $buglogfh =3D IO::File->new($buglog,'r') or die("open log for $ref: $!"=
);
}

my %status =3D
    %{split_status_fields(get_bug_status(bug=3D>$ref,
                                         bugusertags =3D> \%bugusertags,
                                        ))};

my @records;
eval{
     @records =3D read_log_records($buglogfh);
};
my @cleaned_records =3D ();

binmode(STDOUT,":raw");
my $date =3D strftime "%a %b %d %T %Y", localtime;

my $message_number=3D0;

for my $record (@records) {
	my ($msg_id) =3D $record->{text} =3D~ /^Message-Id:\s+<(.+)>/im;
	my @lines =3D split( "\n", $record->{text}, -1 );
	if ( $lines[ 1 ] =3D~ m/^From / ) {
		my $tmp =3D $lines[ 0 ];
		$lines[ 0 ] =3D $lines[ 1 ];
		$lines[ 1 ] =3D $tmp;
	}
	if ( !( $lines[ 0 ] =3D~ m/^From / ) ) {
		unshift @lines, "From unknown $date";
	}
	map { s/^(>*From )/>$1/ } @lines[ 1 .. $#lines ];
	print join( "\n", @lines ) . "\n";

	if ( prompt_yesno("Keep this message in the bug report") ) {
		print "ANSWER WAS: YES\n\n";
		push @cleaned_records, $record;
	} else {
		print "\nANSWER WAS: NO\n\n";
	}
}

$buglogfh->close();

if ( prompt_noyes("Really write back the bug log of bug $ref") ) {
	print "\nANSWER WAS: YES\n\n";
	$cleanedbuglogfh =3D IO::File->new($buglog,'w') or die("open log for $ref:=
 $!");
	write_log_records(logfh =3D> $cleanedbuglogfh,
	                  records =3D> \@cleaned_records,
	);
} else {
	print "\nANSWER WAS: NO\n\n";
}

exit 0;

--=_1y9qSnMlIElqjnyW1FN_3nD
Content-Type: text/plain; name=mbox
Content-Disposition: attachment; size=2094; filename=mbox
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/perl

use warnings;
use strict;

use POSIX qw(strftime);

use Debbugs::Config qw(:globals :text);

# for read_log_records
use Debbugs::Log qw(read_log_records);
use Debbugs::Common qw(buglog bug_status);
use Debbugs::Status qw( split_status_fields get_bug_status);
use Debbugs::MIME qw(create_mime_message);

use List::Util qw(max);

my $ref =3D shift or die;


my %bugusertags;

my $buglog =3D buglog($ref);
my $bug_status =3D bug_status($ref);

my $buglogfh;
if ($buglog =3D~ m/\.gz$/) {
    my $oldpath =3D $ENV{'PATH'};
    $ENV{'PATH'} =3D '/bin:/usr/bin';
    $buglogfh =3D IO::File->new("zcat $buglog |") or die("open log for $ref=
: $!");
    $ENV{'PATH'} =3D $oldpath;
} else {
    $buglogfh =3D IO::File->new($buglog,'r') or die("open log for $ref: $!"=
);
}

my %status =3D
    %{split_status_fields(get_bug_status(bug=3D>$ref,
                                         bugusertags =3D> \%bugusertags,
                                        ))};

my @records;
eval{
     @records =3D read_log_records($buglogfh);
};

binmode(STDOUT,":raw");
my $date =3D strftime "%a %b %d %T %Y", localtime;

my $message_number=3D0;
my %seen_message_ids;
for my $record (@records) {
	next if $record->{type} !~ /^(?:recips|incoming-recv)$/;
	my $wanted_type =3D 'incoming-recv';
	# we want to include control messages anyway
	my $record_wanted_anyway =3D 0;
	my ($msg_id) =3D $record->{text} =3D~ /^Message-Id:\s+<(.+)>/im;
	next if defined $msg_id and exists $seen_message_ids{$msg_id};
	next if defined $msg_id and $msg_id =3D~/handler\..+\.ack(?:info|done)?\@/=
;
	$record_wanted_anyway =3D 1 if $record->{text} =3D~ /^Received: \(at contr=
ol\)/;
	next if not $record->{type} eq $wanted_type and not $record_wanted_anyway =
and @records > 1;
	$seen_message_ids{$msg_id} =3D 1 if defined $msg_id;
	my @lines =3D split( "\n", $record->{text}, -1 );
	if ( $lines[ 1 ] =3D~ m/^From / ) {
		my $tmp =3D $lines[ 0 ];
		$lines[ 0 ] =3D $lines[ 1 ];
		$lines[ 1 ] =3D $tmp;
	}
	if ( !( $lines[ 0 ] =3D~ m/^From / ) ) {
		unshift @lines, "From unknown $date";
	}
	map { s/^(>*From )/>$1/ } @lines[ 1 .. $#lines ];
	print join( "\n", @lines ) . "\n";
}

exit 0;

--=_1y9qSnMlIElqjnyW1FN_3nD--

--=_0os05MFYWClYzphydJOWfb7
Content-Type: application/pgp-signature
Content-Description: Digitale PGP-Signatur
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABCAAGBQJWyCklAAoJEJr0azAldxsx+cEQAI3EY28umdwOKH/O5t6Xbk7Q
VUpTBPX73h9aerp+C4FIXdvjA7BE1Y1XizF27hwsFjnk4GIT80b2sGeyw1z+deto
WQgadegIEki6tLPH1bJINnUPKvMUnjH7aTIOpT+j7u4ftNWnY7nFME5ubOQCnncf
mATUCPPDKNm6oN5fK+icgzvAt6YpjRVCeE6czynLHUlR8Q6fZMlS83lDPdsFxggB
43IzcwExanGnE56JPfmWOXOVZJbRiK/DJd9/fLKO1shBMruA7JeMqWgChYoYj8CN
KzEDixhnsFLflF3SpXOBOlWfW10I9+gu/Ppd2V/tgGLnZDo8WKjw4IqFW+aYJeQp
AOABvKu2h8GC6xOe+XBRPBm0aSETyqnqyt7C6gjVaT5Q5xdf/Pitok1xnPg+cv9Y
FoAtKEiOm1zEA7m0PZopv8WbY1Zh9dRNLqLsAhk4svWFzS2xPFdGiO0SjGK0iXYh
1lS7jlfUb/Gu25rgdMMJILJBuNLk6VqWpJnjhe+0nYS/6wserfkP4YlAxQXJ/h8Q
L+o45dOriyzmxNw2cfiE8xxLCqU6D+FNFheoZMcVyNfZ/+Cgjs4c3Lvgj2GCqXGX
nbyGx0HgeZcHXyOwB5x8htq+EQVBVnkuajR5dOcEb0pafCnM1ylze3EBAjR/fc9W
1XgeRM7Yx0NMbDAjjyQN
=DE/i
-----END PGP SIGNATURE-----

--=_0os05MFYWClYzphydJOWfb7--

