Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

dgl (5868)

dgl
  (email not shown publicly)
http://dgl.cx/

Journal of dgl (5868)

Thursday March 13, 2008
05:33 PM

iPlayer downloader

According to The Register the BBC have closed their "iPhone loophole" in iPlayer (and presumably come up with a DRM solution that works over plain HTTP?). We'll see about that (please excuse my rather evil code).
Wednesday January 09, 2008
09:04 AM

Network Solutions tasting all domains queried

Just incase you were in doubt that Network Solutions / VeriSign were scum after the wildcard .com incident their latest shady tactic is to register all domains queried.

If you go to Network Solutions (I'm not even giving them the benefit of a link) and search on a domain, you'll find within an hour it has been registered like this:

   ------------------------------------------------------------------------
   This Domain is Available - Register it Now!
   600,000 domain names are registered daily! Don't delay; there's no guarantee
   that a domain name you see today will still be here tomorrow!
   Register it Now at www.NetworkSolutions.com.
   ------------------------------------------------------------------------

   Administrative Contact, Technical Contact:
      Network Solutions, LLC            domainsupport@networksolutions.com
      13681 Sunrise Valley Drive, Suite 300
      HERNDON, VA 20171
      US
      1-888-642-9675 fax: 571-434-4620

   Record expires on 09-Jan-2009.
   Record created on 09-Jan-2008.
   Database last updated on 9-Jan-2008 07:08:22 EST.

   Domain servers in listed order:

   ns1.reserveddomainname.com   205.178.190.55
   ns2.reserveddomainname.com   205.178.189.55

Of course, this means once someone has queried it on their site they pretty much have to register it through them. (As domain tasting companies will probably pick the domain up otherwise.)

(via hacker news.)

Wednesday January 02, 2008
06:15 AM

perlbug--

So I typed a bug out, went to send it and got:

Action (Send/Display/Edit/Subject/Save to File): Send
Are you certain you want to send this message?
Please type "yes" if you are: yes

Sendmail returned status '2'
dgl: ~ %

OK, my fault for not having a working sendmail binary, but still, it could have handled it better. The code has what I feel is quite an important TODO:

# TODO: - Allow the user to re-name the file on mail failure, and
#       make sure failure (transmission-wise) of Mail::Send is
#       accounted for.

Losing bugs that I just spent 10 minutes typing isn't good (although I'll get around to submitting it soon).

Also, it seems the old behaviour was to keep the temp files around but for security reasons if File::Temp is installed it does:

my ($fh, $filename) = File::Temp::tempfile(UNLINK => 1);

(Note the UNLINK.)

Thursday October 18, 2007
03:33 PM

Charging an iPod Touch under Linux

I thought I'd treat myself to an iPod touch. Being largely blinded by the shininess of it I didn't actually bother to see how well it worked under Linux. It turns out the answer is not at all it doesn't even charge. Apple in their infinite wisdom have made it even more closed than previous iPods. Nice one Apple.

I can just about live without being able to use it as a mass storage device and needing a Mac or windows machine to organise music, but I do want to be able to charge it easily.

Anyway, a bit of Googling pointed me to someone who claims a module designed for charging the iPhone works but it didn't for me as the USB ID differs, but this patch fixes it.

As for the device itself it's rather nice. My main complaint (which was also one of the first questions a friend asked me about it) is how crippled the WiFi is. You can't download music via the wireless (e.g. download it from a website, rather than just listen within Safari), listen to streaming audio, stream to an AirPort Express (that would be really cool!) or connect to iTunes shares. It really feels like Apple are trying to keep it as closed as possible (I guess I shouldn't be surprised); You can only download music onto the device from the iTunes store and the only video site you can use is YouTube. About the only concession I can find is you can change the default search engine in Safari from Google to Yahoo.

It will be interesting to see how open the upcoming SDK is. I guess I could just root it anyway.

Sunday May 13, 2007
11:46 AM

Ubuntu mouse/trackpad problems on HP 510

Update 3 Jun 2007: The latest Ubuntu feisty kernel (2.6.20-16.28) now has fixed support, so this workaround shouldn't be needed.

The HP 510 laptop has a rather annoying bug under Linux the track pad doesn't work. As mentioned here, here, here and in bug #96598.

Anyway as a few people seem to be experiencing the problem I thought I'd rebuild the Ubuntu kernel with the fix as it's easier to run the Ubuntu kernel. Mainly because running a kernel compiled yourself on Ubuntu seems to end up with random things breaking, hopefully this will save some other people from having to compile a kernel themselves too.

Assuming you are using feisty (7.04) once you've installed Ubuntu[1], download this kernel-image package (23M) and install it (dpkg -i linux-image-2.6.20-15-generic_2.6.20-15.27dgl_i386.deb).

Combined with this and installing 915resolution (I didn't even have to configure it, simply installing it was enough) the laptop seems to be working perfectly, including wireless, fn keys and suspend which is definitely progress over a few years ago, especially for a budget laptop!

[1]: Note: to run the live CD installer without a mouse, press Alt+F2 to open the run dialog, then type ubiquity, it's just about usable with the keyboard tab refused to change the focus in the timezone selection, Alt+f for forward seemed to work though. It might be easier to plug a USB mouse in though..

Wednesday May 02, 2007
08:12 PM

Perl's lack of setgroups

(Hi, I thought I'd start a blog..)

I want a process (started as root) to put itself in some additional groups before it changes to an unprivileged user. perldoc perlvar states this isn't possible via setting $GID or $(:

"However, a value assigned to $( must be a single number used to set the real gid. So the value given by $( should not be assigned back to $( without being forced numeric, such as by adding zero."

Next stop is POSIX, it helpfully contradicts perlvar:

"setgid [..] Similar to assigning a value to the Perl’s builtin $) variable, see "$GID" in perlvar, except that the latter will change only the real user identifier, and that the setgid() uses only a single numeric argument, as opposed to a space-separated list of numbers."

POSIX also provides the function getgroups, but there's no sign of setgroups! Even more helpfully yet another part of the Perl documentation implies this feature was added in perl 5.004.

I gave up and just tried it (with Perl 5.8.8 on Ubuntu):

# perl -MEnglish -e'$EGID = $GID = "1000 10"; $EUID = $UID = 65534; system("id")'
uid=65534(nobody) gid=1000(dgl) groups=0(root)

It doesn't work. Also notice it keeps the additional group root around, which is a bit scary too.

Perl does provide some help though -- through syscall() it's possible to work around the lack of setgroups. Unfortantely syscall() depends on knowing the number of the system call, which varies according to the architecture (even x86-64 is different to x86) and operating system in use.

setgroups is simply (on Linux x86):

sub setgroups {
  syscall 206, scalar @_, pack("L" x @_, @_);
}

This has the desired effect:

# perl -MEnglish -MPOSIX -e'sub setgroups { syscall 206, scalar @_, pack("L" x @_, @_); } setgroups(1000,10); $EGID = $GID = 1000; $EUID = $UID = 65534; system("id")'
uid=65534(nobody) gid=1000(dgl) groups=10(uucp),1000(dgl)

Maybe it would be better written as a module for CPAN although personally I'd rather see this fixed in the Perl core. As it leaves additional groups around with no way to get rid of them, I wouldn't be surprised if it results in a security issue in Perl programs trying to drop privileges.

Note under Linux the syscall number can be found by looking in /usr/include/<arch>/syscall.h (where <arch> is your architecture, e.g. x86). It might be easier to grep /usr/include for __NR_setgroups32 (or __NR_setgroups if it's a newer architecture).

Update: Ignore this post, I realised it's very simple, $EGID is the thing to set first.. i.e. $GID = $EGID = "10 1000"; works fine..