Planet HantsLUG

Syndicate content
Planet HantsLUG - http://www.hantslug.org.uk/planet/
Updated: 14 weeks 3 days ago

Chris Dennis: Signals in Perl, 5.10.1 vs 5.14.2

Mon, 06/02/2012 - 17:37

A Perl script that I've been working on wasn't working properly with Perl 5.14.2.

It turned out that the problem was really with my use of local signal handlers.

The following code works with 5.10.1 but not with 5.14.2:

#!/usr/bin/perl
use strict;
use warnings;
print "starting pid=$$\n";
my $I = 0;
{
  my $pid = 0;
  sub handler {
    my $sig = shift;
    $I += 1;
    print "caught $sig\n";
    local $SIG{$sig} = 'IGNORE'; # doesn't work with local!!
    kill($sig, -$$);
    print "end of handler\n";
  }
  local $SIG{INT} = \&handler;
  kill('INT', $$);
}
print "ending I=$I\n";

With 5.10.1, it calls handler() twice and then exits with I=2; with 5.14.2 it calls the handler many times before crashing with a segfault.

Removing the local from the inner $SIG{$sig} allows it to work with 5.14.2, which makes sense if I'm right in thinking that that command changes the immediately-containing signal handler, and not the global one.

I found the Perl documentation a bit vague on this topic, so this is here in case it's useful to someone else.

Categories: LUG Community Blogs

Steve Kemp: Some domains just don't learn

Sun, 05/02/2012 - 14:24

For the past few years the anti-spam system I run has been based on a simplified version of something I previously ran commercially.

Although the code is similar in intent there were both explicit feature removals, and simplifications made.

Last month I re-implimented domain-blacklisting - because a single company keeps ignoring requests to remove me.

So LinkedIn.com if you're reading this:

  • I've never had an account on your servers.
  • I find your junk mail annoying.
  • I suspect I'll join your site/service when hell freezes over.

I've also implemented TLD-blacklisting which has been useful.

TLD-blacklisting in my world is not about blocking mail from foo@bar.ph (whether in the envelope sender, or the from: header), instead it is about matching the reverse DNS of the connecting client.

If I recieve a connection from 1.2.3.4 and the reverse DNS of that IP address matches, say, /\.sa$/i then I default to denying it.

My real list is longer, and handled via files:

steve@steve:~$ ls /srv/_global_/blacklisted/tld/ -C ar br cn eg hr in kr lv mn np ph ro sg tg ua ve zw aw cc cy gm hu is kz ma my nu pk rs sk th ug vn be ch cz gr id it lk md mz nz pl ru su tr uy ws bg cl ec hk il ke lt mk no om pt sa sy tw uz za

On average I'm rejecting about 2500 messagse a day at SMTP-time, and 30 messages, or so, hit my SPAM folder after being filtered with CRM114 after being accepted for delivery. (They are largely from @hotmail and @yahoo, along with random compromised machines. The amount of times I see a single mail from a host with RDNS mysql.example.org is staggering.).

(Still looking forward to the development of Haraka, a node.js version of qpsmtpd.)

ObQuote: "Mr. Mystery Guest? Are you still there? " - Die Hard

Categories: LUG Community Blogs

Tony Whitmore: Ubuntu Podcast, Season 5

Sat, 04/02/2012 - 17:01

We’re going out for the Planning Curry for season five of the Ubuntu Podcast this week. Over the years, it has become a tradition for all the presenters to go out for a curry before the start of the season. It’s a time to catch up in person, as we haven’t seen much of each other since the end of the last season. But it’s also a chance to discuss any changes we want to make to the show and throw ideas for new segments around. So, if there’s anything you’d like to see in the new season, whether it’s an idea for a segment or a change to something we already do, please let us know. You can leave a comment on this blog post or get in touch using any of the methods on the show website. Thanks!

Categories: LUG Community Blogs

David Ramsden: Virtual Hosting With mod_proxy

Thu, 02/02/2012 - 23:20

The other day I had someone ask if there's a nice solution to the following problem:

Multiple web development virtual machines but only one external IP address.

The quick solution is to port forward on different ports to each virtual machine. For example 81 goes to VM1, 82 goes to VM2, 83 goes to VM3 etc. Which granted, would work, but isn't a "neat" solution.

Using mod_proxy under Apache is a much better solution to this problem.

Deploy a "front-end" server running Apache and mod_proxy. Create a virtual host for each virtual server and then using mod_proxy, reverse proxy to the virtual server. Port forward from the WAN to your front-end Apache server running mod_proxy.

Here's what an example config would look like on the front-end Apache server:

<VirtualHost 213.131.192.201:80> ServerName cust1.dev.domain.com ServerAdmin webmaster@cust1.dev.domain.com ProxyRequests off ProxyPreserveHost on ProxyPass / http://192.168.0.100/ ProxyPassReverse / http://192.168.0.100/ <Proxy *> Order allow,deny Allow from all </Proxy> ErrorLog /var/log/apache2/cust1.dev.domain.com.log CustomLog /var/log/apache2/cust1.dev.domain.com.err.log combined </VirtualHost> <VirtualHost 213.131.192.201:80> ServerName cust2.dev.domain.com ServerAdmin webmaster@cust2.dev.domain.com ProxyRequests off ProxyPreserveHost on ProxyPass / http://192.168.0.101/ ProxyPassReverse / http://192.168.0.101/ <Proxy *> Order allow,deny Allow from all </Proxy> ErrorLog /var/log/apache2/cust2.dev.domain.com.log CustomLog /var/log/apache2/cust2.dev.domain.com.err.log combined </VirtualHost>

Requests for cust1.dev.domain.com would be reverse proxied to 192.168.0.100 and requests for cust2.dev.domain.com would be reverse proxied to 192.168.0.101. All with one external IP address and one port forward rule.

Just one of the many uses of mod_proxy. You can also use it for SSL bridging and SSL offloading. Neat!

Categories: LUG Community Blogs

Adam Trickett: Picasa Web: Macro

Tue, 31/01/2012 - 09:00

Macro and close up shots

Location: N/A
Date: 31 Jan 2012
Number of Photos in Album: 25

View Album

Categories: LUG Community Blogs

Adam Trickett: Picasa Web: 30 January 2012

Mon, 30/01/2012 - 23:00
Date: 30 Jan 2012
Number of Photos in Album: 1

View Album

Categories: LUG Community Blogs

Chris Dennis: Xubuntu 11.10 on Novatech B940 NNB-888 laptop

Mon, 30/01/2012 - 15:45

This was for a client who only needs the basics — email, typing, web browsing — and doesn't have time to adapt to a trendy new GUI.

So I installed Xubuntu 11.10 (I like XFCE).

And it all just worked out of the box — wifi, webcam, sound etc.

Except for sleep and hibernation.  I tried all sorts of fixes and troubleshooting, but nothing worked.  The screen goes blank, but it doesn't turn off.  After being forced off, it resumes as though sleep or hibernation had worked.  Couldn't solve it, so I just changed the settings to never try to sleep or hibernate.

Categories: LUG Community Blogs

Chris Dennis: Updating from Ubuntu 9.04 to Xubuntu 11.10

Mon, 30/01/2012 - 15:17

I was working on a client's laptop, on which I'd installed Ubuntu 9.04 a few years ago and it hadn't been updated since then.

I wanted to bring it up to date, and knew that the client wouldn't want the look-and-feel of it to change radically, so to avoid Unity and Gnome 3, I decided to install Xubuntu 11.10.

I backed everything up, expecting to do a clean install of the new system.  But the Xubuntu installer offered to upgrade directly from 9.04, so I tried it, and it worked! 

The only minor glitch was that Thunderbird didn't find the old profile.  I had to rename ~/.mozilla-thunderbird to ~/.thunderbird, and then that worked too.

Categories: LUG Community Blogs

Chris Dennis: AppConfig and @ARGV

Sun, 29/01/2012 - 18:18

I've been playing with the Perl AppConfig module (http://search.cpan.org/~abw/AppConfig-1.66/lib/AppConfig.pm)

It seems that the getopt() method messes up the global @ARGV array even if I pass it a copy.

For example:
 

#!/usr/bin/perl
use strict;
use warnings;
use AppConfig;
my $opts = AppConfig->new( { CASE   => 0, } );
$opts->define('config=s', {DEFAULT => ''});
print "ARGV: @ARGV\n";
my $argvCopy = [@ARGV];
print "argvCopy: @$argvCopy\n";
$opts->args($argvCopy);
print "after args() ARGV: @ARGV\n";
$opts->getopt(qw(auto_abbrev), $argvCopy);
print "after getopt() ARGV: @ARGV\n";

produces this output

# appconfig-error.pl --config xyz 123 abc
ARGV: --config xyz 123 abc
argvCopy: --config xyz 123 abc
after args() ARGV: --config xyz 123 abc     # @ARGV is still complete
after getopt() ARGV: 123 abc                # @ARGV has bits missing

This is a problem because I need to call getopt() twice — once to get at the –config option, then I read the configuration file with the file() method, then I re-read the command line options so that they override the ones in the configuration file.

Using args() is OK — @ARGV is preserved — but I need the extra feature of getopt().

I've emailed the author, so I'll wait to see what his reply is.

Categories: LUG Community Blogs