Search Results: "mpalmer"

1 December 2005

Matthew Palmer: A trace mixin for Python

Although I am by means an expert Python programmer, I do dabble -- at the moment, I'm dabbling fairly heavily in a project for work. I had need, as you do on occasion, for a call trace (I called this method, it returned X, I then called this other method, it returned Y, and so on). Astoundingly, I got no answer when I asked on #python, as I would have expected this sort of thing to be a gimme -- even possibly including it as a core language feature. But nary an answer was forthcoming. Searches for mixins or magic function calls which might solve my problem were similarly fruitless. I resigned myself to manually sticking print wrappers around the function calls of interest, but that got old real fast (especially after I spent about a half-hour chasing my tail because I'd forgotten to return the return value after I printed it). As usual, my subconscious saved the day. On the train home this afternoon, I suddenly had a brainwave, and the code which I've reproduced below appeared almost fully-formed at my fingertips. It's times like this that I really enjoy programming. Now, of course, someone will pop up and say "oh here it is over here", or "you just set the __trace_me_baby__ attribute on your object", but I can console myself with the fact that I know a lot more about grubby Python internals than I did before. The code: (a pre-saved version is also available).
# tracemixin.py
#
# A python mixin to trace the calling of methods.
#
# Copyright (C) 2005 Matthew Palmer 
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#   or see http://www.gnu.org/licenses/gpl.html
#   
"""
A mixin class to permit the tracing of method calls on an object.
This class, when mixed in, overrides the default operation of method calls
so that requests to call methods which have been listed in the
self._traced_methods list will be printed with their arguments and return
values.  Also included is a simple call depth indication, using indents.
Tracing of particular methods can be turned on and off on a per-object basis
by simply including or removing the method's name in the _traced_methods
list on the particular object.  Whole classes can be traced by setting
the list as a class attribute.
To include this class, simply make it the first class name in the list of
parent classes when defining a new class, like so:
class Something(TraceMixin, RealParentClass):
You could probably leave the TraceMixin in your production code, although
it'll slow execution down by a bit.
Complete usage example:
from tracemixin import TraceMixin
class RandomTask(TraceMixin):
	def x(self):
		print "X!"
	
	def y(self, arg):
		print "%s Y!" % arg
		self.x()
x = RandomTask()
x.x()
x._traced_methods = ['x', 'y']
x.y('why?')
Output:
X!
::y(why?)
why? Y!
  ::x()
X!
  =>None
=>None
"""
class TraceMixin(object):
	_traced_methods = []
	_depth = 0
	def __getattribute__(self, attr):
		if attr in object.__getattribute__(self, '_traced_methods'):
			self.method = attr
			attr = '_trace_proxy'
		return object.__getattribute__(self, attr)
	
	def _trace_proxy(self, *args):
		realmethod = object.__getattribute__(self, self.method)
		if realmethod and realmethod.__class__ == self._trace_proxy.__class__:
			print "%s::%s(%s)" % (self._depth*'  ', self.method, ', '.join(args))
			self._depth += 1
			rv = realmethod(*args)
			self._depth -= 1
			print "%s=>%s" % (self._depth*'  ', rv)
			return rv
		else:
			raise AttributeError

24 November 2005

Matthew Palmer: Key Signing and The Identity Problem

Yet another thread on keyring updates in Debian has gotten me thinking about key signatures, what they really represent, and other associated topics. For those of you who might not know what I'm talking about, a brief primer. Before someone can be admitted as a Debian Developer, they have to have an OpenPGP key (practically, a GPG key) signed by a current Debian Developer. That is, someone who is currently a DD has looked at a photo ID, compared the photo to the face offering a key fingerprint, and compared the name on the ID to the name on the key. If they all match, we have a signature. The other qualification for becoming a Developer is going through a process designed to determine whether you have the required competencies. Since this testing process is conducted electronically, not face-to-face, the primary means of identifying the person behind the answers is via the OpenPGP key they used throughout the process. So, what do we have out of this process? Two things, that I can determine: So, the problem at issue is this -- what do you do when you lose control of that key? You lose it, or it gets compromised, or it expires (whoops!), or whatever. For all intents and purposes, when you lose control of your key, you no longer have an identity, in Debian terms. Generating a new key (and hence identity) is straightforward -- a quick invocation of gpg and you're away. Unfortunately, all that gets you is a pile of bits. There's nothing that intrinsically links you to that key. That's what other people's signatures on your key is for. Then, it comes time to get Debian to accept your new key as belonging to you. This is a lot harder than trying to convince the RTA (DMV.en_AU('New South Wales')) to give you a replacement drivers' licence. Why should it be? You're doing effectively the same thing -- "I am $FIRSTNAME $LASTNAME, give me my (licence upload privileges)". The difference is that, in the Debian case, all of our identity is effectively tied up in the key we use to go through NM. The person behind the key is somehow secondary to that whole process. So when the key completes NM, we record it in the "people who can upload" keyring. When a new key (which is prima facie completely untrusted) should be put into the keyring, we need to ensure that it is qualified. How can that key prove qualification? Well, we can send the new key through NM (dear ghods, no!) or refer to the source document (as it were) -- the human being. We're looking for consistency between the person between the two keys. That's trickier than it looks at first glance. Why? The big one is the non-uniqueness of $FIRSTNAME $LASTNAME (or even $FIRSTNAME $INITIAL $LASTNAME, for those so blessed). Google for yourself one day, and you'll see what I'm talking about. Anyone who has the same name as you could, at first instance, pretend to be "you" (for some values of, anyway). It might seem fairly unlikely, but there are two DDs with easily-mistakable names, out of a pool of 1,000 or so. The probabilities are not in our favour on this one. Then, of course, there's fake IDs, which are a whole other ballgame. How does the government get around the problem of name clashes and identity-theft-by-ID? By using other metadata about you to more uniquely identify you. Your date of birth, street address, perhaps even a general physical description -- all of these can help to disambiguate all of the identically named people out there. Debian can't use that, though, since that metadata isn't initially collected, and so it can't be rechecked later. This does suggest a bit of a solution, though. I said that Debian doesn't collect that info, but that's not entirely true. There is an optional repository of Developer contact details stored for other DDs to access, so we've got something to work from. The Developer updates their own details (whatever they feel comfortable entering). But, of course, people signing your key need to know about all that before they sign the key, so they can check (for example) your residential address and date of birth on your photo ID. You might ask "but how is the info the developer themselves entered accurate?", and that's a good question. The answer is that the legitimate developer entered that info, so if someone with the same name matches that data, then it's reasonable that it's still the same physical person. It's not a real good solution, though. Not all developers enter full metadata (and I can understand why they don't want to). People also often forget to update their details, too, which could quickly cause all sorts of problems. What is a good solution, then? We could always go with a bit of biometrics -- if there was any solution that was sufficiently cheap, reliable, and distributed enough to be used to identify 1,000 developers distributed across the globe to a reasonable standard of reliability. I'll wait for a minute while you finish laughing and wipe your eyes dry. I have to say, I'm stumped. I'd hoped, while writing this, that by the time I was finished I would have worked something out. But nope, it's a problem that's way beyond me. But I think I've got a much clearer handle on the problem space, so with a bit of luck, my subconscious (or someone else's) will eventually produce a sensible answer.

23 November 2005

Antti-Juhani Kaijanaho: The Finnish Criminal Court System

(Reposted from old blog) Inspired by Matthew Palmer’s writings (1, 2) on his experiences about the Australian judicial system, I decided to write a series of essays on the Finnish legal system, mostly to contrast it with the universally familiar United State system (even if that universal familiarity is a little skewed by generally having been obtained from dramatizations and not actual court practice). I will concentrate on criminal cases. I will write based on my personal experience as a part of the judicial system, and I will be supplementing the experience with my personal research into law. I am not legally trained, but I have read a fair bit of law and related literature. I am a lay judge in the Jyv skyl District court. I will explain the significance of that later, but I hope it suffices to say, here, that I have sat on the bench, as part of four-judge panels, since March this year, in ten sessions each a day long, and each containing at least two, usually four or five criminal cases. Some highlights: Later essays in this series: Fictional depictions of court cases in this series: Read more

22 November 2005

Matthew Palmer: Rhetorical Quiz No. 1

What does this shell fragment do?
 watch "iwlist scan  grep :off -B 5 -A 1"
I've only really learnt about the power of watch(1) in the last week or so. Me likee.

20 November 2005

Matthew Palmer: The Fun Never Stops With Ruby

Well, there's nothing like posting a really rubbish program to your blog to find out the right way to do it. Firstly, Philipp Kern has come up with another, even shorter version than his version I posted in the update to my original Ruby post, this time blowing me away with the strangeness of explicit casts in Ruby. Apparently, casting an input stream to an array produces an array with one-line-per-element, as in this example:
 STDIN.to_a.sort_by rand .each l puts l 
As Philipp warns, however: "Ruby is full of fun and power; one must watch out that the scripts remain readable". For a fairly toy example, this solution is still fairly readable, however I can see hair growing on this thing if your program grows large. Next, Pierre-Charles David showed his qualifications for becoming a co-author of the next edition of the Pickaxe (AKA "Programming Ruby: The Pragmatic Programmers' Guide"), with his example and explanation. He's kindly given permission for me to reproduce his e-mail in it's entireity, since it's too good to chop up:
Here is the shortest and most readable version of your "randomize stdin" script I can think of:
  #!/usr/bin/env ruby
  print ARGF.readlines.sort_by   rand  
 
ARGF is a special variable representing either stdin or, in the case where file names are passed on the command line, the content of these files (think of Perl's <>). ARGF behaves like an IO object (although I think it is not one). In particular, it responds to the #readlines method which splits the receiver's content into lines and returns an array. In other words,
  lines = ARGF.readlines
 
is the idiomatic way of doing
  lines = []
  while line = gets() do
    lines << line
  end
 
in your example. The next part (sort_by) uses a new form of the sort method, which I think is not documented in the Pickaxe. It implements the Schwartzian transform technique. In essence, a random number is associated to each element of the array, which are then sorted based on this index. As a general style remark, note that although Ruby supports "while" and "for x in y" loops, they are rarely used, in favor of iterators and/or higher order methods. For example, to gather all the input lines in an array without using readlines, one might write
  lines = Array.new
  ARGF.each_line    l  lines << l  
 
or
  lines = ARGF.inject([])    lines, l  lines << l  
 
Hope it helps, and welcome to Ruby!
Pierre, your explanation definitely helped, and I hope it helps others too. The third person to help me out is Decklin Foster, through a post in his blog. What particularly caught me about his solution was the neat demonstration of another feature of Ruby which I think I will really learn to love: the ability to dynamically add methods to an existing class. "Aiee!" I hear all the purists scream -- and I can see the potential for severe misuse, too. But, since every good idea seems to get deeply perverted, we may as well have some real useful features to pervert while we're at it. Decklin has the clever idea of adding methods to the Array class that shuffle the elements of the array in a random fashion. His code is beautiful in it's simplicity:
 class Array
    def swap!(a, b)
        self[a], self[b] = self[b], self[a]
        self
    end
    def shuffle!
        each_index do  i 
            j = i + rand(length - i)
            swap!(i, j)
        end
        self
    end
 end
He then goes on to rewrite my bumbling example in probably the most comprehensible manner I've yet seen:
 STDIN.readlines.shuffle!.each    line  puts line  
Decklin writes, "Now that is cool.". I couldn't have put it better myself. My thanks to Philipp, Pierre-Charles, and Decklin, for helping me along the Ruby path. So, two new Ruby Rules for me to live by: Hmm, is it possible that Ruby is nothing more than Functional Programming by Stealth? Aiee!

Matthew Palmer: The Other Ruby

One thing I neglected to mention about my recent forays into learning the programming language Ruby -- we've also very recently acquired a puppy by the name of Ruby. Our Cute Puppy The two are slightly interlinked. I've been planning on learning Ruby-the-language for a while, and we started planning on getting a puppy about a month ago. We were, of course, going through the name-picking, and it was my lovely wife who suggested the name Ruby. I thought it was a nice name, and we stuck with it. At the same time, I decided to dedicate my learning of this new language to our beautiful new pup. The only question we really have now is: what breed is she? The official word is "Staffordshire Bull Terrier Cross". But, of course, cross what? Anyone want to take a guess? We've put up a gallery of photos, and feel free to e-mail her and tell Ruby what breed she is.

Matthew Palmer: My First Time Mining Ruby

I'm not usually a grand fan of the latest and greatest fads'' in programming. The only C# I know is the black key next to D#, and I loathe coffee. An IDE in the hands of a poor programmer will still result in crap code. While I do think that agile methods (such as XP) can do well in certain development environments, I certainly don't subscribe to the notion that XP can solve all the world's software production ills. And so on. I do know quite a number of programming languages, and tend to pick up new ones out of intellectual curiousity (although Ada did put a severe dent in that habit) or because a bit of research tells me that the language might be particularly suitable for a particular task (although I've since learned that the actual purpose of PHP isn't dynamic websites so much as bringing the security levels of Linux boxes in line with Windows-led industry standards). I also learn languages because I want to hack on projects written in them, which is motivational, but not a particularly good way to get a deep understanding of a language. Why all of this introspection in a blog? So you have the background to understand how everything about Ruby is different for me, including how I'm getting started using it. I have no interest in hacking on a Ruby-implemented project, and -- although Rails proponents give me an impression similar to that of a horny teenager with a shiny new unlimited broadband account -- I don't have any particular use for Ruby at the moment (I want to write less webapps, FFS, not more!). So, why the hell did I fork out $90 hard-earned South Pacific pesos for a copy of "Programming Ruby: The Pragmatic Programmers' Guide"? A couple of reasons: I'm glad I got "Programming Ruby". The book is superbly organised, reads very easily, and gives you all of the love as and when you need it. Surprisingly for me and a technical book, I read the first section of the book "cover to cover". By the end of it, I came away with a real (if naturally superficial) understanding of the language, and a feeling that I was ready to tackle the world in Ruby. It is a sad state of affairs when the first piece of new programming you can sink your teeth into is some four days after finishing your initial studies into a language, but this afternoon I wrote my first Ruby program in anger. It's quite simple -- just take stdin and rewrite it all on stdout with the lines in a random order. But I wrote it in a new programming language, in about 3 minutes, with nothing more than ri (Ruby's answer to firing up python and typing help(xyzzy), more or less) and "Programming Ruby". I think I also produced a suitably reasonable result:
#!/usr/bin/env ruby
lines = []
while line = gets() do
	lines << line
end
	
while ! lines.empty? do
	idx = rand(lines.length)
	puts lines[idx]
	lines.delete_at(idx)
end
(Any Ruby afficionados out there, feel free to e-mail me and tell me what egregious sins I've committed). I think it looks reasonably neat and clean, it's certainly simple, and the use of real Object Orientation makes for a certain readability (I think the method call lines.empty? is particularly cute, although I did initially consider the use of a question mark in a method name to be a crime against humanity). So, will I be using Ruby more in the future? I think so. There are some features in Ruby which I'm hoping to get a lot more cosy with -- the idea of "blocks" looks particularly interesting, and I don't think the utility of languages that have been designed, top-to-bottom, to really live the OO ideal has been explored enough (you SmallTalk bigots can stop glaring at me now -- really, I mean it -- stop it!). It's far too early to tell whether Ruby will become my "go to" language for random development tasks, but anything that stops the nightmares (where I start thinking about using PHP as a general scripting language) cannot be all bad. And, if I continue to make new webapps, Rails will probably come in handy. Update: HTML <pre> tags don't like having < inside them unescaped. Also, Philipp Kern pointed out that the Ruby documentation browser is called ri (not ir as I originally wrote). Philipp was also kind enough to provide a much shorter version of my original script, which shows the power of Ruby so much better:
 lines = []
 STDIN.each_line    line  lines << line  
 lines.sort_by   rand  .each    line  puts line  
Now tell me that isn't a language worth using!

15 November 2005

Matthew Palmer: Arrr, it's Sonybeard the Pirate!

In what can only be described as a massive display of SCO-you-worked-on-Linux-2.7-grade stupidity, it appears that the infamous Sony shiny-disc-that-pretends-it's-a-CD DRM is not only bad for your computational health, but is in fact a copyright-infringing work, as it looks as though it contains chunks of the LAME MP3 encoder/decoder library. I don't think my commentary can beat what BoingBoing had to say on the matter:
Sony claims that it needs to install dangerous, malicious, underhanded software on its customers' computers to protect its copyrights, but in order to write this malware, it has no compunction about infringing on the copyrights of public-spirited software authors who make their works available under free software licenses like the GPL. I suppose it's natural to believe that everyone is at least as sleazy as you are: for Sony's rip-off artists, assuming that paying customers are planning to rip them off must come easy.
How can anyone even vaguely involved in the tech industry possibly believe that anything they write can't be popped open and peeked in, to find out what naughtyness they've done? The mind boggles. Sony, you are on my official shit list. It's a long and prestigious list, but you've managed to climb very quickly to the upper echelons. May the fleas of a thousand camels infest the nether regions of every Sony executive who may have had anything to do with this whole fiasco. The original article is available, and is quite informative. Yay for BoingBoing, also, who provide me with so much of my daily interesting news.

14 November 2005

Antti-Juhani Kaijanaho: The Finnish Criminal Court System

Inspired by Matthew Palmer's writings (1, 2) on his experiences about the Australian judicial system, I decided to write a series of essays on the Finnish legal system, mostly to contrast it with the universally familiar United State system (even if that universal familiarity is a little skewed by generally having been obtained from dramatizations and not actual court practice). I will concentrate on criminal cases. I will write based on my personal experience as a part of the judicial system, and I will be supplementing the experience with my personal research into law. I am not legally trained, but I have read a fair bit of law and related literature. I am a lay judge in the Jyv skyl District court. I will explain the significance of that later, but I hope it suffices to say, here, that I have sat on the bench, as part of four-judge panels, since March this year, in ten sessions each a day long, and each containing at least two, usually four or five criminal cases. Some highlights: Later essays in this series: See more ...

13 November 2005

Matthew Palmer: Working as a Witness

(A continuation of my reminiscences as an expert witness.) In an earlier post, I made brief mention of the unpleasant realities of being a witness in a trial. More details, ahoy! Most witnesses aren't allowed in the courtroom except when they're giving evidence (to avoid bias) and have to sit out in the hallway. Bring a fat book, because you could be out there for days. I don't think much compensation is provided for your time, either. And, as a final indignity, the lawyers might not even end up calling you to the stand. For example, one of the prosecution witnesses in the case I was involved with was called to appear, and sat outside the court for eight (count them, 8!) days, before being told he wasn't needed after all, and he could go home. I don't know about you, but if that had been me, I would have ended up in the dock myself on a charge of mayhem. Another witness, after having been through her time on the stand, made a comment along the lines of "I'm going to make sure I'm overseas next time". Expert witnesses (as I was) get treated a little better. We can watch most of the bantering in court, while we evaluate the technical evidence presented by other witnesses (experts and non-experts alike), and at least the pay is sensible. As an occupation, "expert witness" would be OK. The hours are pretty sweet, the pay is good, and the conditions quite reasonable. For a regular geek like myself, though, it was fairly close to agony by the end of it. I've had three big projects on indefinite hold while I was at court, unable to give my clients a firm date when I could resume work for them. They were all understanding, bless them, but I could have lost out badly. The complete uncertainty as to what is going to happen and when means that you basically end up camping out at the courthouse for umpteen days. At least, in my case, I was being paid regular consulting rates for my camping. When I say uncertainty, I really do mean it. I was originally told I'd be needed for a day or two -- a quick look at what the other witnesses were saying, maybe jump in the box for a bit, and then I'm off. Then the first witness in the stand was there for nearly three days (along with a day or two of procedural stuff in amongst it so I had been there a week before he was finished). Then the defence was going to make a motion for dismissal, because the prosecution were being pummeled by his honour for their lack of case preparation, so I would have been out of there. That never materialised. Then more procedural faffage, another witness that ended up in the box for about 4 days -- each day of which I thought was the last -- and then it was my turn, which lasted nearly four days. At no stage did I have any indication of when it was going to be over, either, so I couldn't say with any sort of certainty when I could start helping anyone else out. While the legal system has a vital part to play, I'm wondering if something could be done to improve the running of trials to reduce this sort of pummeling of witnesses. On the sweet hours: court convenes each morning at 10am. There's usually half and hour to an hour of transcription correction (although I get the impression that isn't a standard thing) then witnesses start going through. There's a half hour morning tea break around 11 or 11:30, and then an hour lunch at 1pm. Usually there will also be an afternoon break of 10 to 15 minutes, before court adjourns for the day at 4pm (if not a bit earlier). I presume that the reason for the short days is that it's mentally very tiring, and there's lots of prep work for the lawyers mornings and afternoons, but it's a lot better life when you've got none of that to do. Unfortunately, the day isn't short enough that I could get a lot of other work done, so it's effectively just a short-paid day.

Matthew Palmer: Snail Racing (The Legal System)

I previously mentioned in a sidenote to another post that I've been involved in a court case over the last few weeks, and I promised a few people I'd blog about my adventures there. Obviously, not quite everything can be discussed in an open forum, but I checked with the legal beagles and I'm OK as long as I stick to generalities. Which is fine by me, since the detailed specifics are actually immensely boring. Executive Summary: It's the law Jim, but not as the TV shows it. I have to recommend that everybody spend a bit of time watching a case or two at their local court. It's surprising how different reality is to what you see on TV (of course, Australian courts are going to be different to the US courts we primarily see on TV, but even the dramatic representations of Australian courts I've seen are fairly inaccurate). The legal system, while appearing to be out in it's own little world, is a vital and integral part of most societies, so it's useful to have at least a basic idea of what goes on in them -- not because you'll end up in one (and even if you did, your lawyer will tell you what to do) but because it's an interesting insight into a part of our world that often affects us, but we don't like to look at. (Going and watching your houses of parliament, or an abboitoir, is a similar thing). Second, if you can possibly avoid it, don't get involved in a case. Not as a defendant, not as a litigant (in a civil case), and not as a witness. Litigants and defendants get screwed because they're stuck in a small room with a bunch of people they don't know or particularly like, for days or months, with a limited understanding of what's going on. Boooooooring. For witnesses, it's a different kind of pain. But I'll leave the details of that for another post. One of the things that quite surprised me is the general good nature and decent relationship between all of the legal professionals involved. They're willing to help each other out, they concede points graciously, and there's a surprising amount of banter between all of the lawyers and (in some cases) the witness as well. I'm told that this was peculiar in my case because I was involved in a voir dire[1], and everyone's on their more formal behaviour when there's a jury in the room. At times, it was almost a pleasure to watch the proceedings -- like a slightly dry but nonetheless compelling play. Most of the time, though, I characterised as "Snail Racing" -- about the most dull activity one could imagine, but nevertheless you just can't tear your attention away in case something interesting happens while you're blinking. When I say that the lawyers are good natured, that's not to imply that they're not vehemently arguing their case. Toward the end of the voir dire, in particular, counsel for the defence started to get rather vocal as to the lack of proper procedure on the part of the Crown. Over the entire voir dire, too, both counsel were always pressing hard and always trying to get their case seen in the best light. But their vigourous pursuit of the case never got personal or competitive. I think that's actually something that a lot of free software people could take on board (myself included) -- argue strongly for your position, but never internalise it or make it personal. Your position may be rather important (the defendant in my case was looking at up to 14 years if he got sent down) but making it a personal attack isn't going to help your case. I was amazed at the speed with which counsel picked up on new concepts and ideas. Unsurprisingly, the expertise I provided was quite technical, and counsel were not particularly computer literate. However, over lunches, I was able to essentially brain dump fair chunks of knowledge at the barrister, and he then went inside and laid it all out, usually accurately and very good presentation. It's also intensely satisfying to know that the questions that are being presented were suggested by you, and the skillful way that the ideas and queries were weaved together. I guess you'd get a similar buzz writing a play and then watching skilled performers bring it to life -- not necessarily exactly the way you imagined, but with an undeniable skill and vibrance. I've got a lot more material about my adventures in the legal system, which I'll be posting over the next while, but I figure this is probably well enough to be going on with for now.
1. A voir dire (as explained to me) is a sort of "trial within a trial", used to determine a point of fact or the admissability of a particular piece of evidence. It is run in the absence of a jury. They're only supposed to run for a couple of days; apparently mine was extraordinary at three weeks, although mention was made of a six week marathon (in the context of "this better not be like $OTHER_VOIR_DIRE").

Matthew Palmer: Linking Does Not Create A Derivative Work

Ian Murdock's recent piece on the whole Debian/Nexenta controversy contained what is an almost-universal misunderstanding (so common, in fact, that I held the same misunderstanding myself until fairly recently) about what the GPL actually says about linking in other software with a GPL-licenced work. Ian writes:
It seems to me the argument that linking a GPL application to a CDDL library and asserting that that somehow makes the library a derivative work of the application is, to say the least, a stretch&emdash;not to mention the fact that we're talking about libc here, a library with a highly standard interface that's been implemented any number of times and, heck, that's even older than the GPL itself. It's interpretations like this, folks, that give the GPL its reputation of being viral, and I know how much Richard Stallman hates that word.
The core misunderstanding there is that the GPL somehow claims that libraries linked into a GPL-licenced binary are derived works. Nothing in the text of the GPL states that, and a quick scan of the GPL FAQ doesn't provide any opinions of that nature, either. What the GPL does state are a few conditions which you have to abide by in order to be given permission by the copyright holder to exercise rights ordinarily held exclusively by said copyright holder. One of those is that, in order to be given permission to distribute a compiled binary, you must be able to provide source code for the binary itself, as well as all interface definition files, build scripts, and modules contained in the binary, and that all of this material must be provided under terms no more restrictive than those of the GPL. The GPL isn't trying to lay a "derived work" claim on any of those other parts. It's just saying to you, as someone who wants to distribute a binary, "here are some other things that must be OK if you want to do this". A similar clause exists with regards to patents and court judgments (section 7, for those of you playing along at home). This doesn't mean that the GPL is attempting to claim that the patents or court judgments are derived works. A licence could also say "you must delete all copies of any Microsoft product from your hard drive before duplicating this software", but that wouldn't mean that the licence is attempting to claim that all Microsoft products are derived works of the licenced software! As anyone who's looked at a typical proprietary software EULA probably already knows, a software licence can claim pretty much anything (and, apparently, thanks to the DMCA, in the US they can make it stick). The licence doesn't make the claim on the basis of derivation, it makes it because that's just what the licence claims. The GPL is no different in that respect. If you can't fulfill the licence conditions (either because you don't want to, or because -- as in the case of the clause under discussion -- the module you are including in your binary can't be licenced under terms equivalent to the GPL) then you can't do whatever it is that the licence would otherwise allow you to do. To be fair to Ian, some of the comments he made to his blog post indicate that he does understand the distinction between a claim due to derivation and one due to a simple licence term, but I thought it worth making the point crystal clear to everyone out there in the blogsphere, because it's a very common misunderstanding, and I'd hate for it to spread any further than it has already.

12 November 2005

Matthew Palmer: Challenge/Response is Not The Answer

Telford, your comments to my previous article were quite helpful and I thank you for them. However, not configuring your Challenge/Response Authentication Program to accept mail from me when you previously sent one to me is decidedly less helpful.

11 November 2005

Matthew Palmer: Do we need a licence to *use* our software?

Note: All of this is specific to Australian law. Similar principles may apply elsewhere, but I've got no idea where, if any, they might apply. Also, I'm not a lawyer, nor do I play one on TV, and my writings here (and for that matter, everywhere else) are for entertainment purposes only. If swallowed, do not induce vomiting. In the middle of a cogitation this morning, my thoughts turned (as they occasionally do) to the much loathed EULA for Nobody's Favourite OS. As we all know, this EULA is pretty brutal in the things you agree to allow other people to do to your machine, and the rights you agree to give up. As I was, in general, thinking about issues of copyright law, the EULA got looked at through copyright-coloured glasses. And it was... weird. As we all (probably) know, copyright law is about limiting the actions that can be performed with a work of creation, and giving the author of the creative work the ability to be the sole arbiter of who can perform those actions. The Australian Copyright Council has a nice information sheet on Copyright and Computer Software if you'd like to get the full story. The set of actions which the Copyright holder has exclusive rights to is fairly well proscribed. The statement "All Rights Reserved" doesn't mean "every possible right is reserved", it means "those rights which I can control (by virtue of the legally-protected monopoly of copyright law) are reserved". As far as I can tell, there is no right which allows the copyright holder to control the use of the creative work. It's important to think about what "use" actually means. The Copyright Act and the above info sheet tend to apply the word "use" to include the act of making copies, as well as other dealings (protected or otherwise) in the copyright work, but that doesn't seem particularly useful for this discussion, because I can't think of another appropriate word to use to describe a non-copying action involving the work. So I'll stick with "use" for that, and go with "copying" for any duplication. Obviously, the type of work that we're looking at determines what "using" that work means. A book is read, or perhaps burnt for warmth. A picture is stared at. A computer program is run. I can't find anything in Copyright law that covers reading, burning, or staring, but section 47B of the Copyright Act 1968 (Cth) deals with the "normal use or study" -- basically, the act of using the thing. It says that users are allowed to copy the program into RAM to run it[1]. Goody. So far, it looks like there's no way the copyright holder can stop us from running our legally acquired copies. There are two flies in the ointment, though. The first is s47(2)(b) of the Act:
(2) Subsection (1) does not apply to the making of a reproduction of a computer program:
[...]
(b) contrary to an express direction or licence given by, or on behalf of, the owner of the copyright in the computer program to the owner or licensee of the copy from which the reproduction is made when the owner or licensee of that copy acquired it.
Aaaargh! Does this mean that the copyright holder can force a licence on us, against our will? I really don't know the answer to that. Hopefully, at the very least, the protections of contracts law[2] would apply to such licences. If licences can be treated as contracts, then they can be rejected. If the copyright holder can't restrict the running of a legally obtained copy of the program, then how can they compel the acceptance of a licence? One idea that comes to mind is the process of installation. That is neither an incidental nor an automatic copy, and hence doesn't fall under the allowances of s47. So, without the permission of the copyright holder, making an installation from CD to your hard drive would seem like an infringemnet. On the other hand, the installation program usually runs directly from (for example) the CD, and if it wants to make copies of other copyright material owned by the same person or company as part of it's ordinary operation, then who are we to stop it? But back to the idea of compelling acceptance. Looking at the XPToy Retail EULA for a moment, part of the agreement is that you agree to be bound by the terms by the action of installing, copying, or "otherwise using" the software. But if you don't agree to any of the EULA, I'm not sure how you can agree that you agree to be bound by the EULA by performing an action which the copyright holder cannot restrict you from doing. On the other hand, perhaps I've drunk too much of the GPL "You don't have to accept this licence, but nothing else gives you the right to copy this software" inplied-licence-acceptance kool-aid, and there is provision in law for licences to specify other positive means of signifying acceptance. I know that contracts can be accepted by written agreement between the parties, and with a suitable verbal exchange, so perhaps you can add "Installing, copying, or otherwise using" to that list. I wonder if "You agree to the acceptance of this agreement to give me your first-born child by blinking within 15 metres of me" would be valid? No, I didn't think so either. Does anyone know where the descriptions of permissible means of agreeing to a contract are defined in Australian law? To get back on track, let's assume for a moment that we can refuse the EULA. Can we still use the software? s47(2)(b) says we can't contravene licence terms, but if we can refuse the EULA then it doesn't look like there are any licence terms. So we're back to relying on s47(1), which says copying for running the program isn't a problem. If you can avoid accepting the EULA, and don't do anything otherwise naughty with the software, I can't see how anyone can have any complaint, in Copyright law, with your actions. Of course, the next trick is to avoid clicking-through the EULA "you accept" notice without falling foul of any other provisions, but if we've already knocked the paper-EULA on the head with contracts law or something, then I don't think that your click-through acceptance (coerced, as it were) is going to worth a hell of a lot more. I know the DMCA in the US did a lot to strengthen the power of click-wrap licences; perhaps those provisions got written into AusNSFTA. Of course, this whole thing is based around a lot of conjecture and a lack of real, detailed knowledge of the law. Perhaps there's even some bits of the Copyright Act I've missed. I'd be interested to hear your thoughts on the matter. Do we need a licence to use software we've legitimately purchased? I'm interested in your comments. E-mail me at mpalmer@hezmatt.org.
1. I'm not quite sure why this is so majorly different to a person with an eidetic memory reading a book, but I guess it's better to cover the issue to stop lawyers getting richer. 2. There's all sorts of goodies in contracts law, from what I recall -- prohibitions against coercive contracts, and contracts presented as a fait accompli (AKA "take it or leave it") without any ability or intention to negotiate. Certainly sounds like a EULA to me...

9 November 2005

Matthew Palmer: Redhat Considered Harmful

I try hard not to hate Redhat, I really do. I don't visibly grimace when someone says "I'm running $REDHAT_DERIVED_DISTRO", and my first solution to "I can't get this to work on $REDHAT_DERIVED_DISTRO" is almost never "just install Debian,Ubuntu ". But Redhat makes it so hard to not beat them with a stick. For instance, I'm working on building a SOE for a client, and so I've got a bunch of scripts (calling random poorly documented and hard-to-find utilities) to help me do that. Naturally, I'm pruning the package list, which requires me to rebuild the list of packages which are on the CD. No problems, I can handle that. Oh, but the tool that builds the package list can't deal with the correct "ordering" of packages in the list. Why is ordering important? Because, and this will make you laugh, the installer can't actually deal with dependencies. Yes, that's right, anaconda will install your packages in any old order you specify, regardless of what is actually needed. Brain-damaged, certainly, but I've dealt with Windows, so this is ultimately a minor setback. The tools for building the packages lists are in a certain package, which I dutifully install. They then proceed to fail horribly. Why, do you ask? Because the script requires python modules from another package. Gee, wouldn't be handy if there was a mechanism by which a package could specify that it needed another package to operate? OH WAIT, THERE IS -- IT'S CALLED DEPENDENCIES, FOR $DEITY'S SAKE! YOU WROTE THE GODDAMN RPM SPECIFICATION, REDHAT, WHY CAN'T YOU ACTUALLY USE SOME OF IT'S FRIGGING FEATURES! But wait, there's more! Installing the package which contains the module doesn't actually make the module accessable to anything else on the system, because the module is installed in some god-forsaken, out of the way location, where Python fears to tread. You need to specify PYTHONPATH to make it work. Apparently someone was sure that specifying absolute paths in scripts (instead of letting the system search it's environment) was a bad idea, but didn't have problem with not putting modules in standard, well-known locations. Then, of course, the (other) tool segfaults. Why? Because it's reading an empty file. Wow. An empty file causes this thing to fall over in a screaming heap. Not "Sorry bub, but your file's empty" just an unceremonious segfault. Wow. Thanks. And that's even before we get around to actually doing an install...

6 November 2005

Matthew Palmer: The Internet is Not What It Seems

James, while I understand your anger, it would seem as though Hetracil isn't a real product, and is just a (fairly elaborate and subtle) hoax. Resources:

Matthew Palmer: Cleaning The Barbeque

Hi everyone, my name's Matt and I'm a BBQaholic. Seriously, I love to cook on the barbie. It's outdoors, you get the best smells coming off the searing meat and vegetables, and you can quietly put away a cold beer in the name of culinary exploration. So, during a visit to the hardware store today, I was suitably interested when I saw a product called "BBQ cleaner". Curious as to what might be so fantastic as to advertise itself as a cleaning product specifically and exclusively for use on my favourite cooking utensil, I took a look at the back. The first item on the "How To Use" instructions:
  1. Put on rubber gloves.
And there I stopped. Anything that requires rubber gloves to the point of adding an item in the usage instructions specifically to that end (rather than, say, a general blurb saying "wear adequate eye and hand protection whilst using this product" which is standard on everything down to and including toilet paper) is *not* going anywhere near a food preparation surface in my household, Thank You Very Much.

4 November 2005

Matthew Palmer: When Technology Goes Wrong

A dramatic title for a not so dramatic post. The Sydney suburban train network runs several sorts of rolling stock. The newest of these are the much-maligned "Millenium Trains", which bring local train users (all 18 of them) into the 20th century. One of the features of these technological masterpieces is an irritatingly obsequious voice which announces the current and next stations on the train's journey, and an LED board displaying the same info. So far, so good. Of course, I was a little curious as to how the boards and little-miss-noisy were kept in-sync with where they were. I was thinking transponders, maybe something that the train guard did. Then, last week, I found my explanation. This train announced each station as being the preceding one. So, we'd stop at Central, l-m-n would announce "This train will stop at Museum". We stop at Green Square, l-m-n says "This train will stop at Central". And so on. At least the voice and the board were in sync, even if the voice and reality were eyeing each other off at quite some considerable distance... My goal now is to find a train which is announcing stations for the wrong line completely, rather than just one station behind on the current line -- but considering I only get these new-fandangled millenium trains a couple of times a week (they spend the rest of their time in the sheds being fixed, apparently) it may be a while.

26 October 2005

Matthew Palmer: A Licence to Use Your Genes?

Science magazine (by way of Boing Boing) reports that "20 percent of human genes have been patented in the United States". As the Boing Boing article's title says, "20% of your genes are belong to them". So, it seems to me, that there are two reasonable courses of action:
  1. Attempt to get the USPTO to accept a claim of prior art, since you've been doing this gene thing for quite a bit longer than whoever filed the patent. This is probably doomed to failure, since the USPTO appears to be collectively sticking it's fingers in it's ears and singing "Mary had a little (cloned) lamb" any time anyone mentions such inconveniences as "prior art", "obviousness", or any of those other pesky impediments to granting a patent.
  2. Apply for a licence from the rightful (hah!) holder of the patent, to duplicate, use, and distribute (well, for some of us) the patented "technology". To be helpful, when you send your letter requesting a patent licence, you should also include a list of the names, addresses, and home telephone numbers of people in your local area who you honestly believe to also be infringing on the patent.
I wonder what the effect of a patent holder not responding to your request for a patent licence would be? In a fair world, I would expect the patent holder's ability to later enforce the patent (at least against you) would be diminished -- but in a fair world, this particular blog post wouldn't be written. So, what happens if the patent holder denies you a licence to use their patent? Well, I would imagine you must cease and desist from any use, reproduction, or distribution of the patented technology. I can see the headlines now: "$PHARMECEUTICAL_COMPANY demanded that I kill myself". Maybe a few people who would prefer the eternal sleep could do it, just to make the point. But even without that, the effect of a few thousand licence requests (received with local phone books attached) should be appropriately entertaining to watch. This whole "patenting the human genome" thing almost makes me want the whole "Intelligent Design" thing to come out in favour of the Christian Fundies. If courts were to rule that there is a reasonable belief that God (or some other convenient Deity) did in fact design us noisy bipeds, then that would, surely, count as a fairly obvious prior art claim. For that matter, what if these drug companies are infringing on a celestial patent on the human genome? An omnipotent being capable of changing the heavens and the earth isn't someone whose patents I'd want to infringe.

24 October 2005

Matthew Palmer: Could *you* pass 8th grade math?

Apparently, I could: You Passed 8th Grade Math Congratulations, you got 10/10 correct! Could You Pass 8th Grade Math? I'd kind of hope I could pass 8th grade math, though -- I'd be quite ashamed if all of those hours sleeping through MATH187 lectures were wasted... I'll tell you one thing the people who wrote the quiz didn't pass, though -- standards-based Web Design 101. It's some downright hideous HTML they generated for the results page. I've tidied it up a lot, but it's still not particularly satisfying. Ugh.

Next.

Previous.