Sunday, July 25, 2010

KDE suspend, hibernate workaround for Gentoo on Lenovo U150

Hello, recently I upgraded my Gentoo packages to the following:


sys-auth/consolekit-0.4.1

sys-auth/policykit-0.9-r1

sys-apps/hal-0.5.14-r2

kde-base/powerdevil-4.4.5

kde-base/policykit-kde-4.4.5
With these, I lost the ability to suspend the laptop. I trield by directly communicating with HAL:

dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
The program answered:

Error org.freedesktop.Hal.Device.UnknownError: error: org.freedesktop.Hal.Error: Could not determine whether caller is privileged

org.freedesktop.Hal.Device.Error
I don't have the clue why this is happening, so I found a workaround by adding the following to the local_start() function of /etc/conf.d/local:

sleep 3s && /etc/init.d/hald restart
I also had to make sure the suspension policies were enabled for the relevant users in PolicyKit through KDE's System Settings.

Update Oct 13, 2010 - Thanks to Motosauro's comments, I checked for the workaround in my current setup:

sys-auth/consolekit-0.4.1

sys-auth/policykit-0.9-r1

sys-apps/hal-0.5.14-r3 -apm

kde-base/powerdevil-4.5.2
The workaround is no longer needed.

Monday, July 19, 2010

Printing useful STL container information with GDB

GDB's "p variable-name" is the Swiss Army knife of the programmer, except when it comes to examine the contents of STL containers.

(gdb) p fieldInd
$110 = {
  <std::_Vector_base<unsigned long, std::allocator<unsigned long> >> = {
    _M_impl = {
      <std::allocator<unsigned long>> = {
        <__gnu_cxx::new_allocator<unsigned long>> = {<No data fields>}, <No data fields>}, 
      members of std::_Vector_base<unsigned long, std::allocator<unsigned long> >::_Vector_impl: 
      _M_start = 0x646c60, 
      _M_finish = 0x646cc8, 
      _M_end_of_storage = 0x646d20
    }
  }, <No data fields>}

This tutorial gives you useful information to have GDB print useful STL container information for you.
(gdb) pvector perm
elem[0]: $111 = 4
elem[1]: $112 = 2
elem[2]: $113 = 0
elem[3]: $114 = 3
elem[4]: $115 = 1
elem[5]: $116 = 5
Vector size = 6
Vector capacity = 6
Element type = unsigned long *

Wednesday, July 07, 2010

CAcert y Certicamara en Google Chrome / Chromium - Linux

Hola, hace algunos días no podía usar Google Chromium para ingresar a miplanilla.com, CAcert y otros servicios debido a que no contaba con los certificados digitales adecuados. Por el consejo de un amigo, e investigando una serie de sitios web, he compilado las siguientes instrucciones para agregar los certificados a Chrome:
wget http://www.cacert.org/certs/root.crt
wget http://www.cacert.org/certs/class3.crt
wget http://www.certicamara.com/downloads/safelayer/certicamara.crt
wget http://web.certicamara.com/media/69784/ac_offline_raiz_certicamara.crt
wget http://www.certicamara.com/ac_online_subordinada_certicamara.crt
certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org" -i root.crt
certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org Class 3" -i class3.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "TCu,Cu,Tuw" -n "Certicamara" -i certicamara.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "TCu,Cu,Tuw" -n "Certicamara CA Raiz SafeLayer 3" -i ac_offline_raiz_certicamara.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "TCu,Cu,Tuw" -n "Certicamara CA Subordinada SafeLayer 3" -i ac_online_subordinada_certicamara.crt
Para usar la herramienta certutil en Gentoo Linux, es necesario tener instalado el paquete nss con la opción utils. Para Ubuntu y otras distribuciones basadas en Debian, se debe tener instalado el paquete libnss3-tools. Más información en este blog.
Después de agregar los certificados, se pueden borrar los archivos crt.