Blog

String Formatting in Grace

There are many places where programs written using grace seem to be syntactically closer to languages like Python than to C. String formatting used to be not one of these places. Historically, formatting text with dynamic elements within grace was a matter of using either string::printf() or file::printf(). These are C-style printf formatters, which means they accept a variable argument list consisting of a ‘format string’ and one or more integer or pointer arguments. When dealing with value and string objects, this means liberally using explicit casts like cval() and ival() to convert those to printf-compatible types.

The library version inside the repository now supports a friendlier way of going about things, one that does away with all the explicit casting in the form of the %format pseudo-keyword. In its most simple incarnation, it works mostly the same as a normal printf formatting operation, except that it can deal with any objects that can be cast to value:

  string test = "%i bottles of %s" %format (99, "beer");

One level up on the funky scale is referring to positioned arguments:

  fout.writeln ("<%s>%s</%{0}s>" %format ("str","foo"));

Finally, you can access children of the first argument like this:

  value v;
  v["name"] = "John Smith";
  v["email"] = "j.smith@example.net";
 
  fout.writeln ("%[name]s <%[email]s>" %format (v));

This way of formatting, apart from being more flexible and less sensitive to formatting-related security problems (since it doesn’t need to follow arbitrary pointers), adds a lot of clarity to your source code, which is a major plus for keeping up maintainable code.

august releases

Hi!

Last week we released new alpha packages to our group of testers, both .deb and .rpm packages. See the changelog for a list of what’s new and great!

HTTP on Unix sockets with Python

Initially I had a more elaborate version based on the exact connect() code in the higher class, but this simpler version works just fine. Incidentally what the xen xm commandline tool uses works identically ;)


class UHTTPConnection(httplib.HTTPConnection):
    """Subclass of Python library HTTPConnection that uses a unix-domain socket.
    """
 
    def __init__(self, path):
        httplib.HTTPConnection.__init__(self, 'localhost')
        self.path = path
 
    def connect(self):
        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        sock.connect(self.path)
        self.sock = sock

This small hack plus the fine PHP serialization classes from Scott Hurring are the basis of OpenPanel.coreclient, which allows for very easy provisioning and querying of OpenPanel/opencore data. We use it mostly for unit testing.

we’re not dead!

Although this blog has been awfully quiet, we have not been idle at all. Since the alpha release a few more alpha releases have happened and many alpha testers have provided us with valuable feedback.

Current projects include:

  • a unit testing framework for opencore and all modules; in the process of building this, many bugs have been uncovered!
  • lima, our own mailinglist manager, because the state of open source mailinglistsoftware when considered in a virtual hosting context is sad
  • wasp, a tool to manage web applications for individual users, with upgrades (including forced global upgrades eventually)
  • massive work on the GUI to get it stable and mature

We intend to release a full public beta within Q3; watch this space!

London!

In a few minutes Liessa and me will be heading off to London to celebrate our 5 year anniversary. We’ll try to do some posts over the weekend; Liessa will post photos after the weekend :)

[Turn AirPort Off]

[Turn AirPort On]

We landed safely :)

dell 1950 quadcore fuckage

You buy a fat PowerEdge 1950 from Dell, with a dualcore Xeon in it. A few months later you decide your box is not quite fat enough so you ask Dell for a quadcore Xeon to stick in -your- 1950. You know, the one they have on file for support and all.

You upgrade the BIOS because the stock 1.0.1 stuff doesn’t do quadcore yet. You shut down your box (customer downtime!), replace the CPU, turn box back up. BIOS reports quadcore CPU, all seems well. SCSI bios comes by, PXE bios comes by – but then: `Unsupported CPU combination! System halted!’

Fuck you, Dell. Fuck you and the horse you rode in on.

Update [May 18]: Dell stated that (a) besides the BIOS the BMC needs an update too (b) that our hardware revision is -certainly- new enough to accomodate the quadcore. So, we did the upgrade, put the quadcore in, same error. Some digging revealed that new 1950 revisions are marked on the frontpanel with a Roman 2 (II) – ours turns out not to have that marker. Moral of the story: do not ever believe what a Dell support drone tells you. Fuckers.

stuffit expander free download

The stuffit folks want to spam you; if you don’t want that, just use this download link.

break it down

Cyanide and Happiness, a daily webcomic
Cyanide & Happiness @ Explosm.net

Sharing NFS With a Group of Macs

This problem may sound familiar to some people: You have an office (or a livingroom) filled with Macs and you want to share a common NFS volume from a linux machine that all OSX users can access. Linux’ kernel nfsd doesn’t support uid/gid-mapping beyond its rather tame idea of uid-squashing: mapping all file access over NFS to a specific userid and groupid combination. Although this sounds like a sensible approach for such a shared volume, unfortunately the OSX Finder is trying to be way too smart about things and will block any operations on a volume if the permissions look wrong. What this means is, if you use all_squash to map all access to, say, uid/gid 100/100, the Finder running for a user under uid 501 will refuse to copy files to the share, even while the NFS server will permit this.

So for months we resolved to just making sure everybody was running under the default userid 501 assigned to the primary (or actually, first created) user of an OSX system. This, of course, is unworkable for machines that have multiple accounts (onlyl the account with userid 501 will allow proper access to the share).

Then I ran across this post, documenting that the uid/gid combination of 99/99 is magic to OSX and the Finder: it will automatically map the ownership of a file/directory with these properties to that of the user that is currently looking, so problem solved. By exporting an NFS volume like this:

(rw,insecure,all_squash,anonuid=99,anongid=99)

we no longer have to muck around making sure everybody has uid 501.

Ubuntu 6.10 /etc/motd

Up to and including Ubuntu 6.06, /etc/motd was managed similarly to FreeBSD’s: replace one line to note some information about the kernel, leave the rest of the contents alone. That way, an administrator can edit the motd anytime he likes and users will see the new version the very next time they log in.

Ubuntu 6.10 takes a different approach: /etc/motd is a symlink to /var/run/motd, which is at boottime generated from uname output+/etc/motd.tail. Upside: /etc can now be a readonly mount (I’m assuming this is their rationale). Downside: updating the motd without rebooting means applying the same edit to two different files equally. Bah. The manual pages do not mention this at all, too.

At least FreeBSD has /etc/rc.d/motd which you can run; in Ubuntu the motd magic is hidden in the middle of /etc/init.d/bootmisc.sh which also does things like backup your dmesg. Not very flexible.

Ubuntu workaround: remove the symlink; tough luck for the uname gnomes.