Today’s sysadmin tip: ipsort – sort text by ip address

March 25th, 2014

Quite often, I have a list of ip addresses or networks available as an output from a list or a script, and would like to sort them based on the address. The usual unix sort -n does numerical sort, so the list often becomes almost correct

$ (echo 192.168.1.1; echo 192.168.10.2; echo 192.168.2.10) | sort -n 
192.168.10.2
192.168.1.1
192.168.2.10

But grep has a few tricks up its sleeves. Numerical sort by field:

$ alias ipsort="sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4"

$ (echo 192.168.1.1; echo 192.168.10.2; echo 192.168.2.10) | ipsort
192.168.1.1
192.168.2.10
192.168.10.2

Nice, isn’t it?

Today’s sysadmin tip: Latest rpm changelog entry

March 13th, 2014

Nothing special today, just a small script that shows (only) the newest changelog entries from the latest installed version of a package, optionally only showing security entries. Especially useful for multiversioned packages, like the kernel.

latest-changelog script may be downloaded here.

Example run:

latest-changelog: Shows the most recent changelog part of the latest installed package given

Usage: latest-changelog [-s] package | [-h]
Options:
  -s | --security : Filter out security information
  -h | --help     : This message

Example: latest-changelog -s kernel

[ingvar@thijs ~]$ latest-changelog -s kernel
- [exec] ptrace: fix get_dumpable() incorrect tests (Petr Oros) [1039486 1039487] {CVE-2013-2929}
- [net] ipv6: fix leaking uninitialized port number of offender sockaddr (Florian Westphal) [1035882 1035883] {CVE-2013-6405}
- [net] inet: fix addr_len/msg->msg_namelen assignment in recv_error functions (Florian Westphal) [1035882 1035883] {CVE-2013-6405}
- [net] inet: prevent leakage of uninitialized memory to user in recv syscalls (Florian Westphal) [1035882 1035883] {CVE-2013-6405}
- [net] ipvs: Add boundary check on ioctl arguments (Denys Vlasenko) [1030817 1030818] {CVE-2013-4588}

Protected: Mythopoeia (norsk)

January 27th, 2014

This post is password protected. To view it please enter your password below:

Today’s sysadmin tip: Finding what binaries to restart revisited

January 20th, 2014

Almost exactly two years ago, I posted a perl script to find what binaries to restart for Red Hat based systems. I digs a bit deeper than the excellent needs-restarting script that is provided by Red Hat, by running ldd on the running process binaries, and recursively checking all underlying libraries. I did an extra variant for Debian and derivates today.

Why is this necessary? Because processes may map libraries without opening them. If the underlying library is updated, needs-restarting (or checkrestart on Debian, Ubuntu and derivates) won’t list the process as need to be restarted. But the process may crash or behave strangely when it some time in the future opens a mapped library, and that library has been changed by an update.

And yes, this is a real problem, experienced on production systems.

Red Hat variant
Debian/Ubuntu variant

Qiu Xiaolong: År i Rødt Støv

December 31st, 2013

Dette er en ganske vidundelig liten bok. Historien om Kina under kulturrevolusjonen er storslagent tragisk og grusom. I denne boka har forfatteren gitt rom for de små fortellinger i stedet. Rødt Støv er en liten gate i Shanghai. Vi får glimt fra hverdagslivet i gata gjennom korte historier og glimt gjennom femtiseks år. Hvert kapittel er en som en selvstendig liten novelle, og åpner med gatas siste veggavis for det året.

Her blir hverdagskina tryllet fram gjennom muntre glis, sorg og savn, og besk humor, gitt i akurat passe små porsjoner til at vi rekker en på sengekanten, eller mellom stasjonene på banen. Litt visere blir vi også. Anbefales svært varmt.

Boris Akunin: Kroningen

December 31st, 2013

Moskva, 1896. Tsar Nicholas II skal krones, og det planlegges stor festivitas og en masse selskapligheter med svært celebre gjester fra hele verden. Afanasi Zjukin, overkammerherre hos storhertug Georg Alexandrovitsj får vanskeligheter når et medlem av famlien, selve lilleprins Mikail, tsarens fire år gamle nevø, blir bortført foran øynene på guvernanten, familien, og Zjukin selv. Ikke helt tilfeldig er Erast Petrovitsj Fandorin på pletten, og sammen med sin japanske tjener Masa jager han bort kidnapperne, men ikke før prinsen er forsvunnet. En internasjonal forbryter i mesterhjerneklasse, dr. Lind, tar på seg ansvaret, og forlanger den største løsepenge som kan tenkes; selveste Orlov-diamanten, en av de største skatter i Russlands skattkammer, og et avgjørende element i Tsarens septer, som selvsagt skal brukes under kroningen. Her haster det altså.

Dette er god underholdning, såklart. Det er det alltid med Fandorin. Men samtidig vet jeg ikke helt hvordan jeg skal plassere boka. Boris Akunin har pleid å leke med genrer. En bok er som James Bond, en annen som Agatha Christie, en tredje er et historisk krigsskue, en fjerde er en terrorist-thriller, osv. Men her peker det litt i alle retninger. Stakkars Zjukin blir fremstilt som en litt pompøs klovn der han går helt opp i rollen som overkammerherre. Noen steder går det nærmest over i farse, med elsker-i-skapet-scenen, velkledde herren detter-i-søla-scenen, velkledde-herrer-blir-kledd-opp-i-drag-scenen, velkledde-herrer-skal-kjøpe-undertøy-til-damen-scenen, osv. Samtidig beskrives Moskva og stemningen i byen tilsynelatende historisk korrekt, og det gjør den straks mer interessant. Boka tar f.eks opp i handlingen Khodinka-tragedien, der hundrevis av mennesker ble trampet til døde ved et arrangement til kroningen.

Leseverdig, og litt spennende innimellom. Hvem som egentlig er skurken gjetter leseren ganske tidlig, og Fandorin og Zjukin er kanskje i overkant trege med å forstå sammenhengen. Men hvem som står igjen levende og død til slutt er ikke avgjort før på nest siste side.

Kan trygt anbefales

Chris Tvedt: Av jord er du kommet

December 31st, 2013

Edvard Matre er etterforsker ved KRIPOS. Han blir kalt ut til et underlig drap på Finnskogen. En eldre mann blir funnet henrettet med rifle. Han har vært død lenge, og bortsett fra en datamaskin med barneporno finnes det ingen spor i saken. Matre og teamet hans blir etter noen ukers famling tatt av saken, og får noe så sjeldent som en seriemorder i Bergen å ta hånd om. En sinnsyk morder tar livet av prostituerte på blodigst mulige måte, og det blir en kamp mot tiden for å stoppe morderen før han dreper igjen. Kompliserende faktorer er et team som samarbeider dårlig, og Matre klarer å innlede et slags kjærlighetsforhold til et av de mulige ofrene. Midt oppi det hele får han vite at han er adoptert, og at levningene etter hans biologiske mor er funnet i en massegrav ved Ris kirke, med pasienter fra Gausdal sykehus. Med et plundrete forhold til broren på toppen blir veldig mange tråder å holde i for stakkars Edvard, som knapt vet hvem han selv er. Med politiledelse og presse på nakken i tillegg så det er ikke så rart at han sliter litt underveis.

Historien om Matre og teamet hans er god, men den er over kjent lest. Liknende varianter er jo skrevet f.eks av Jørn Lier Horst eller Henning Mankell. Et lite gullegg er det jo å sette identitetskrise på mannen. Det gir en interessant vri. Forfatteren tør gi hovedpersonen svakheter. Han er ikke noen spesielt god leder, og viser også dårlig selvinnsikt idét han tviholder på en ekstremt viktig sak samtidig som han går gjennom en personlig krise.

Utgangspunktet for denne historien er selvsagt massegraven på Ris. I boka blir den åpnet, og restene av de døde blir forsøkt identifisert. Denne graven finnes i virkeligheten, men den er aldri blitt åpnet, og forfatteren spekulerer åpenbart i hva man kan finne ut om behandling og pasienter om dette blir gjort. Ikke at det blir mindre viktig av den grunn. Edvard Matre er ny hovedperson, men forsvarsadvokaten Mikael Brenne fra tidligere bøker dukker opp som bifigur.

Dette er bra krim av kjent merke. Kan trygt anbefales.

J.R.R. Tolkien: The Silmarillion

December 31st, 2013

Since it’s that time of the year again, I’m reading Tolkiens “canon”, that is The Hobbit, The Lord of the Rings, and The Silmarillion. I always do around Christmas. I’m still moved by the creation of Ëa, the Earth, and of the many stories, I find The Tale of the Children of Húrin the most intriguing. The story variant in the Silmarillion is almost too short, and for those who want the longer version, I would recommend the standalone book The Children of Húrin.

J.R.R. Tolkien: The Lord of the Rings

December 31st, 2013

Since it’s that time of the year again, I’m reading Tolkiens “canon”, that is The Hobbit, The Lord of the Rings, and The Silmarillion. As earlier years, I’ve also this time tried to find a new angle or figure to scrutinize. This year, the turn has come to Prince Imrahil of Dol Amroth.

Imrahil is a bit strange to me. His name would have another kind of etymology, I think. Imrahil sounds more Arabic-like (or Harad, if you like) than of Nùmenorean origin. And he’s too good to be true. Being but Denethor’s brother-in-law, he appears even more noble than Faramir!

When Imrahil first enters the story, he’s the bright hero warrier knight in his shining armour, on his white horse, and his soldiers are marching behind him singing. Wow! And through the story, he barely jumps from his high horse, and then either to save prince Faramir from certain death, or to find that Eowyn is still alive, (and thus saving her as well): ‘I deem she yet lives.’ And he held the bright-burnished vambrace that was upon his arm before her cold lips, and behold! a little mist was laid on it hardly to be seen. And when finally Aragorn is revealed as the heir of the throne of Gondor, Imrahil bows his head, and calls him his liege-lord.

What a man, what a hero, and he is even humble in all his glory. It’s almost too much. And he even has the looks; he is part elvish, according to Legolas: Legolas looked at him and bowed low; for he saw that here indeed was one who had elven-blood in his veins..

Stop. Brakes on. Part elvish? There’s something fishy here. Skipping forward to Appendix A, subchapter The Nùmenorean Kings, it is stated that there were only three unions of elves and men; Lúthien and Beren, Idril and Tuor, and Arwen and Aragorn. Of course, Imrahil could be of Nùmenorean race, but that doesn’t rhyme with the rest of Legolas encounter: It is long since the people of Nimrodel left the woodlands of Lórien, and yet still one may see that not all sailed from Amroth’s haven west over the water. And Imrahil answers: So is the lore of my land.

Now this is a little mystery. What’s the story about elves mingling with men in Dol Amroth? I thought I could remember having read something about that somewhere, but being unwilling to read my volumes of The History of Middle-Earth again, I humbled my pride, and searched the Internet. Wikipedia had the answer, of course. I’m obviously not the first to dig into this. The story is is found in a note in Unfinished Tales, in one of the variants of the founding of the line of Dol Amroth. It is shortly told that Mithrellas, a Silvan elf-lady of Nimrodel’s company became lost in the mountains, but was found and harboured by the Nùmenorean Imrazôr of Bel Falas, who wedded her. She bore him two children, a girl Gilmith and a boy Galador. Thus Nùmenorean blood was mingeled with Silvan elves, and the line of Dol Amroth was established. Shortly after, Mithrellas left, and was never heard of again. It is an, a bit sad story I think, and with Mithrellas leaving, not to say escaping, her wedding to Imrazôr is not mentioned by the “official” unions of elves and men – or it could just be one of the many discrepancies in Tolkien’s stories.

J.R.R Tolkien: The Hobbit

December 31st, 2013

Since it’s that time of the year again, I’m reading Tolkien’s “canon”. And since the Internet is full of posts about the book, I’d rather post a few comments on the new Hobbit movie, The Desolation of Smaug, which I watched just before Christmas. (Yes, the Internet is full of those posts too, I know.)

I was a bit surprised by this film. I quite enjoyed last year’s chapter of the story, but this time I was a bit baffled. I mean, yeah, this is a cool film, and I kind of liked it, but this is … another story. It could be described as “loosely based on a story by J.R.R. Tolkien”. But while watching it, I thought, well, OK, let’s see what happens. I might be surprised. And as beeing one that knows the original story, well, let’s say, in more detail than the average, that’s probably a good thing, isn’t it? And with that, I found the film quite entertaining.

There were a few things to note, though, if I may.

First, the meeting of Gandalf and Thorin in Bree, in retrospect. That part is fetched from the appendixes of The Lord of the Rings. I very much liked that part. And perhaps especially because it picks one of the main weaknesses of the book: What is the mission of the dwarves? They should understand that addressing a dragon, and go burglaring for several hundred tons of treasure is just a mad quest. Making the Arkenstone the primary target, as it gives royal power over the rest of the dwarvish clans, see that’s a quest that might be possible to achieve using a smart and quiet burglar. And it also shows Gandalf’s master plan: To get rid of the dragon before Sauron may use it for his own purposes. Nice!

Beorn and his house. Gone is the rather comical encounter of Gandalf and his story, and the dwarves popping up like jack-in-a-boxes. Gone is the laughing, jolly huge man, and his wonderful animals. In his place, a dreadful beast, and a rather mystical, dreamlike figure. I missed the children’s book’s Beorn.

Gandalf finds that the Necromancer has released the Úlari, the nine Nazgûl from their well bolted up tombs in the mountains. A bit far fetched, I think. According to legend, the ring wraiths never died. The rings made them live forever, under Sauron’s dominion. They did not have to rise from death. But this is what happens when one tries to combine the stories. The Nazgûl did not exist yet in Tolkien’s mind when he wrote about the Necromancer in Dol Guldur. Actually making him Sauron, as Gandalf discovers, did not appear to Tolkien before he had started writing The Lord of the Rings.

Bilbo’s heroism against the spiders in the forest is rather ignored. That’s sad. Instead, the general fight, and the fierceness of the elves, and in particular this totally new character, Tauriel, is emphasized.

Tauriel, I actually quite liked, but why was she there? After discussing this with a colleague, the obvious reason appeared: There is no women at all in the original book. And this far in the films, the only female figure that has appeared has been Galadriel. Nice, but quite remote. So here is a heroine for our female audience. Good for them. This is our fight!.

Then, the elven king. With the looks and temper of Lucius Malfoy. ‘nough said. I didn’t like that at all.

An action movie needs action scenes. Legolas jumping from dwarf to dwarf on the river while constantly beheading orcs. It’s a laugh! And that surfing-on-a-shield detail from The two Towers was revisited twice, or was it three times? Or four?

Making Bard a kind of agent for People’s Liberation Front against the Tyrant, was an interesting move, I think. At least more than the original variant of an acid-stomached watchman. But again, Bilbo’s rôle and heroism is ignored. It should be Bilbo that discovers the weakness of the dragon. It should not be a well-known fact from the stories from Dale. Why is Bilbo’s courage diminished for this?

An elf-dwarf love story. Now that’s way too far fetched. Sorry, that would never happen. Orcs attacking Esgaroth? Uhm, well, okay. But parting some of the dwarves from the rest of the company. Now that was a strange move. Didn’t see that coming.

I loved the scene where the keyhole is found. It almost gave me goosebumps. The dragon was great. The dwarves try to fight the dragon using dwarvish tech. Well, there had been at least four minutes without an action scene, and if you have to fill up a film, why not go for the spectacular. I can stomach that.

All in all, while making quite a different story than Tolkien’s own Hobbit, I quite enjoyed this. And to quote a Norwegian ex-politician, caught while lying about so-called facts: “But it could have happened” * **.