Archive for the ‘OpenSource’ Category

Eclipse – CDK – build – run as super user

October 5, 2011

If you develop your native C/C++ application with Eclipse CDK and the need to execute the newly build  application with permissions to access raw socket API, such as a tun-interface, I suggest to use Linux-capabilities. (Executing the newly build application as root/super user, can become very complex.)  The Linux-capabilities allow you to execute you app with regular user permissions, but being capable to access certain privileged interfaces of Linux.

I assume that your build environment builds the binary /home/myuser/workspace/proj/bin/myapp

## invoke command in terminal with root permissions
sudo setcap cap_net_admin,cap_net_raw=eip /home/myuser/workspace/proj/bin/myapp

Next you have got to add the following lines to /etc/security/capability.conf to grant these privileges to the developer/user myuser.

## add to file /etc/security/capability.conf
cap_net_admin myuser
cap_net_raw   myuser

If your application needs read/write access to raw network devices such as  /dev/net/tun, grant these privileges by adding the following line to the file /etc/udev/rules.d/50-udev.rules (assuming myuser is member of group admin)

## file /etc/udev/rules.d/50-udev.rules
KERNEL==”tun”,     NAME=”net/%k”,     GROUP=”users”, MODE=”0660″, OPTIONS+=”ignore_remove”

These take effect on next reboot. In the meantime do:
sudo chown root.admin /dev/net/tun
sudo chmod g+w /dev/net/tun

Now your application has the required permissions to execute privileged network operations. Now you have got to integrate the setcap invocation into the Makefile build process. Add the following line to your make-rule:

## Makefile rule
myapp:  $(APPLIBS) main.o
     $(CC) $(CFLAGS) $(LDFLAGS)  -o myapp main.o $(APPLIBS)
     sudo setcap cap_net_admin,cap_net_raw=eip /home/myuser/workspace/proj/bin/myapp

To avoid that sudo request the password, we add the following line to the very end of the file /etc/sudoers, replace myuser by the user-name of the developer.

## Add as last line of config file /etc/sudoers
myuser ALL = (ALL) NOPASSWD: /sbin/setcap, (ALL) NOPASSWD: /sbin/ifconfig

You will notice that we grant access as well to /sbin/ifconfig. This will allow our application to invoke ifconfig commands from within application to create the required network interfaces.

Finally very that the capabilities are configured for the freshly built binary. And you should see the capabilities are the one you set before.

## Execute in console:
sudo getcap myapp

Now you are done. You should be able to execute your application with normal user permissions from within Eclipse, and invoke privileged network operations.

PDF to TIFF

September 13, 2010

Let’s assume you created slides in the past with embedded graphics/images. Years later you want to re-use some graphics, but all you have got at hand is the PDF version. How could you extract the embedded graphics in high quality?

The solution is to convert the PDF to TIFF slide by slide, and use GIMP to edit the graphics. The following command will convert the PDF to TIFF file. The echo-piping is used to get around the page-wise confirmation.

echo | gs -sDEVICE=tiff32nc -r300 -sOutputFile=slideshow.tiff slideshow.pdf

Make Project Creator

September 5, 2010

Did you ever wish something which allows you to declare inter-dependencies between C/C++ source files and let you compile with GCC or MSVC, or even exotic compilers? If so, you should take a look at the  Make Project Creator (MPC) hosted by the TAO project. MPC defines a simple  syntax to define inter-dependencies between source files, and can be transformed into the appropriate formats for GMAKE/GCC or MSVC. If I find some time, I will write something in more detail about it.

http://training.ociweb.com/products/mpc/features.html

Android for SmartQ7

May 14, 2010

I documented step by step the installation of Android on the SmartQ7 MID device. The qdroid-inst.sh script eases the creation of the boot-SDCard.

http://skednet.wordpress.com/2010/04/09/qdroid-2-0-on-smartq7/

Disable CPU frequency scaling

April 30, 2010

The CPU frequency scaling drove me crazy. My slow fanless z520 based system slowed down a lot using the ondemand mode. It just meets my needs when I set it to  performance mode, but on every re-boot the system fell back to ondemand mode.  The annoying thing is that I can not disable the CPU scaling anywhere. The solution has been explained in  http://ubuntuforums.org/showthread.php?p=9159702

The solution is to configure the performance mode persistently, just  add the following lines to /etc/rc.local, per CPU one line:

echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

Binary Scanner (beta)

April 1, 2010

Binary Scanner is a frontend for ldd and nm to view and analyze symbol names of dynamicaly linked ELF executables, as they are used by Linux and other Unix like operating systems.

The tool shall help developers and release managers to improve the quality of binaries shipped with Linux releases, in terms of number of library dependencies and vast amount of dynamic symbols within the libraries and executables.

As it seems, some executables depend on shared libraries such as libm.so but do not refer to any of its functions or constants. More over, many executables re-export symbols  which are have been “cloned” from library header files accidentely. Both influence the startup time of dynamicly linked executables significantly.

This tool gives developers and Q&A an easy to use tool at hand to inspect and analyze selected executables.

The sources are hosted at http://sourceforge.net/projects/binscan/ The tool provides a text mode and a Gtk+ based GUI mode.

Alice – slow connects

January 22, 2010

After migration to Alice-DSL I noticed slow connects in Webbrowser. It turns out that it is caused by the DNS services provided by Alice on login.

Connecting Alice provides two  DNS services. These DNS service may change the next time logging in. These  Alice-DNS services are causing way to long timeout to return with answer, in range of seconds. Way tooooo slow. Probably the ISP (Alice) is trying to slow down traffic this way.

The DSL-router itsself is also a problem.   The Alice DSL-router does not support the static DHCP-feature I am used to. This feature allows you to configure a static IP address for your notebook for your  network at home,  instead of a random IP number from DHCP pool.  This is a very nice feature I am using extensively  as it allows  to assign a well known IP numbers to my notebooks, even if it is using automatic network configuration via DHCP. Otherwise you would need to switch frequently  between  static/manual and automatic IP configuration moving you notebook between home/office and hotel.

I recommend to buy a third-party DSL router (eg. netgear) , which supports static DHCP configuration and also free choice of DNS servers, to make use of public-DNS services in the network, which will speed up webpage download a lot. Search this list of  public-DNS  services available in network
http://www.ccc.de/censorship/dns-howto/

Configure external disk

October 10, 2009

I bought the Patriot-Convoy-XL Raid case (eSATA&USB), equipped with two 250GB WesternDigital HDDs. The raid device shall be mounted as external USB-2.0 device. To avoid collisions with other USB storage devices, the device shall be detected via unique UUID.

The following command lists the UUID of all connected disks
> ls -lF /dev/disk/by-uuid
frehberg@freza:~$ ls -lF /dev/disk/by-uuid
total 0
… 3220f76f-0967-4fe8-ad70-b97bca895bd6 -> ../../sda5
… 4c7a980e-b3a6-4ae3-8225-53f0a448b474 -> ../../sda1
9cd4ffd9-40b2-4968-9d9d-dbb82255370d -> ../../sdc

I want the device being mounted at  /media/raid/, I have got to create first
> sudo mkdir /media/raid

Add the following line with text editor to /etc/fstab, so the device with UUID 9cd4ffd9-40b2-4968-9d9d-dbb82255370d will be mounted beneath /media/raid

# line added to /etc/fstab

UUID=9cd4ffd9-40b2-4968-9d9d-dbb82255370d /media/raid     ext4    relatime       0        1

Finally unmount the device /dev/sdc and mount it under the new branch

> umount /dev/sdc

> mount -a

Linux & G500/poulsbo

October 4, 2009

Dell Mini 10 is a Linux-nightmare, but this page is quite helpful:
http://wiki.ubuntuusers.de/Grafikkarten/Intel

And Modeline needs to be added:
http://julipedia.blogspot.com/2007/03/x11-mode-line-generator.html

This is also useful:
http://www.fit-pc2.com/forum/viewtopic.php?f=9&t=768

Finally I modified /etc/X11/corg.conf the following way, to run stable and support my external screen with 1400×900 resolution:

Section “Monitor”
    Identifier “Configured Monitor”
    Modeline “1440x900_60.00” 106.47 1440 1520 1672 1904 900 901 904 932 -HSync +Vsync
EndSection
Section “Screen”
    Identifier “Default Screen”
    Monitor “Configured Monitor”
    Device “Configured Video Device”
    SubSection “Display”
        Virtual 2464 900
    EndSubSection
EndSection
Section “Device”
    Identifier “Configured Video Device”
    Option “AccelMethod” “EXA”
    Option “DRI” “off”
    Option “MigrationHeuristic” “greedy”
EndSection

Poulsbo Linux Treiber

September 19, 2009

Nach diesen Schritten, ist der “Dell Mini 10” eine echte GrafikRakete:
http://ubuntuforums.org/archive/index.php/t-1229345.html