Thursday, March 29, 2007

Linux Printing with CUPS - sucked into dependency hell

After two days of struggling, I finally got my Epson C67 printer to work again. All in the name of upgrading GIMP-Print to Gutenprint which should provide better support for the printer, especially for photo printing.

The initial build process for Gutenprint was smooth - no error what so ever. But when I tried to print - nothing happen. After much reading and Google around, I found the problem was due to dependency issues. This simply means I had to re-build my Gimp and Ghostscript to newer versions (and also I took the opportunity to re-build CUPS). Only after all those re-built I managed to print again. I just wish there is an easier way to resolve dependency in the future.

Monday, March 26, 2007

A Simple Step-By-Step Guide of SSL Key Management With OpenSSL

This is a simplified step by step guide to manage SSL key using OpenSSL. For further information do man openssl.

1. Become a root certificate authority(CA)

  • $openssl req -new -x509 -keyout ca.key -out ca.crt -days 3650
  • This will request for (-)new self-signed(-x509) root certificate with private key(-keyout) named "ca.key") and certificate file(-out) named "ca.crt" which is certified for 10 years(-days 3650).

2. View the contents of the certificate
  • $openssl x509 -in ca.crt -noout -text
  • $openssl x509 -in ca.crt -noout -dates
  • $openssl x509 -in ca.crt -noout -purpose

3. Create the certificate signing request
  • This request is actually generated by those who want their certificate to be signed by root CA
  • $openssl req -new -nodes -keyout my.key -out my.csr -days 365
  • If paranoid, remove -nodes option to make the private key encrypted and password protected.

4. Signing a certificate
  • $openssl ca -out my.crt -in my.csr
  • Optionally, remove the human-readable portions of the certificate :
    • $openssl x509 -in my.crt -out my-nohuman-readable.crt

5. Deployment of certificates
  • The following certificates my.key, my.crt and ca.crt are needed by application using SSL.
  • Some applications require both the key and certificate in one file, which can be achived by running:
    • $cat server.key server.crt > key-cert.pem
  • For applications using SSL/TLS, the Diffie Hellman parameters may be required on the server side. Create the DH (using 2048 bits) by issuing:
    • $openssl dhparam -out dh2048.pem 2048

6. Certification Revocation List (CRL)
  • $openssl ca -gencrl -crldays 30 -out rootca.crl

7. Renewing and revoking certificates
  • Both root certificate and other signed certificates are subjected to expiry.
  • If root certificate expires, a new root CA certificate must be created and distributed. All other certificate that it signed must also be re-created and signed.
  • For other certificates, those certificates can be renewed by first revoking the old certificate, then re-signed the original request or do another round of request and sign procedure. To revoke a certificate, issue the following command:
    • $openssl ca -revoke expire.crt
  • Regenerate CRL again if necessary.

Tuesday, March 20, 2007

Wow! del.icio.us

Just open an account at del.icio.us :) It's a rather late entry into social bookmarking. I already formed an initial impression of social bookmarking - it's pretty cool.

You can view my bookmarks at http://del.icio.us/efaisal

Wednesday, March 14, 2007

Posting source code

I not really satisfied the way source code is being displayed. Currently I'm just putting the <pre> tag around the code. No fancy formatting, just plain <pre>. So, is there a better way to format source code? May be use <pre> tag with some cool CSS hacks?

Scheduleable Event Loop for asyncore/asynchat

Been a while since I write a blog. Below is the Python code which is quite usable to replace the default asyncore loop. It's based on Sam Rushing code which can be found at http://squirl.nightmare.com/medusa/async_sockets.html

import sys, time, asyncore

map = asyncore.socket_map

class EventLoop:
def __init__(self):
self.events = {}
self.poll = asyncore.poll3
self.__quit = None

def loop(self, timeout=30.0):
while map:
if self.__quit is True: break
now = int(time.time())
for k, v in self.events.iteritems():
if now >= k:
for o in v:
try:
o[0](*o[1][0], **o[1][1])
except:
type, value, tb = sys.exc_info()
parm = str(o[1])
logstr = "Error in Evenloop processing " + \
"scheduled task."
logstr = "Error details: %s: %s" % (type, value)
logstr = "Error details(parm): %s" % parm
logstr = "Error details(tb): %s" % \
tb.tb_frame.f_code
del self.events[k]
self.poll(timeout)

def schedule(self, delta, callback, *args, **kargs):
now = int(time.time())
if self.events.has_key(now + delta) is False:
self.events[now + delta] = []
self.events[now + delta].append((callback, (args, kargs)))

def unschedule(self, callback):
for k, v in self.events.iteritems():
for o in v:
if o[0] is callback:
del self.events[k][v][self.events[k][v].index(o)]
if len(v) == 0:
del self.events[k]

def quit(self):
self.__quit = True

Wednesday, August 16, 2006

Hylafax protocol experimentation ended

I finally wrote a kind of middleware that sits between a web-based procurement system (written in PHP) and Hylafax server. Among other things that the procurement system does is mass faxing to various vendors - in this case up to a few hundred vendors a day.

My initial test went pretty smooth - well, a bit of hiccup though. Few fax machines apparently received the distorted document due to some unknown reasons. I'm still investigating. Apart from that I would say the prototype was a success, able to handle hundreds of documents to fax simultaneously. The decision to do the communication part asynchronously paid off - no noticeable load on the server which runs the middleware.

So anybody interested in integrating your webbased system with Hylafax? :)

Wednesday, August 09, 2006

Hylafax protocol: Administrative function

Today while testing bulk faxing, I encountered a failure due to blacklisted number.

Is there a way, or rather a protocol verb which I can use to query the Hylafax server for sending modem command - e.g. to check modem status or to reset modem blacklisted number

Tuesday, August 01, 2006

Understanding Hylafax protocol

It's been a while since my last blog post. I've been kept busy a number of things - mainly at work.

OK, so I've learnt one or two things since then. I've managed to build a prototype Hylafax client - and yes - it's making use of asynchronous communication mechanism. The prototype currently able to send a fax job and query the status of a job. The code right now is rather crude. The next course of action is make some administrative query. I just hope I have the spare time for this :)

Friday, June 30, 2006

Hylafax protocol prototype update

Basic login mechanism is now working. All I did was to follow the same way any FTP client handles login as noted by Bernstein here. Next would be testing to login as admin.

Tuesday, June 27, 2006

Hylafax protocol prototype

This is an update of the previous post. For the prototype, I'll just focused on 3 things:

  1. Able to login, both as users and admin
  2. Able to post fax job
  3. Able to query the fax server the status of fax job

I've played around with asyncore/asynchat and looks that this is a feasible project.

Monday, June 26, 2006

The new Hylafax protocol adventure begins

I've started my little learning project - writing a prototype program that speaks Hylafax protocol in Python. I also found Pyla, a Hylafax client written in Python. Pyla make use of ftplib module that comes with Python distribution - a smart move for not re-inventing the wheel. But I want to re-invent the wheel in order to learn something. So I'll be a little bit more adventurous - instead of using blocking socket like Pyla, I'll go for non-blocking asynchronous communication. Two asynchronous communication framework came to mind - Twisted and asyncore/asynchat. Twisted is sexy, but I guess I'll go with asyncore/asynchat for the sake of learning.

Wednesday, June 14, 2006

Another reminder

I know a mental know will not last long, that's why I blog this kind of thing :)

Please be reminded to check out Bazaar-NG - a next generation distributed version control system. I think I might have one or two projects which is suitable for using distributed version control system. Furthermore, this one is written in Python and still under active development. This could be a nice alternative to centralized version control system that I'm used to - CVS and SVN.

Tuesday, June 13, 2006

Hylafax protocol for Python

A reminder for myself to investigate about Hylafax protocol. All I know right now, the new Hylafax protocol is a modified FTP protocol. When I browse through the hfaxd code (it's written in C++), I think writing a Hylafax protocol under Python is acheivable.

Monday, June 12, 2006

FIFA World Cup - got time to blog?

I haven't been able to find a time to blog - all due to FIFA World Cup. Below are my thoughts of the current state of the competition:
  1. Most of the seeded teams which have played produced a sub-standard performance.
  2. Many of the teams which were expected to lose to the seeded teams fought in a spirited manner and played extremely well.
After 8 matches, the underdogs were obviously well prepared. They did their homework well. They played well as a team. Many of the players were very good at ball control.

So, what happened to the seeded teams? Over confidence? Ego - thinking that they're star players which make them unable to play as a team? Poorly prepared? Or all the above?

Friday, June 09, 2006

Open Source: Beyond Software

Open Source is not exclusive to software, or in the broader sense tech domain - yes, that's right. Newsforge reported about a project called Free Penguin Project that produced sewing pattern to make a soft toy of the cuddly little penguin - Tux.

Another thing to do beside hacking the codes - sew!

Thursday, June 08, 2006

My little rant on Python

Today I thought to myself, why not try to play around with SysV shared memory and semaphore under Python. Then, to my surprise, this time the battery is not included. Yes, there is no module that come with standard Python which offer this facility. After painstakingly Google around, I found 2 modules which provide a mechanism to this IPC - but I'm not too convinced with these 2 modules. I guess I need to dig into the C codes of these external modules to boost my confidence level. Till then, I'd stick to Unix domain socket and pipe for my IPC under Python.

Tuesday, June 06, 2006

IPv6 has finally come

Today, the 6th day of June of the year 2006 - or 666 if you like to dramatize a little bit - is the day 6Bone, the experimental IPV6 netwrok will be shut down. Now IPv6 comes to a stage of deployment to the masses.

This is a wake up call for me to ensure that all the boxens I'm using and their corresponding network apps support IPv6. With this, comes a task of learning how to use IPv6 and its tips-and-tricks. Bye-bye 6Bone, Welcome IPv6.

Monday, June 05, 2006

2 weeks full of events

A couple of updates.

First, ITTutor was defaced on 31 May 2006 and up till now is still closed. Apparently the Admin is taking the opportunity, while fixing the defaced page(s), to do some upgrade works.

Secondly, the Klang Valley in Malaysia was shocked by a landslide which claimed 4 lives. A series of finger-pointing trying to find the fault followed right after. The local authority, however, has the lion share for blames - due to repeated complaint by the affected residences months before the incident happend.

Next news, I still couldn't find an SSL library for Python which is easy to use and less confusing for newbies like me. The existing libraries is either too complex for newbies or simply out of date with the current C version.

Finally, the talk in the office is to integrate the procurement system with the fax server, which is running Hylafax. It is very likely I'll be assigned to figure out how to do it.

Friday, June 02, 2006

Managing user account using OpenLDAP

IBM developerWorks features a nice article on implementing a centralize user management using OpenLDAP. Although it's Red Hat specifics, but most of the steps described also applicable to other Linux distributions. I might even try to test the steps in the article myself when I have a free time - may be after the FIFA World Cup is over :)

Thursday, June 01, 2006

The first day of June 2006

A very interesting day.

Today marks the month of June 2006, the month of FIFA World Cup. Along with it come plenty of sleepless night - since all the live telecast would be in the early morning in Malaysia.

Also a very interesting start:
Linux.com featured 2 nice articles on GNU grep and Emacs tips.
Newsforge brought an article on OCSNG - which could be a nice complement to WPKG I'm currently evaluating.