dgl's Journal http://use.perl.org/~dgl/journal/ dgl's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:39:46+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 dgl's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~dgl/journal/ iPlayer downloader http://use.perl.org/~dgl/journal/35902?from=rss <a href="http://www.theregister.co.uk/2008/03/13/iplayer_iphone_drm_loophole_closed/">According to The Register</a> the BBC have closed their "iPhone loophole" in iPlayer (and presumably come up with a DRM solution that works over plain HTTP?). <a href="http://dgl.cx/2008/03/iplayer.pl">We'll see about that</a> (please excuse my rather evil code). dgl 2008-03-13T22:33:24+00:00 journal Network Solutions tasting all domains queried http://use.perl.org/~dgl/journal/35339?from=rss <p>Just incase you were in doubt that Network Solutions / VeriSign were scum after the wildcard<nobr> <wbr></nobr>.com incident their latest shady tactic is to register all domains queried.</p><p> 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: </p><blockquote><div><p> <tt>&nbsp; &nbsp;------------------------------------------------------------------------<br>&nbsp; &nbsp;This Domain is Available - Register it Now!<br>&nbsp; &nbsp;600,000 domain names are registered daily! Don't delay; there's no guarantee<br>&nbsp; &nbsp;that a domain name you see today will still be here tomorrow!<br>&nbsp; &nbsp;Register it Now at www.NetworkSolutions.com.<br>&nbsp; &nbsp;------------------------------------------------------------------------<br> <br>&nbsp; &nbsp;Administrative Contact, Technical Contact:<br>&nbsp; &nbsp; &nbsp; Network Solutions, LLC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; domainsupport@networksolutions.com<br>&nbsp; &nbsp; &nbsp; 13681 Sunrise Valley Drive, Suite 300<br>&nbsp; &nbsp; &nbsp; HERNDON, VA 20171<br>&nbsp; &nbsp; &nbsp; US<br>&nbsp; &nbsp; &nbsp; 1-888-642-9675 fax: 571-434-4620<br> <br>&nbsp; &nbsp;Record expires on 09-Jan-2009.<br>&nbsp; &nbsp;Record created on 09-Jan-2008.<br>&nbsp; &nbsp;Database last updated on 9-Jan-2008 07:08:22 EST.<br> <br>&nbsp; &nbsp;Domain servers in listed order:<br> <br>&nbsp; &nbsp;ns1.reserveddomainname.com&nbsp; &nbsp;<br>&nbsp; &nbsp;ns2.reserveddomainname.com&nbsp; &nbsp;</tt></p></div> </blockquote><p> 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.) </p><p> (<a href="http://news.ycombinator.com/item?id=96246">via hacker news.</a>)</p> dgl 2008-01-09T14:04:57+00:00 journal perlbug-- http://use.perl.org/~dgl/journal/35266?from=rss So I typed a bug out, went to send it and got:<blockquote><div><p> <tt>Action (Send/Display/Edit/Subject/Save to File): Send<br>Are you certain you want to send this message?<br>Please type "yes" if you are: yes<br> <br>Sendmail returned status '2'<br>dgl: ~ %</tt></p></div> </blockquote><p>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:</p><blockquote><div><p> <tt># TODO: - Allow the user to re-name the file on mail failure, and<br>#&nbsp; &nbsp; &nbsp; &nbsp;make sure failure (transmission-wise) of Mail::Send is<br>#&nbsp; &nbsp; &nbsp; &nbsp;accounted for.</tt></p></div> </blockquote><p> Losing bugs that I just spent 10 minutes typing isn't good (although I'll get around to submitting it soon). </p><p> Also, it seems the old behaviour was to keep the temp files around but for security reasons if File::Temp is installed it does:</p><blockquote><div><p> <tt>my ($fh, $filename) = File::Temp::tempfile(UNLINK =&gt; 1);</tt></p></div> </blockquote><p>(Note the UNLINK.) </p> dgl 2008-01-02T11:15:47+00:00 journal Charging an iPod Touch under Linux http://use.perl.org/~dgl/journal/34713?from=rss <p>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. </p><p>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. </p><p>Anyway, a bit of Googling pointed me to someone who claims <a href="http://mattcolyer.com/projects/iphone-module/">a module</a> designed for charging the iPhone <a href="http://www.jroller.com/dschneller/entry/how_to_charge_the_ipod">works</a> but it didn't for me as the USB ID differs, but <a href="http://dgl.cx/2007/10/0001-Add-iPod-Touch-USB-ID.patch">this patch</a> fixes it. </p><p>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. </p><p>It will be interesting to see how open the <a href="http://www.apple.com/pr/library/2007/06/11iphone.html">upcoming SDK</a> is. I guess I could just <a href="http://toc2rta.com/?q=node/23">root it</a> anyway.</p> dgl 2007-10-18T20:33:36+00:00 journal Ubuntu mouse/trackpad problems on HP 510 http://use.perl.org/~dgl/journal/33263?from=rss <p> <b>Update</b> 3 Jun 2007: The latest Ubuntu feisty kernel (2.6.20-16.28) now has fixed support, so this workaround shouldn't be needed.</p><p>The HP 510 laptop has a rather annoying bug under Linux the track pad doesn't work. As mentioned <a href="http://www.hexten.net/2007/03/25/touchpad-wlan-hp-500-hp-510-ubuntu">here</a>, <a href="http://hp500.xf.cz/us/Main.html">here</a>, <a href="http://ubuntuforums.org/showthread.php?t=344103">here</a> and in <a href="https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.20/+bug/96598">bug #96598</a>.</p><p> 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.</p><p> Assuming you are using feisty (7.04) once you've installed Ubuntu[1], download <a href="http://dgl.cx/2007/05/ubuntu-hp510/linux-image-2.6.20-15-generic_2.6.20-15.27dgl_i386.deb">this kernel-image package</a> (23M) and install it (<tt>dpkg -i linux-image-2.6.20-15-generic_2.6.20-15.27dgl_i386.deb</tt>).</p><p> 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!</p><p> [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.. </p> dgl 2007-05-13T16:46:44+00:00 journal Perl's lack of setgroups http://use.perl.org/~dgl/journal/33182?from=rss <small>(Hi, I thought I'd start a blog..)</small><p> I want a process (started as root) to put itself in some additional groups before it changes to an unprivileged user. perldoc <a href="http://perldoc.perl.org/perlvar.html">perlvar</a> states this isn't possible via setting $GID or $(:</p><blockquote><div><p> "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."</p></div> </blockquote><p> Next stop is <a href="http://perldoc.perl.org/POSIX.html">POSIX</a>, it helpfully contradicts perlvar:</p><blockquote><div><p> "setgid [..] Similar to assigning a value to the Perl&#8217;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."</p></div> </blockquote><p> 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 <a href="http://perldoc.perl.org/perl5004delta.html#Group-vector-changeable-with-'%24)'">added in perl 5.004</a>. </p><p> I gave up and just tried it (with Perl 5.8.8 on Ubuntu):</p><blockquote><div><p> <code> # perl -MEnglish -e'$EGID = $GID = "1000 10"; $EUID = $UID = 65534; system("id")'<br> uid=65534(nobody) gid=1000(dgl) groups=0(root) </code></p></div> </blockquote><p> It doesn't work. Also notice it keeps the additional group root around, which is a bit scary too. </p><p> 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. </p><p> setgroups is simply (on Linux x86):</p><blockquote><div><p> <code> sub setgroups {<br> &nbsp;&nbsp;syscall 206, scalar @_, pack("L" x @_, @_);<br> }<br> </code></p></div> </blockquote><p> This has the desired effect:</p><blockquote><div><p> <code> # perl -MEnglish -MPOSIX -e'sub setgroups { syscall 206, scalar @_, pack("L" x @_, @_); } setgroups(1000,10); $EGID = $GID = 1000; $EUID = $UID = 65534; system("id")'<br> uid=65534(nobody) gid=1000(dgl) groups=10(uucp),1000(dgl) </code></p></div> </blockquote><p> 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. </p><p> Note under Linux the syscall number can be found by looking in<nobr> <wbr></nobr>/usr/include/&lt;arch&gt;/syscall.h (where &lt;arch&gt; is your architecture, e.g. x86). It might be easier to grep<nobr> <wbr></nobr>/usr/include for __NR_setgroups32 (or __NR_setgroups if it's a newer architecture). </p><p> <b>Update</b>: Ignore this post, I realised it's very simple, $EGID is the thing to set first.. i.e. $GID = $EGID = "10 1000"; works fine.. </p> dgl 2007-05-03T01:12:05+00:00 journal