Importing contacts the hard way

Three days ago, I got my Nokia N9 and everything was fine.

One day later I flashed PR1.2 onto it. This broke Contact synchronization via Exchange. No matter what I tried, I couldn’t get it to work.

The  synchronization not working is one thing, but not having the contacts on the phone at all is pretty bad, so I needed to find a way to bring them on there.
The N9 doesn’t support importing contacts from any files. The next best thing that came to my mind, were QrCodes.

Easy-peasy, just open up Google contacts, point the phone camera to the QrCodes of one contact after another and save it. But wait! Google Contacts doesn’t show any QrCodes. So I had to generate them myself. Of course I could upload the exported file with all contacts to a website and get back the Codes, but that’d mean that I’d transfer all my contact data to some strange website - not an option either.

The Linux program qrencode can convert contact data to a QrCode. That’s easy enough. Just use:

qrencode -o name.png “`cat name.vcf`”

Toying around, I found that Vcard was the only format supported by both Google Contacts export and the N9 Qr Code program.

So, the last problem I had, was that I’d have to download every contact’s vcard file. That’s a lot of work.

I ended up, exporting all the contacts at once and writing a Python program to separate the data into files for each contact:
(It’s uggly code, I’m not using Python that often…)

import vobject
from vobject import readComponents
import StringIO
import subprocess

file = open(‘contacts.vcf’)
io = StringIO.StringIO(file.read())
string = io.getvalue()

for vcard in readComponents(string):
  print vcard.fn.value

  filename = vcard.fn.value+”.vcf”
  filename = filename.replace(” “, “.”)
  filename = filename.lower()

  out = open(filename, ‘w’)

  v = str(vcard.serialize())
  out.write(v)

  out.close()

Afterwards, I used a (very small) Shellscript to generate the png files:

#!/bin/bash
for line in *.vcf;
do
  qrencode -o $line.png “`cat $line`”
done

(You can use my code under the WTF Public License 2.0 http://sam.zoy.org/wtfpl/COPYING)

Bronies React to Teens React to My Little Pony: Friendship is Magic. Nnnnnnice!

cron based alarm clock playing podcast on N900

To make getting up in the morning easier, I’d like my phone to play the latest episode of the InfoSec Daily Podcast that comes out while I’m sleeping.
That wouldd be totally doable with a proper cron daemon.
When I reset my N900 lately, I finally got around installing a cron daemon.

http://wiki.maemo.org/Fcron explains how to install Fcron on the Nokia N900, I just followed all their steps.

The first problem I had afterwards was, that I was unable to use fcrontab -e with the default user account. That sucks! I could not find a solution for this problem, but a workaround: As root user, just do

fcrontab -u user -e

Now you can edit the users crontab :)

To do the alarm clock with the podcast, I need two scripts: One downloading the newest episode and a second one playing it. I start the first one about 45min befor the second, as I can’t predict how long it will take to do the download.
I’m using the GPodder Podcast client on my N900 (that thing’s amazing!). Luckily, Gpodder offers a command line interface that can be called via the gpo command.
The download script looks a bit like this:

#/bin/bash

gpo update http://feeds.feedburner.com/InfosecDaily » download.log

gpo download http://feeds.feedburner.com/InfosecDaily » download.log

The second script was a bit trickier. The main problem is, that mplayer, for some reason, doesn’t work from within the cronjob. So I decided to use ffplay.
That didn’t fully solve the problem though. ffplay absolutely wants to spawn a window, even when started with the “-nodisp” option (that’s apparently a bug that’s solved in newer versions of ffplay).
This requires the SDL variable to be set, and that’s normally not the case from within the script.
The script looks like this:

#/bin/bash

cd /home/user/MyDocs/Podcasts/InfoSec\ Daily\ Podcast/

/bin/ls infosec-daily-podcast-episode-* > episodes.list

episode=$(sort -n episodes.list | tail -1)

echo $episode » /home/user/play.log

DISPLAY=:0.0 ; export DISPLAY

ffplay -nodisplay $episode » /home/user/play.log 2> /home/user/error.log

Both scripts are only started during week days, the second one at the time I want to get up.

There’s still a minor problem: When I run the second script manually as user, ffplay runs fine, using about 20% of the CPU, according to htop. But when started by the cronjob, ffplay uses 100% and still has minor lag.
I couldn’t figure out why this is or how to solve it yet :(

full privileges to ‘root’@’%’ in MySQL

I just had the problem that I was unable to do certain things when logged in as root to a remote MySQL Server. I was wondering a bit why this was, after all, I’m root.

The problem turned out to be quite simple. MySQL has two root accounts. One is root@localhost (when coming from localhost, obviously) and on is root@% (when coming from any other host).
The root@% hasn’t full permissions by default. Changing this is quite simple:

1. Login from localhost

mysql -u root -p

2. Change permissions for the remote root account

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’;

That’s all :)

My Linux Kernel Config

Configuring a Linux Kernel can be a lot of work and one has to remember a lot of things. It’s boring work but yet, you have to be concentrated.

To avoid forgetting important things that I need in my Gentoo Kernels, I made a list of things that need to be turned on. Here it is:

Processor type and features  —->                                  
   [ ] Machine Check / overheating reporting
   [*]   Intel MCE Features
   [ ]   AMD MCE Features
         Processor family (Core 2/newer Xeon)  —->                
   (16)  Maximum number of CPUs                                    
   [*] Symmetric multi-processing support                          
   [*] Enable KSM for page merging                                 
   [*] Paravirtualized guest support  —->
       [*]   KVM paravirtualized clock                             
       [*]   KVM Guest support                                     
       -*-   Enable paravirtualization code                        
       [*]     Paravirtualization layer for spinlocks              
 
Executable file formats / Emulations  —->                         
   [*] IA32 Emulation
 
File systems —->
  <*> Second extended fs support                                   
  <m> Ext3 journalling file system support                         
  <*> The Extended 4 (ext4) filesystem                             
  <*> FUSE (Filesystem in Userspace) support                       
  Pseudo Filesystems —->                                          
    [*] /proc file system support                                  
    [*] Virtual memory file system support (former shm fs)         
  Partition Types —->                                             
    [*] Advanced partition selection                               
      [*] EFI GUID Partition support                               
  CD-ROM/DVD Filesystems —->                                      
    <M> UDF Filesystem support                                     
   
Networking support —->
    Networking options —->
        <*> 802.1d Ethernet Bridging                               
        <*> 802.1Q VLAN Support                                    
   
Device Drivers —->
  [*] HID Devices  —->
    <*>   USB Human Interface Device (full HID) support            
  [*] Multiple devices driver support (RAID and LVM) —->          
    <*> Device mapper support                                      
    <*> Crypt target support                                       
    <*> RAID support                                               
  [*] Block Devices —->                                           
    <*> Loopback device support                                    
  [*] Hardware Monitoring Support —->                             
    <*> Intel Core/Core2/Atom temperature sensor                   
  Graphics support —->                                            
    /dev/agpgart (AGP Support) —->                                
      <*>  Intel 440LX/BX/GX, I8xx and E7x05 chipset support       
    Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)
      <*>  Intel 830M, 845G, 852GM, 855GM, 865G (i915 driver) i915 d
      <*>  Intel 830M, 845G, 852GM, 855GM, 865G (i915 driver) i915 d
      [*]    Enable modesetting on intel by default
  Input device support —->
    <*>  Event interface
  [*] Network device support —->
    -*- Network core driver support
    <M>   Universal TUN/TAP device driver support

[*] Cryptographic API —->
  <*>  SHA256 digest algorithm
  <*>  AES cipher algorithms
  <*> RIPEMD-160 digest algorithm
  <*> SHA384 and SHA512 digest algorithms
  <*> Whirlpool digest algorithms
  <*> LRW support (EXPERIMENTAL)
  <*> XTS support (EXPERIMENTAL)
  <*> AES cipher algorithms
  <*> Serpent cipher algorithm
  <*> Twofish cipher algorithm

Power management and ACPI options —->
  [*] ACPI (Advanced Configuration and Power Interface) Support —->
    <*> AC Adapter
    < > Battery
    -*- Button
    -*- Video
    <*> Fan
    <*> Processor
    <*> Thermal Zone
    [*] Power Management Timer Support
  CPU Frequency scaling —->
    [*] CPU Frequency scaling
          Default CPUFreq governor (ondemand) —->
    <*>   ‘performance’ governor
    < >   ‘powersave’ governor
    <*>   ‘userspace’ governor
    <*>   ‘ondemand’ governor
    <*>   ‘conservative’ governor
          x86 CPU frequency scaling drivers —->
          <*> ACPI Processor P-States driver

[*] Virtualization —->
    —- Virtualization
    <M> Kernel-based Virtual Machine (KVM) support
    <M>   KVM for Intel processors support

I’ll post a list of sources for these settings soon.

One week ago…

One week ago the 28c3 had ended. These four days definitely were one of the best times I had in my entire life! Awesome people, awesome talk, awesome tech, awesome experiences - it was amazing!

Before leaving, we helped tearing down the tables and some of the network stuff and then went off to go to the after party at the c-base.
I hadn’t been at a hackerspace before actually and certainly not at such a big one as the c-base.

It was very busy there with a lot of people coming over from the 28c3, but it was absolutely great.

If I can get a ticket, I’ll definitely go to the 29c3 and also visit the c-base again.

Thanks to everyone who was there and especially to all the angels!

No Coca Cola for one week!

Every day, just after lunch, I’m getting myself an 1/2l bottle of Coca Cola (the _real_ one, not zero or diet).

However, this week, I decided not to! No Coca Cola for one week (or at least 5 days).
Turns out, that’s pretty hard! For the first two days I felt really odd and my stomach felt strange all afternoon!

Wednesday wasn’t that bad anymore, but still strange.

Today now went ok. Just after lunch it was still strange but then it became OK very quickly.
Amazing, how hard it is not to drink Coca Cola!

Microsoft congratulates Linux to it’s 20th birthday

reallinux:

Microsoft just want to say Happy Birthday! | The Linux Foundation Video Site - http://video.linux.com/video/2127

The LinuxFoundation has asked for videos for the 20th birthday of Linux. This one was submitted by Microsoft.