Tag Archive: Linux


cookies.txt for Chromium (linux)

A simple python script to extract all cookies from Chromium and export them to the cookies.txt file:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from sqlite3 import dbapi2 as db
import os

homedir =  os.environ['HOME']
cookie_file = homedir + '/.config/chromium/Default/Cookies'
output_file = homedir + '/cookies.txt'

conn = db.connect(cookie_file)
cur = conn.cursor()
cur.execute('SELECT host_key, path, secure, expires_utc, name, value FROM cookies')

f = open(output_file, 'w')

for row in cur.fetchall():
    f.write("%s\tTRUE\t%s\t%s\t%d\t%s\t" % (row[0], row[1], str(bool(row[2])).upper(), row[3], row[4]))
    # unicode handler
    f.write(row[5].encode('utf-8'))
    f.write("\n")

f.close()
conn.close()

Enjoy ;)

Today, I was backing up some old data from a another laptop to a USB pen drive (SD/MMC card reader) using Ubuntu 10.10 LiveCD. This pen drive was no SD card, or else, it had only itself capacity (128 MB =P).

When I tried to mount this pen drive on my Gentoo Linux, I was getting the error:

mount: unknown device

But what ?! dmesg, udevadm and lsusb were showing me that it was there:

lsusb:

Bus 002 Device 004: ID 0bda:0103 Realtek Semiconductor Corp. USB 2.0 Card Reader

dmesg:

usb 2-2: new high speed USB device using ehci_hcd and address 4
scsi4 : usb-storage 2-2:1.0
scsi 4:0:0:0: Direct-Access     Generic  2.0 Reader   -SD 1.00 PQ: 0 ANSI: 0 CCS
sd 4:0:0:0: Attached scsi generic sg1 type 0
sd 4:0:0:0: [sdb] Attached SCSI removable disk

After looking carefully to output messages on Ubuntu 10.10 LiveCD, I realized that only the card reader was being recognized, the internal storage was not.

Well, in order to resolve this problem I had to recompile the kernel and activate the option CONFIG_SCSI_MULTI_LUN:

Device Drivers -> SCSI device support
[*] Probe all LUNs on each SCSI device

After reboot the system with my new kernel I could see the expected output message from dmesg:

usb 2-2: new high speed USB device using ehci_hcd and address 4
scsi4 : usb-storage 2-2:1.0
scsi 4:0:0:0: Direct-Access     Generic  2.0 Reader   -SD 1.00 PQ: 0 ANSI: 0 CCS
scsi 4:0:0:1: Direct-Access     Generic  2.0 Reader   -FD 1.00 PQ: 0 ANSI: 0 CCS
sd 4:0:0:0: Attached scsi generic sg1 type 0
sd 4:0:0:1: Attached scsi generic sg2 type 0
sd 4:0:0:1: [sdc] 256000 512-byte logical blocks: (131 MB/125 MiB)
sd 4:0:0:1: [sdc] Write Protect is off
sd 4:0:0:1: [sdc] Mode Sense: 03 00 00 00
sd 4:0:0:1: [sdc] Assuming drive cache: write through
sd 4:0:0:0: [sdb] Attached SCSI removable disk
sd 4:0:0:1: [sdc] Assuming drive cache: write through
    sdc:
sd 4:0:0:1: [sdc] Assuming drive cache: write through
sd 4:0:0:1: [sdc] Attached SCSI removable disk

Now, I could mount the device /dev/sdc and transfer the whole backup to my homedir.

To the curious the pen drive model with 128MB is showed bellow:

My 2 cents ;)

This problem refer to the installation of old JDKs on 64bit Linux systems.

When java command is executed at shell, generally, you will receive this error message:

Error: can't find libjava.so.

To solve this problem just edit 3 files located at JDK installation dir and be happy :)

  • $JAVA_HOME/bin/.java_wrapper
  • $JAVA_HOME/jre/bin/.java_wrapper
  • $JAVA_HOME/jre/bin/realpath

All these 3 files have similar code snippet as bellow:

    case "`uname -m`" in
        i[3-6]86 | ia32 | ia64 | i?86)
            proc=i386
            ;;
        sparc*)
            proc=sparc
            ;;
        *)
            proc=unknown
            ;;
    esac

Edit each file and  include the architecture x86_64 in the first case-statement and the problem will be fixed:

i[3-6]86 | ia32 | ia64 | i?86 | x86_64)

Emerge easter egg

Today I’ll post just a little easter egg inside the emerge command (Gentoo linux):

Say hello to Larry, the cow! ;)

These days I began to develop a new feature to Google Chromium and fix some ones (certain problems in Chromium gets me angry…very angry!!! =P).

I resolved to write this post because in the official build guide there is not mention how to workaround the problem with gcc-4.4 and the WebKit bug (you can see it here).

The problem resides in the file:

$CHROMIUM_ROOT/src/third_party/WebKit/WebCore/WebCore.gyp/webcore.target.mk

If you don’t apply this patch you will see various erroneous lines saying that there are undefined references into file libwebcore.a as these bellow:

undefined reference to findColor
undefined reference to findEntity
undefined reference to findValue

Pay attention: you have to apply the patch after synchronize your code with the remote repository and run the command “gclient runhooks –force” inside $CHROMIUM_ROOT/src or else the changes will be overwritten!

To apply the patch, just do it:

cd $CHROMIUM_ROOT
patch -p0 < /path/to/patch.doc

Some informations:

  • ccache statistics:

  • time compilation:
~  1h56m08s
  • target machine:
2.6.32-gentoo-r4-fx #1 SMP PREEMPT x86_64 Intel(R) Core(TM)2 Duo CPU T5250 @ 1.50GHz
  • tools:
  • gcc 4.4.3 / ccache 2.4

    Extra informations:

    • if you desire compile the code with ccache just change the Makefile inside $CHROMIUM_ROOT/src
    • all object code and binaries are put into directory $CHROMIUM_ROOT/src/out, if you wanna run a “make distclean” just remove this directory…this Makefile (from h3ll) does not have a distclean target!!!

    In the next article I will explain how to compile Google Chromium with LLVM/Clang ;)

    Terminal sharing with GNU Screen

    Today lets to demonstrate how to share a terminal session with GNU Screen. It has been very helpful to me lately, especially in remote pair programming (XP + home-office + linux) or hacking =P

    First, you have to init screen with -S option (it means “create new session named xXx“):

    screen -S xXx

    Now, we have to go to multiuser mode, then just press Ctrl+a and later type the command desired:

    Ctrl+a
    :multiuser on

    Done it, now we will let our friend (mrniceguy) to participate of the current session:

    Ctrl+a
    :acladd mrniceguy

    Well, our job it’s finished. Lets see how our friend (mrniceguy) must to proceed to view the shared session:

    screen -x richizo/xXx

    The option -x attach a started session (xXx) of the user richizo (you) into mrniceguy‘s screen.

    To see if the mrniceguy already is connected to session, just do it:

    Ctrl + a
    :displays

    You can also log all activity in this session (it will be create a file screenlog.n, where n is the number of the current window):

    Ctrl + a
    :log on

    To view more examples, just access the official manual page and have fun ;)

    Boosting your Kernel on Gentoo

    Everybody knows that Gentoo is a performance-architeture-oriented Linux. You can optimize your entire system changing the compiler (gcc) flags to attend the hardware specificities.

    Example: I have a Sony VAIO with Intel Core 2 Duo processor, then I can use this flags on my make.conf (I unmasked sys-devel/gcc to use gcc-4.3.3 that have native support to core2 technology)

    CFLAGS="-O3 -march=core2 -pipe -fomit-frame-pointer -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3"

    Then, all binaries in your system will be optimized…but and the kernel ???

    Well, when you compile the kernel it uses itself compiler flags. And how to optimize it ?

    Good news to you…If you have a Intel processor and use Gentoo Linux in your machine you are a lucky man. You must know the LinuxDNA project. The idea of the project is optimize the kernel to Intel architecture using the icc (Intel Compiler).

    Currently, I’m working on Gentoo ebuild to linuxdna package. You’ll have more news about it soon…

    larry

    Setting keyboard on XWindow

    It’s a little tip showing how you can change your keyboard layout on X11 when you are not root and you cannot use the console (when you are able to use the console, you can use yourself X11 config file through the startx command).

    Well, forget KDE, GNOME and modern X11 clients. Think you are using a simple client as Fluxbox and OpenBox…How do you can change your keyboard layout ?

    It’s simple…use setxkbmap. In my case (I have a Sony Vaio with Spanish layout):

    setxkbmap es

    My two cents ;)

    Follow

    Get every new post delivered to your Inbox.