2012-08-10

Lua output redirection

While ago I was working on Lua based implementation of the scripting library. One of the requirements was a total control of output and error messages, to allow it's automatic handling. One of the issues I've faced is that some output was going to stdout even if there is redefined print Lua function.

I thought about two quick solutions:
- redirect standard streams;
- redefine printf and it's adjacent functions.

Since standard streams, both stdout and stderr, in my case were already redefined (for remote debugging purposes), I didn't had much to choose from.

Looking into Lua 5.1 sources, I've found that stdout was simply hard-coded in some places. During up-streaming this patch to Lua 5.2 surprisingly most of the hard-coded stream names went away, and it looks like it would be possible to use redefined print without losing anything. I haven't tested this though. Following just works for Lua 5.1.x and above.

2012-08-08

Manually adding missing apt public keys

When apt-get update starts complaining about missing public keys, it's always pain in the ass when you're behind proxy and gpg --recv-keys doesn't work. Following is the manual way of adding missing apt public keys:

1. Obtain public key via browser:
http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x[KEY]
2. Save the key.
3. Import the key file in System->Administration->Software Sources