Hi all,
last night, I created to new scripts for the debbugs software underneath bugs.x2go.org.
Both scripts are attached and can be found under /usr/lib/debbugs on host ymir.das-netzwerkteam.de.
Especially the cleanbug script should be of interested here.I recently received various abuse notifications from my provider and they all relate to X2GO bugs containing mails with virus attachments. These need 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 the X2Go bugtracker. Currently, these people have access:
Heinz Mihai MikeYou have to log into ymir.das-netzwerkteam.de (aka bugs.x2go.org) as user locadm 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 selected bug and say yes and no.
At the end you get asked, if you really want to write back the changes to the bug. The answer's question defaults to "no".
You should create some back before manipulating existing bugs. For this, create copies of <bugno>.log in /var/lib/debbugs/spool/db-h/
Note for archived bugs: for cleaning up archived bugs, you have to unarchive them first.
Mike -- DAS-NETZWERKTEAM mike gabriel, herweg 7, 24357 fleckeby fon: +49 (1520) 1976 148 GnuPG Key ID 0x25771B31 mail: [email protected], http://das-netzwerkteam.de freeBusy: https://mail.das-netzwerkteam.de/mailxchange/kronolith/fb.php?u=m.gabriel%40das-netzwerkteam.de
#!/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) = @_; # take a prompt string as argument
local $| = 1; # activate autoflush to immediately show the prompt
print $query;
chomp(my $answer = <STDIN>);
return $answer;
}
sub prompt_yesno {
my ($query) = @_;
my $answer = prompt("$query (Y/n): ");
return (lc($answer) ne 'n');
}
sub prompt_noyes {
my ($query) = @_;
my $answer = prompt("$query (N/y): ");
return (lc($answer) eq 'y');
}
my $ref = shift or die;
my %bugusertags;
my $buglog = buglog($ref);
my $bug_status = bug_status($ref);
my $buglogfh;
my $cleanedbuglogfh;
if ($buglog =~ m/\.gz$/) {
my $oldpath = $ENV{'PATH'};
$ENV{'PATH'} = '/bin:/usr/bin';
$buglogfh = IO::File->new("zcat $buglog |") or die("open log for $ref: $!");
$ENV{'PATH'} = $oldpath;
} else {
$buglogfh = IO::File->new($buglog,'r') or die("open log for $ref: $!");
}
my %status =
%{split_status_fields(get_bug_status(bug=>$ref,
bugusertags => \%bugusertags,
))};
my @records;
eval{
@records = read_log_records($buglogfh);
};
my @cleaned_records = ();
binmode(STDOUT,":raw");
my $date = strftime "%a %b %d %T %Y", localtime;
my $message_number=0;
for my $record (@records) {
my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im;
my @lines = split( "\n", $record->{text}, -1 );
if ( $lines[ 1 ] =~ m/^From / ) {
my $tmp = $lines[ 0 ];
$lines[ 0 ] = $lines[ 1 ];
$lines[ 1 ] = $tmp;
}
if ( !( $lines[ 0 ] =~ 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 = IO::File->new($buglog,'w') or die("open log for
$ref: $!");
write_log_records(logfh => $cleanedbuglogfh,
records => \@cleaned_records,
);
} else {
print "\nANSWER WAS: NO\n\n";
}
exit 0;
#!/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 = shift or die;
my %bugusertags;
my $buglog = buglog($ref);
my $bug_status = bug_status($ref);
my $buglogfh;
if ($buglog =~ m/\.gz$/) {
my $oldpath = $ENV{'PATH'};
$ENV{'PATH'} = '/bin:/usr/bin';
$buglogfh = IO::File->new("zcat $buglog |") or die("open log for $ref: $!");
$ENV{'PATH'} = $oldpath;
} else {
$buglogfh = IO::File->new($buglog,'r') or die("open log for $ref: $!");
}
my %status =
%{split_status_fields(get_bug_status(bug=>$ref,
bugusertags => \%bugusertags,
))};
my @records;
eval{
@records = read_log_records($buglogfh);
};
binmode(STDOUT,":raw");
my $date = strftime "%a %b %d %T %Y", localtime;
my $message_number=0;
my %seen_message_ids;
for my $record (@records) {
next if $record->{type} !~ /^(?:recips|incoming-recv)$/;
my $wanted_type = 'incoming-recv';
# we want to include control messages anyway
my $record_wanted_anyway = 0;
my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im;
next if defined $msg_id and exists $seen_message_ids{$msg_id};
next if defined $msg_id and $msg_id
=~/handler\..+\.ack(?:info|done)?\@/;
$record_wanted_anyway = 1 if $record->{text} =~ /^Received: \(at
control\)/;
next if not $record->{type} eq $wanted_type and not
$record_wanted_anyway and @records > 1;
$seen_message_ids{$msg_id} = 1 if defined $msg_id;
my @lines = split( "\n", $record->{text}, -1 );
if ( $lines[ 1 ] =~ m/^From / ) {
my $tmp = $lines[ 0 ];
$lines[ 0 ] = $lines[ 1 ];
$lines[ 1 ] = $tmp;
}
if ( !( $lines[ 0 ] =~ m/^From / ) ) {
unshift @lines, "From unknown $date";
}
map { s/^(>*From )/>$1/ } @lines[ 1 .. $#lines ];
print join( "\n", @lines ) . "\n";
}
exit 0;
pgpL2vOuF5Vki.pgp
Description: Digitale PGP-Signatur
_______________________________________________ x2go-project mailing list [email protected] http://lists.x2go.org/listinfo/x2go-project
