I’ve been working on enum again recently and got completely stuck in getopt_long() return values. I don’t want to bore you with details, so let me cut to the chase: I needed a way to look into what getopt_long() is actually doing.

Now, there are a few ways to figure out the doings of a function. If it’s your own code, you could just go ahead and add a few printf()s to see if your variables fill up as intended. Then you could use gdb to walk through your running code. But what if you want to do so in functions outside the scope of your own code? In my case: getopt, i.e. libc?

Obviously, you can download the library, add your printf() stuff, compile and install it, and see it all happening. But libc isn’t exactly small, fast-compiling, and you really don’t want to mess it up and have it installed on your system. So how about just taking what you actually care for and push it in? This is nothing experimental or particularly “hacky”. I just don’t want to forget about it and maybe someone can make use of it. So here we go…

Download your libc sources to a new directory and copy the files you need. Try something like

mkdir -p /tmp/getopt/mygetopt
cd /tmp/getopt
apt-get source eglibc
cp eglibc-*/posix/getopt* mygetopt/
cd mygetopt

Now write up a primitive Makefile:

all: libmygetopt.so

libmygetopt.so: getopt.c getopt1.c getopt_int.h getopt.h
	gcc -shared -Wl,-soname,libmygetopt.so.1 -fPIC -o libmygetopt.so.1.0.0 getopt1.c getopt.c
	ln -s libmygetopt.so.1.0.0 libmygetopt.so.1
	ln -s libmygetopt.so.1 libmygetopt.so

	$(RM) libmygetopt*

In order for this to actually work, I fiddled around with a few #ifdef’s in getopt.c. But that’s something you’ll probably find out yourselves. You should at least be able to compile it (‘make’ it). Now put a printf statement somewhere in the function you want to inspect. Recompile the lib and then go back to your actual program.

Running the program ist easy.

src/enum -p1 1 3

Surprisingly, running it using your own getopt version is just as easy. Just push your library in:

LD_PRELOAD=libmygetopt.so LD_LIBRARY_PATH=/tmp/getopt/mygetopt:$LD_LIBRARY_PATH src/enum -p1 1 3
Yo, Ulrich, my getopt version is waaaay cooler than yours!
Yo, Ulrich, my getopt version is waaaay cooler than yours!

If you’re disappointed now, that’s your own fault. I said it in the beginning, this is nothing special. It’s not my idea. It’s something that developers all use all the time … or something like that. In case you didn’t know about it, good for you. Otherwise, sorry for reading my memory dump.

Since there have been a few blog posts about GNOME 3 already, I’m sure you don’t mind me adding one. I’m one of those who don’t do any work, just lurk around and wait for stuff to be fixed — or working in the first place. I also don’t like compiling GNOME myself. I barely touched the already packaged stuff in the repository of our Debian GNOME packaging team. But I run unstable plus stuff from experimental. I’ll thus have a bit of a different experience with GNOME 3 than current testing users who at least in parts don’t seem to like what they’re getting.

That being said… I love it.

No, I don’t mind running network manager on my systems, I even have it on my netbook (Atom processor). I used wicd for a long time because network manager really got nothing done back in the days (half a year ago or what :)). Nowadays, since version 0.9, it works fine for me. No fiddling around with config files, perfect integration in the desktop, and LAN and WLAN Just Work [tm].

No, I don’t like if some weird dependencies dictate what tools to use. I usually used pidgin for messaging, for instance. Now I’m using empathy, simply because it’s best integrated in GNOME. And no, I won’t switch from mutt to evolution. :-P

And there are more such cases. Also, these weird accessibility tools that are stuck in the gnome-shell “top panel”, I don’t need them. Still there. (There’s an extension to remove it, by the way.) Also, I must say, GNOME 3.2 is a lot better than 3.0 already. And I think 3.4 might do the final trick for me.

Fact is, with GNOME 3 I have a much cleaner desktop, there is more room for windows (which is nice on a netbook display), there are web apps which I already use a lot, and it has a professional, not too playful look (i.e. a few effects, clear and consistent theming, no bubbling windows). And the new notification stuff is just awesome, especially with the empathy integration.

Oh, and too many mouse click to access an application? 1) Put your most used apps in the favorites bar (or whatever it is called); it’s just one click then. 2) Press your meta-key (that way our name for the windows key, or was that the ESC key? Whatever, press your windows key), type in the first two or three letters of your application, and hit enter; you don’t need a mouse at all.

There. It had to be said. :)

Using zsh as default shell is perfect. Using grml-zsh stuff to configure it, even better. Using XTaran’s config, way better. Using your own config, invaluable. Now, there is one thing that always bothered me: having all hosts I usually deal with in my ~/.ssh/config in order to have tab completion (and short names). I wanted to improve the situation and was kindly pointed in a different direction by Myon, namely to just use the ~/.ssh/known_hosts for tab completion. How about that?

I started playing around with the config and, as it turns out, Axel already has something ready. Unfortunately, it didn’t fulfill all my needs yet. That is because I have multiple known_hosts files. Martin already filed a bug to have ssh read ~/.ssh/known_hosts.d/* but that isn’t resolved yet either, even though upstream is aware of it. I thus had to point tab completion and ssh to multiple files by hand. But that’s not too bad for now. Let’s have a look:

Host *
        HashKnownHosts no

Host *.your-work.com
        User that-is-what-they-call-me-at-work
        UserKnownHostsFile ~/.ssh/known_hosts.work

Host *.debian.org
        UserKnownHostsFile ~/.ssh/known_hosts.debian

What am I doing? Well, we need to deactivate the hashing of known hosts. Otherwise your known_hosts files aren’t readable as needed. Then you define your known_hosts files for the domains you care about. Pretty straight forward.

Now, how about tab completion in zsh? Well, easy part actually:

[ -f ~/.ssh/config ] && : ${(A)ssh_config_hosts:=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}} [ -f ~/.ssh/known_hosts ] && : ${(A)ssh_known_hosts:=${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*}} [ -f ~/.ssh/known_hosts.work ] && : ${(A)ssh_known_hosts_work:=${${${(f)"$(<$HOME/.ssh/known_hosts.work)"}%%\ *}%%,*}} [ -f ~/.ssh/known_hosts.debian ] && : ${(A)ssh_known_hosts_debian:=${${${(f)"$(<$HOME/.ssh/known_hosts.debian)"}%%\ *}%%,*}} zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts $ssh_known_hosts_work $ssh_known_hosts_debian

What's here? We read and parse your ~/.ssh/config for configured hosts, then we parse all your known_hosts files which are for me: ~/.ssh/known_hosts, ~/.ssh/known_hosts.work, and ~/.ssh/known_hosts.debian. And lastly, all is added to zsh completion for hosts. That actually works. :)

Axel, that makes a diff for you looking like this:

diff --git a/zsh.d/70-completion b/zsh.d/70-completion
index e92e068..5abf5cc 100644
--- a/zsh.d/70-completion
+++ b/zsh.d/70-completion
@@ -8,6 +8,8 @@

[ -f ~/.ssh/config ] && : ${(A)ssh_config_hosts:=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}} [ -f ~/.ssh/known_hosts ] && : ${(A)ssh_known_hosts:=${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*}} +[ -f ~/.ssh/known_hosts.work ] && : ${(A)ssh_known_hosts_work:=${${${(f)"$(<$HOME/.ssh/known_hosts.work)"}%%\ *}%%,*}} +[ -f ~/.ssh/known_hosts.debian ] && : ${(A)ssh_known_hosts_debian:=${${${(f)"$(<$HOME/.ssh/known_hosts.debian)"}%%\ *}%%,*}} -zstyle ':completion:*:*:*' hosts $ssh_config_hosts $ssh_known_hosts +zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts $ssh_known_hosts_work $ssh_known_hosts_debian

Care to merge?

Oh, and before I forget... Of course you don't need to check each and every host by yourself. Debian provides ssh keys for all hosts on master. Just do a

scp master.debian.org:/etc/ssh/ssh_known_hosts ~/.ssh/known_hosts.debian

and I'm sure, your security aware employer has such a file for you as well. Doesn't he? ;)

It’s the time of the year again. LinuxTag is right up and, of course, Debian is part of it. But, it wouldn’t be us if we didn’t have any problems at all. Well, the situation isn’t real bad™ but could deserve some improvement. Improvement about what, you ask? Isn’t that obvious? It’s man power that we need (women shall feel included :)).

Now, LinuxTag 2011 is going to happen, with or without you, on May 11th to 14th. Needless to say that you’ll be missing quite a lot if you don’t attend. I mean, even Zack will be there. And so will I (most probably at least). And even more… Who’s willing to miss that, really? So, pack your stuff, get a train ticket or your car or your friend’s car or the car of a friend of your friend who knows a friend who doesn’t know you but still wants to give you his car which you don’t even need since you already have the car of that friend of your friend and now you have two cars and can even bring another bunch of fellas who probably own cars themselves and now you’re thinking about the environment because of all the cars that will come to Berlin and because of that you suddenly buy a train ticket and leave all three cars at home… and in the end only one thing counts: you’ll be there. Oh, and before you drive off to your local train station, please put your name into our neat little list so we can count on you as booth staff — that’s because we need man power in case you missed that section or somehow forgot it while thinking about that guy who is the friend of your friend that owns a car but rather comes by train as it saves the environment.

Dear lazyweb,

I’m using Gnome for quite some time now and I’m always satisfied with the interfaces I have to whatever I need. There is one thing, though, that I miss: a calendar. I don’t like evolution, I don’t need another mail client. What I want is a simple, yet sophisticated application that I can put appointments in and which reminds me of them (recurring issues should be possible, too). It may but doesn’t have to be somehow attached to the Gnome clock or whatever. Though I expect it to look “Gnome-like” and be accessible from the panel. Do you know such? And is there even a Debian package for it?


In einer Zeit, in der förmlich alles im Internet abgehandelt wird, in der die Sekunden schneller gehen als je zuvor, in der die Menschen keine Zeit mehr haben, auf ein persönliches Treffen zu warten oder kurz anzurufen; in einer Zeit, in der man nur schnell mal was fragen wollte, um dann schon zum nächsten Tagesordnungspunkt überzugehen; in einer solchen Zeit beschloss ich, eine Freundin nach der Telefonnummer von ihrem Frisör zu fragen, die ich von anderer Quelle nicht in Erfahrung bringen konnte, denn, wer mich kennt, weiß, dass ich das mal wieder nötig habe. Leider war meine Frage wohl zu lang, um über den Facebook-Chat zu wandern, also schrieb ich sie ihr in einer Facebook-Message. Dabei hab ich mich extra kurz gefasst:

Liebe Zeitgenossin, mir ist zuweilen vorgetragen worden, dass, und solches stelle man sich ersteinmal vor, obgleich doch es wenig überraschend ist, bedenkt man, um wen es sich handelt, du ganz im Gegensatz zu ihr im stolzen Besitze dessen bist, das mir zueigen gemacht sich gar lohnen würde, wenn auch der Ausgang des angestrebten Unterfangens noch umnachtet, will sagen: in greifbarer und dennoch unklarer Ferne zu liegen scheint. Aus diesem Grunde nun würde ich meine Verbundenheit zu deiner Person außerdordentlich zum Ausdruck bringen wollen, wenn nun du, so deine bezaubernde Güte es zulässt, mir unter die Arme greiftest, um mir zu geben, was sie mir nicht geben konnte angesichts ihrer erstaunlichen Besitzlosigkeit. Was dieses etwas, dessen ich mich ermächtigen will, nun ist, wird deinen Geiste wohl beschäftigen, und es liegt mir fern, mich der Werkzeuge verbaler Folter zu bedienen, um zu spannen, was zu spannen sich nun nicht mehr gehört. Es liegt mir nämlich zweierlei am Herzen: zum einen, deine unermässliche Güte und Zuneigung nicht zu strapazieren, zum anderen, mein Anliegen einer Endgültigkeit näher zu bringen. Daher möchte ich darum bitten, holde Maid, dass du mir an ihrer Stelle die Ehre erweisest und mir mitteiltest, wie die Nummer derjenigen, die deiner Kopfbedeckung ständig so zuträglich ist, lautet, sodass ich mit ihr eine Unterredung und mögliche Behandlung meines dir bekanntes Dilemmas vereinbaren kann. Ich hoffe, selbiges liegt so weit auch in deinem Interesse, dass du mir diesen Gefallen nicht abschlägst und mich so zu einem glücklichen Freund an deiner Seite machst, der, wie angedeutet, tief in deiner Schuld stünde.

Countless times already have I used Google’s amazing feature called maps. Admittedly, if you know me, you might wonder how I can be advertising Google. At least as often as I used google maps, I have told people about google’s evilness. They’re making their users transparent in ways most people can’t even imagine — transparent to other users (just like Facebook does) but, more importantly, transparent to themselves and their advertising customers. Technically skilled people reading my blog probably just nod and scoll down now… :) Well, there still is something about Google that makes me use their developments: they are good. I don’t know any other online service to create own maps, get directions etc. with as much detail and huge amount of data as google delivers. Thus, Google maps became my main source for locations and directions world wide. As such, I wanted to use it to get directions between places in Berlin, Germany. Apparently, Google’s software had some kind of hick up or whatever, though. They got the directions right but somehow I doubt the map is anyhow related to what I requested. See for yourself…Google maps irritatedYes, yes, no software is perfect… but still :)

Since thousands of people seem to like RSA keys these days and my key is “old” anyways, I thought: how about running where the other lemmings run… So, here it is, my transition to a new gpg key. A properly written transition document is to be found here, obviously signed by both the old and the new key. I’d appreciate signatures if your signing policy allows (and you’re not insanely signing anything that looks like it could be signed).

Been playing with that thought for a while now, finally got to rebuilding it for lenny, now I’m using it… tmux is the new screen. To have fun already I read a few short introductions and got myself a few suggestions for a proper .tmux.conf. So, for root I have this one now:

# Copy mode
unbind [
bind Escape copy-mode

# Use Vi mode
setw -g mode-keys vi

# Make mouse useful in copy mode
setw -g mode-mouse on

# More straight forward key bindings for splitting
unbind %
bind | split-window -h
bind h split-window -h
unbind '"'
bind - split-window -v
bind v split-window -v

# History
set -g history-limit 4000

# Terminal emulator window title
set -g set-titles on
set -g set-titles-string '#S:#I.#P #W'

# Status Bar
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-left '#[fg=green]#H#[default]'
# no line break here, it's just to long for my blog layout!
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]'

# Notifying if other windows has activities
setw -g monitor-activity on
set -g visual-activity on

# Highlighting the active window in status bar
setw -g window-status-current-bg red

# Clock
setw -g clock-mode-colour green
setw -g clock-mode-style 24

# Create a default session
new -n htop -d htop
setw -t htop monitor-activity off
neww -n aptitude -d aptitude
neww -d

Then I added a new alias to my user’s zsh config:

alias root='su -c "tmux attach"'

Why ‘tmux attach’? Because tmux would start a new session which I don’t want it to. The config already starts a session which we can immediately attach to. Also, when such session was started I can attach to it as a user with the very same command over and over again. That makes it pretty handy as I always have htop, aptitude and a free shell available in a nice tmux session. Great. How did I live until now? ;-)

It’s pretty off topic for my blog since I usually only blog about technical stuff. But this is just great. Real life people having a real look at concerts of prominent and not-so-prominent musicians. And it’s all in German which is a nice thing since most of such stuff I have to find on English web sites (except the obvious German big press influence). Made me notice I missed the concert of Jamie Cullum — of course. But the article is quite nice and I definitely enjoy reading more of those. Have a look if you’re as keen on music as I am, or not. :)

https://blog.jhr-online.de/feed/">Entries (RSS) and Comments (RSS).
Powered by WordPress. Theme Evanescence.