Monday, November 19, 2012

Unknown symbol

(This is a question I almost submitted to Stackoverflow.  The answer to my question is that I needed to add "MODULE_LICENSE("GPL"); to the top of my code for it to be able to link to GPL code.  Crazy huh?)

The following code (pasted last), taken mostly from here, is a very simple kernel module which acts as a keylogger. I can get it to compile and produce a .ko just fine, but when I try to load it, I get the following errors in dmesg:
[  790.833828] keylogger: Unknown symbol unregister_keyboard_notifier (err 0)
[  790.833846] keylogger: Unknown symbol register_keyboard_notifier (err 0)
I did not build my kernel from source, but am using the stock kernel provided with archlinux. I did install the kernel-headers package to get the module to compile, however.
So my question is: Are these two symbols really not found in my installed kernel? And if they are, why aren't they linking(?) correctly?
I can find evidence that the symbols are present. Firstly, I can see the symbols in /proc/kallsyms. Also, when I do nm /usr/src/vmlinux I can also see these two symbols. Are they not the same?
Module code:
#include    /* Needed by all modules */


int hello_notify(struct notifier_block *nblock, unsigned long code, void *_param) {
    struct keyboard_notifier_param *param = _param;
    struct vc_data *vc = param->vc;

    int ret = NOTIFY_OK;

    if (code == KBD_KEYCODE) {
        printk(KERN_DEBUG "KEYLOGGER %i %s\n", param->value, (param->down ? "down" : "up"));

static struct notifier_block nb = {
    .notifier_call = hello_notify

static int hello_init(void)
    return 0;

static void hello_release(void)


Tuesday, October 18, 2011

Cygwin: Windows Context Menu

The following, when placed in a .reg file and imported into the windows registry, will create a context menu entry that will open a mintty cygwin window at the specified directory. I simply modified a similar reg file which was created for rxvt (I prefer mintty), found here.

Windows Registry Editor Version 5.00

@="Open Mintty Window Here"

@="C:\\cygwin\\bin\\mintty.exe -e /usr/bin/bash --login -c \"cd \\\"`cygpath -u '%1'`\\\"; exec bash\""

Friday, February 05, 2010

Solaris10 (sparc) jumpstart from Linux

This got me started:


Where I work, we have several Sun T1000s. These machines lack usb ports and cdrom drives, so installing Solaris on them is a pain. The process involves using another machine to jumpstart the target machine. Most instructions on the web tell you how to do this using Solaris as the jumpstart server.

One of the great benefits of jumpstarting, is you can completely configure the install process using configuration files. You can set root passwords, specify packages to be installed, run custom shell commands, add users, etc.

I needed a way to be able to manage all of these configurations in CM (perforce) and then reliably and consistently build my jumpstart server. Previously this involved following written instructions that went something like this: 1) Create Solaris VM 2) Move this files over 3) Configure this, that, etc. It was highly error prone and many times a little step here or there would get skipped.

Enter Linux.

Besides the fact that I really dislike Solaris, I saw many advantages to trying to make a Linux jumpstart server. Primarly was the fact that I could programatically make a Linux jumsptart server by making a Live CD (maybe more on this in another blog post). Also, Linux for me, is easier to manage, debug, configure, etc.

In the sections that follow, I'll try to explain the steps I took to create a Linux jumpstart server on a RHEL 5.4 system. As alluded to before, I eventually ported this to an ArchLinux livecd, so I could pop the live cd in a x86 PC, boot, and serve Solaris installs!

And lastly, I should note that this post is mostly a collection of notes. I don't expect a newbie to jumpstart to understand anything by reading this. This will be mostly helpful to someone who is already familiar with the basics of jumpstart, has probably already tried to get it to work on Linux, but just needs a few hints.

Install a minimal RHEL 5.4

Add dhcpd and tftp-server packages, if necessary

Configure dhcpd

Here is my config file. My server's ip is
ddns-update-style interim;
ignore client-updates;
option routers;
option subnet-mask;

default-lease-time 600;
max-lease-time 7200;


# Jumpstart Support
option space SUNW;
option SUNW.root-mount-options code 1 = text;
option SUNW.root-server-ip-address code 2 = ip-address;
option SUNW.root-server-hostname code 3 = text;
option SUNW.root-path-name code 4 = text;
option SUNW.swap-server-ip-address code 5 = ip-address;
option SUNW.swap-file-path code 6 = text;
option SUNW.boot-file-path code 7 = text;
option SUNW.posix-timezone-string code 8 = text;
option SUNW.boot-read-size code 9 = unsigned integer 16;
option SUNW.install-server-ip-address code 10 = ip-address;
option SUNW.install-server-hostname code 11 = text;
option SUNW.install-path code 12 = text;
option SUNW.sysid-config-file-server code 13 = text;
option SUNW.JumpStart-server code 14 = text;
option SUNW.terminal-name code 15 = text;

subnet netmask {
option broadcast-address;
#option routers;

option host-name "solaris10-jumper1";
vendor-option-space SUNW;
option SUNW.sysid-config-file-server "jumpstartserver:/home/jumpstart/config";
option SUNW.JumpStart-server "jumpstartserver:/home/jumpstart/config";
option SUNW.install-server-hostname "jumpstartserver";
option SUNW.install-server-ip-address;
option SUNW.install-path "/home/jumpstart/install";
option SUNW.root-server-hostname "jumpstartserver";
option SUNW.root-server-ip-address;
option SUNW.root-path-name "/home/jumpstart/install/Solaris_10/Tools/Boot";

Configure NFS

For some reason, you have to disable NFSv4 on the server. See this page:
Pay special attention to the comment left by Lars Rohrbach.

My /etc/exports file looks like this:



Enable tftp by editing the /etc/xinet.d/tftp file.

Tftp files (at least with RHEL5) are served by default from /tftpboot. The Solaris sparc bootloader(?) needs to be copied to this directory. In my situation, I copied /install/Solaris_10/Tools/Boot/platform/sun4v/inetboot from the Solaris10 install dvd and renamed it SUNW.Sun-Fire-T1000. If you're not installing a T1000, you will rename it to something different. Also, the folder that inetboot was in, sun4v, may change too. I deduced the filename, SUNW.Sun-Fire-T1000, by looking at tcpdump output and I figured out the architecture(?), sun4v, by googling.

DVD Contents

For simplicity, I mounted (instead of copying) the Solaris 10 sparc dvd at /home/jumpstart/install.



install_type initial_install
system_type server
partitioning explicit
filesys rootdisk.s0 10000 /
filesys rootdisk.s1 1000 swap
filesys rootdisk.s4 10000 /home
filesys rootdisk.s5 free /var

cluster SUNWCreq


network_interface=e1000g0 {hostname=client1


# The following rule matches any system:

any - - any_machine -


any - - any_machine -
# version=2 checksum=num

Start the Install

From the Solaris ">" prompt, issue a "boot net:dhcp - install"

That's it!

Wednesday, December 09, 2009

Extract files from an ISO in Linux (or Windows) without root

I have a need to extract an iso from a script as a non-root user.

My google searching revealed a couple of ways to access the files within an ISO without root access. Obviously, the loop method requires root. If you have gnome around, you can use file-roller as this post shows, but this didn't work for me from the command line. Apparently you can use midnight commander, but I didn't see any easy way to script mc.

The solution I found is to use good ole 7zip. From previous experience I knew it could open up iso files on Windows. They have a Linux version.

Here is the 7zip download page. I recommend downloading the binary verison for linux if you don't want to compile from source.

Here is some sample syntax to extract an iso:

7z x -oOutputDir LargeLinuxIso.iso

I mentioned Windows in the title because 7zip is cross platform and these instructions apply there as well.

Friday, November 20, 2009

Custom RHEL / OEL 5.4 CD (iso) with kickstart

The end result of this tutorial is a bootable iso which will install a pre-configured RHEL 5.4 without any user input.

Step1: Copy

Copy the entire contents of the RHEL 5.4 dvd to $rhroot, where $rhroot is any directory on your system.

Step 2: Create Kickstart

A kickstart file tells the installer how you want the system installed and allows your install to take place with no user input. In it, you configure options like the timezone, the partition layout, and which packages you want installed. The easiest way to create a kickstart config file is to use the one created when you installed your current system which is located at /root/anaconda-ks.cfg. See the documentation for more information on tweaking your kickstart file.

Step 3: Remove Unnecessary Packages, Add Extra Packages

Remove the rpms that you don't need from $rhroot/Server/. Most likely the Cluster, ClusterStorage, and VT directories of $rhroot can also be removed. The rpms you don't need are determined by what packages your installing as defined in the kickstart file. For any additional custom RPMs, be sure you add them to kickstart file or include them in a package group (see $rhroot/Server/comps-rhel5-server-core.xml).

Despite the fact that you may remove many RPMs, I haven't found any benefit to removing references to them from the package group file.

Step 4: Rebuild the Repository

Run the following command from $rhroot/Server to rebuild the Server repository to reflect any packages that were added or removed:
$ createrepo -u "media://`head -1 ../.discinfo`" -g repodata/comps-rhel5-server-core.xml .
Step 5: Build the ISO

From $rhroot run the following:
mkisofs -r -R -J -T -v -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/ -x "lost+found" -o ../oel5Custom.iso .
Step 6: Test

I use VirtualBox to give my new ISO a spin.

Good References:

Friday, November 06, 2009

Ozone mobile web browser

For the longest time, I've been looking for a decent web browser for the Nokia e71.  After trying webkit s60 (the built in browser), skyfire, opera mini, bolt, and teashark, I finally found Ozone.  Ozone is amazing.  It is fast and loads pages with javascript better than any other mobile browser.

Interestingly enough, Ozone's author(s) is mysteriously elusive.  It is a really good browser, so I would conclude that it took a lot of money to develop.  Why is there no mention of a company or author?  With nobody to give credit to, there's nobody to take blame -- for better or worse.  It's hard for me to trust my identity (gmail username/password, for example) to Ozone.  For all I know, there's a good chance Ozone is the fruit of an organized crime effort.  I'm pretty sure someone could earn a buck or two if they full access to the kinds of information people, usually trustingly, put into their web browser.

So while I'll be using Ozone for everything I can, I won't be giving it any information I wouldn't openly post on the internet.  

Tuesday, October 06, 2009

How to (easily) mount a CDROM in Solaris

for device in `ls /dev/dsk`; do mount -F hsfs -o ro /dev/dsk/$device /mnt/cdrom; done