2009-12-09
My fav font for the terminal
Been working on gnome-terminal with the "Inconsolata" font for some time now - really cool!
On Ubuntu, just "sudo apt-get install ttf-inconsolata" and then in gnome-terminal change the default profile (or another profile if you wish) to this font. Mine is set at "Inconsolata Medium 12".
On Ubuntu, just "sudo apt-get install ttf-inconsolata" and then in gnome-terminal change the default profile (or another profile if you wish) to this font. Mine is set at "Inconsolata Medium 12".
2009-07-19
IT Security: interesting interview with Joanna Rutkowska
Over at Tom's Hardware is a very interesting (and long) interview with Joanna Rutkowska - a security specialist best known for her Windows Vista exploits (for research - of course).
I especially like her strategy (look at page 6) is to run various virtual machines, each with it's own security settings depending on it's task. There is however two major drawbacks on this approach: 1) You need a powerful machine; and 2) given problem 1, mobile computing on batteries is not goinbg to fly (yet).
I encourage everybody to have a look - very interesting read indeed.
I especially like her strategy (look at page 6) is to run various virtual machines, each with it's own security settings depending on it's task. There is however two major drawbacks on this approach: 1) You need a powerful machine; and 2) given problem 1, mobile computing on batteries is not goinbg to fly (yet).
I encourage everybody to have a look - very interesting read indeed.
Labels: linux, os, security, windows
2009-05-31
Python signal handling
Signals are one of the most under estimated tools on POSIX systems. Windows is supposed to also handle (some) signals, but I've never used it and don't plan to either. These notes are therefor based on Linux and similar behaving systems.
I used signal processing a lot in Perl coding but since I'm still learning Python I thought it might be a good idea to check it out. As it turns out, it's extremely easy in Python.
For this sample app I wanted to know how easy it would be to tell the app the re-read it's config. The app doesn't really do anything useful but it may perhaps be used for a skeleton of some sorts. Here goes:
It may look complicated at first glance but it's really not. The app behaves like a "server" that needs to do some house keeping from time to time. When it starts up all timers start fresh and the house keeping routines are called immediately. Part of the house keeping is to read (or re-read) the configuration file - which in this sample just prints a message to STDOUT.
But, if you run the app and you get it's process ID, you can send it a SIGUSR1 signal and you will see from the output it re-read it's config. To issue the command:
That's assuming of course your app is running with process id 23456.
"But why" you may wonder?
Well, for one thing you can tweak the configuration parameters and in stead of a restart you can tell your app just to re-read and apply the new configuration parameters. A good example could be that you need to change DB servers to do maintenance on your primary. With this method you could force your app to drop all current DB connections and re-establish the connection with the new parameters. Of course you will have to write some extra code - but I'm sure you understand the concept.
Being able to make changes in a production environment without customer impact is sort of a holy grail for most IT shops. This gets you one step closer.
Enjoy!
I used signal processing a lot in Perl coding but since I'm still learning Python I thought it might be a good idea to check it out. As it turns out, it's extremely easy in Python.
For this sample app I wanted to know how easy it would be to tell the app the re-read it's config. The app doesn't really do anything useful but it may perhaps be used for a skeleton of some sorts. Here goes:
#!/usr/bin/python
import sys
import signal
import time
sleeptime = 5.0 # Every how many seconds do we need to perform hosekeeping
house_tracker = 0 # Track the last time we did housekeeping
def SigUSR1Handler(signum, frame):
global house_tracker
house_tracker = time.time() # Reset the timer of the last house keeping
print "Reacting on USR1 signal (signal 10)"
HouseKeepingRoutines()
return
def ReadConfig():
print str( time.time() ) + "\tRead Config"
return
def Housekeeping( timestamp, interval=10 ):
global house_tracker # Last time we did house cleaning
if ( timestamp - house_tracker ) > interval:
print str( timestamp ) + " - Housekeeping timer reached. Running house cleaning routines"
house_tracker = timestamp
HouseKeepingRoutines()
return
def HouseKeepingRoutines():
# Put all the housekeeping functions here
ReadConfig( )
return
signal.signal( signal.SIGUSR1, SigUSR1Handler )
# Set initial timers
start_time = time.time()
previous_time = start_time
abs_starttime = start_time
while(1):
time_now = time.time()
if ( time_now - previous_time ) > sleeptime:
previous_time = time_now
running_time = time_now - abs_starttime
print "Uptime: '" + str( running_time ) + "' seconds"
Housekeeping( time_now )
time.sleep( 1 )
It may look complicated at first glance but it's really not. The app behaves like a "server" that needs to do some house keeping from time to time. When it starts up all timers start fresh and the house keeping routines are called immediately. Part of the house keeping is to read (or re-read) the configuration file - which in this sample just prints a message to STDOUT.
But, if you run the app and you get it's process ID, you can send it a SIGUSR1 signal and you will see from the output it re-read it's config. To issue the command:
$ kill -10 23456
That's assuming of course your app is running with process id 23456.
"But why" you may wonder?
Well, for one thing you can tweak the configuration parameters and in stead of a restart you can tell your app just to re-read and apply the new configuration parameters. A good example could be that you need to change DB servers to do maintenance on your primary. With this method you could force your app to drop all current DB connections and re-establish the connection with the new parameters. Of course you will have to write some extra code - but I'm sure you understand the concept.
Being able to make changes in a production environment without customer impact is sort of a holy grail for most IT shops. This gets you one step closer.
Enjoy!
2008-07-07
SSH and Virtual User Authentication
I was searching around for a solution on how to authenticate users via OpenSSH on a Linux system, if the users live in a DB. It appears that not a lot of information is available on the topic on some of the more obvious search terms, but after some digging the solution was actually straight forward.
Of course I'm running Debian stable, so the following solution should work for all Debian based systems. However - try at your own risk :-)
Step 1: Install all dependencies:
Step 2 : Prep your database:
Step 3 : Modify your /etc/nsswitch.conf file by replacing the following lines:
Step 4 : Restart SSH and TEST
Also refer to the libnss-mysql-bg documentation online.
Of course I'm running Debian stable, so the following solution should work for all Debian based systems. However - try at your own risk :-)
Step 1: Install all dependencies:
# apt-get install mysql-server libpam-mysql libnss-mysql-bg
Step 2 : Prep your database:
# mysql -uroot < /usr/share/doc/libnss-mysql-bg/examples/linux/sample_database.sql
Step 3 : Modify your /etc/nsswitch.conf file by replacing the following lines:
#passwd: compat
#group: compat
#shadow: compat
passwd: files mysql
group: files mysql
shadow: files mysql
Step 4 : Restart SSH and TEST
Also refer to the libnss-mysql-bg documentation online.
Labels: authentication, linux, mysql
2008-06-26
Dell XPS M1530 with Ubuntu and Vodafone 3G
Well, let me first say that Ubuntu absolutely rocks on the M1530. The only thing that took me a while to sort out was the on board 3G modem, so here is a little run down of the steps I took to get it working.
I assume for now you have installed the Vodafone 3G dialer.
Step 1: Add the following line in /etc/fstab:
Step 2: Run the following command:
The sleep command might be an overkill, but I am playing safe here.
Step 3: Initialize the modem again. You do this by switching off the modem (slide button on the right hand side of the laptop). Wait 5 seconds, and switch on again. This will create the /dev/ttyUSB* entries.
Step 4: Launch the Vodafone 3G dialer and configure your account. I had to restart the dialer after the initial account set-up.
That's it - surf's up !
I assume for now you have installed the Vodafone 3G dialer.
Step 1: Add the following line in /etc/fstab:
none /proc/bus/usb usbfs devgid=46,devmode=664 0 0I did a reboot, just to make sure that everything was working.
Step 2: Run the following command:
sudo modprobe -r usbserial ; sleep 3 ; sudo modprobe usbserial vendor=0x413c product=0x8138
The sleep command might be an overkill, but I am playing safe here.
Step 3: Initialize the modem again. You do this by switching off the modem (slide button on the right hand side of the laptop). Wait 5 seconds, and switch on again. This will create the /dev/ttyUSB* entries.
Step 4: Launch the Vodafone 3G dialer and configure your account. I had to restart the dialer after the initial account set-up.
That's it - surf's up !
2008-04-05
Some Centos and SELinux woes...
I discovered that custom compiling Apache and PHP leads to an interesting situation in Centos with SELinux. When you try to start Apache, you will get an error like this: "cannot restore segment prot after reloc: Pemission denied".
This has to do with SElinux. I found some help on the web, and what you have to do is:
Open /etc/sysconfig/selinux and modify the line that reads "SELINUX=enforcing" to "SELINUX=permissive".
You will have to reboot :-(
This has to do with SElinux. I found some help on the web, and what you have to do is:
Open /etc/sysconfig/selinux and modify the line that reads "SELINUX=enforcing" to "SELINUX=permissive".
You will have to reboot :-(
Labels: apache, centos, linux, php, selinux