Finally a real weblog

Posted on: Nov 2014

Well, so after years chasing this "dream" (?) I finally I have a good website, self made, beautiful, with the things that I use and without a messy WYSIWYG editor which does what he wants. So as everybody knows, my editor is Vim, and I'm using github's markdown as formating syntax to write this whole website.

How I did this? Well, this site is now automatically generated by a 162 lines python script. Cool isn't it? :-)

You don't believe me? Take a look at the whole code and website (+content) at: https://github.com/nomius/nomius.github.io.

This website support links (doh!), it has an automated weblog created, it uses a clean syntax that you really enjoy writing in like markdown, it also support syntax highlight for programming, mobile support (?) as it use bootstrap under the hood and one of the nicest things, it has a really nice design.

If you want to use this code to create your own site, please, go ahead, it's free software.

Also, this is something I did last year, all my projects are now in GitHub, and sure, this site as well is hosted on GitHub pages. Let me list them and give some explainations:

  • ntunnel: Simple tunnel protocol with RSA keys, signed digests and blowfish cipher using the OpenSSL library and the tuntap device from the Linux kernel and its API.

  • kpkg: kpkg is the binary Kwort package manager. It allows you to install, remove and download and upgrade packages. This is one of Kwort's holy grail.

  • misctools: Interesting miscellaneous scripts (service command for Kwort, a simple virtualization manager, a wireless network manager, a tool to work with certificates, etc...)

  • dmemory: Dynamic memory management C library (educative project). This is an *alloc functions' wrapper. the test file and source code is pretty much self explainatory.

  • nqqueue: NQqueue is a modular, threaded and plugeable queue for Qmail allowing the user to write their own filters for spam, virus, etc. This is one of the coolest projects I have worked on.

  • mttools: A couple of years back, when I started playing around with text formating languages I came up with some basic tools to use the Troff -ms macros. This is a small project that includes a C and Shell troff parser.

  • nomius.github.io: This site and weblog.

  • kwtools: Kwort tools is a set of scripts and applications used in Kwort < 2.4.2, including package manager, user and network manager. This code is now really old and unmaintained but it has some really useful gtkdialog code that I used in the misctools.

  • Kwort: Kwort is a modern and fast Linux distribution that combines powerful and useful applications in order to create a simple system for advanced users who finds a strong and effective desktop. Kwort is based on CRUX, so it's robust, clean and easy to extend. Of course, not hosted at github. ;-)




Updates for everybody!

Posted on: Nov 2011

I'm a disaster to write a blog, sorry for the delay. There have been lot of news in the past few months. Let's enumerate one by one: I created a small project called mttools, and this is basically a set of tools to write good technical documentation, with formated code inside and some pretty nice features. The nice thing about this tools is that it forced me to learn Unix flex :-) You can check out this project at: http://code.google.com/p/mttools

As some of you might have noted, Kwort 3.2 got released, this is a pretty clean and nice release that got some really nice features and improvements. If you like Kwort > 3, please, step by http://www.kwort.org, read the announcement and try it. There's also some nice new features and bug fixes in kpkg, that were deployed with Kwort 3.2, if you're not using Kwort but you're using kpkg, you should step by http://code.google.com/p/kpkg

One of the cool stuff that came up with Kwort 3.2 are the ports; we are now supporting the crux ports, that you can bring to your system by:

  kpkg install httpup rsync fakeroot rsync ports

I'll blog a little on the CRUX ports latter on.

Also there's a new release of ktsuss, just baked. This release has some bug fixes in the su backend and guess what... There's a sudo backend now too! You should get the release at http://code.google.com/p/ktsuss.

NOTE: 1.4 code has critical bugs and is completely unmaintained, so please update to the latest release. I also removed all extra repositories like the one at berlios, github, etc, so there's now only one at google code avoiding confussions.

The last few months I worked a little on LimShSQL and there's a full new re-write with a pretty shinny curses interface in limshsql-rewrite-1.0 branch, I think I should merge it soon and package a release. Check it out here: http://code.google.com/p/limshsql




Goodbye lout... Hello troff!

Posted on: Mar 2011

Five years ago I went to a dissertation on LaTeX given by Guido Macci, I left that dissertation telling myself "Yes, that's the way to go" and I liked formatting systems, by then I only knew LaTeX, but after seeing that in Slackware it was like 100mb in packages I said like "Ooook, wait a second... Is it that big?", it turned out it really was, and not only big, but a real mess under the hood, so I was kinda disappointed and desisted on the idea of using LaTex. Those who know me knows that I'm pretty minimalist, and having a formatting system of 100mb that was a mess was pretty much out of the table, but I still though it was the way to go.

So I spoke to a friend (Emiliano Gavilan) who always liked that stuff and told my "problem" with LaTeX... So Emiliano recommended me to take a look at lout.

That was in the beginning of 2006, so it's been like 5 years now with lout. Nowadays lout is kinda unmaintained, it has some bugs, the output generated is not as professional as LaTeX, and (I bet this is because I'm too lazy to learn them) there are some things that I never wasn't able to do.

So last week I gave a chance to troff, and I keep myself reading the whole weekend, and I really liked, it's stable, small, well tested (almost 40 years :-D), and it is on every Unix out there (this is a BIG plus). I had some troubles inserting with code, but after digging I found vgrind (which I heard is unmaintained so we'll have to check in the future how it goes) which does the job pretty good.

There are tons of books out there written with troff some pretty well known like "Advanced Programming in the UNIX Environment", "The C programming Language" or "The Design and Implementation of the 4.4BSD Operating System", there's a big list here

If you're interested in learning troff, you can read this book: Dale Dougherty & Tim O'Reilly - Unix Text Processing.

I hope this turns out good.

Cheers.




Something that I was waiting for...

Posted on: Feb 2011

I want to share something with you guys... Last week (sorry for the delay) I got an email from Jorgen Thomsen telling me that gnu-pop3d was released:

Hello I just released GNU -pop3d 0.9.13 which is a more stable release than 0.9.12 http://jth.net/virtual.html In a short time I will release 0.9.14 which will implement IPv6 support.

So great, a new gnu-pop3d is available, so I saw the changelog and I saw this:

Bugfix: certain login methods did not work (David B. Cortarello)

Pretty happy about the merging of my patch into mainstream. Thanks Jorgen!

Cheers!




GNU pop3d fix

Posted on: Nov 2010

Wooooo, kinda a lot without saying something here! Well, I took some sabbatical months of blogging ;-)

Recently I've been working on a mail server, and those who know me, knows that I'm pretty minimalistic. So I started with exim and gnu-pop3d (no imap for this) with stunnel to provide ssl support. I use Unix users for authentication, but gnu-pop3d had a (pretty small) bug which made it reject any authentication whether it is right or wrong. So I wrote a patch to provide a fix and sent it to Jorgen Thomsen. He answered me on Wednesday telling me that the patch was accepted.

Anyways, I leave the patch here: gnu-pop3d-0.9.12-fixpasswdlogin.patch

Cheers!




Hidding messages in ICMP packets

Posted on: Feb 2010

Hello everybody. A new month, a new article (I wish I could do this so periodically).

Today I'm going to show you something that I've been playing with. As you probably know (if you don't, I'm just telling you now :-)), the ICMP packets provides an arbitrary data space right after the ICMP header. Normally, no one use it, since ICMP is a control protocol that has all its usage right inside of it, leaving this data space useless.

A few days ago, I saw someone connected on Cinetix and he was just connected, but not on the IRC server and I didn't know who he or she was. So an idea started to flow around my head "What about if I could send messages with ICMP packets".

So actually this is what I did... I wrote a tool to put a message in the data space and send it using the ICMP type 7 which is unassigned (for example, ping is the type 8). The problem is that the kernel just drop type 7 (as we all assume) and the data space is also dropped in any icmp packet. So I wrote a kernel patch that print the message in the output of dmesg or /var/log/message if you have set KERN_NOTICE to be displayed (I think klogd -c 6 does).

With this, you can send to a friend a message of the kind "Hey. This is David, I'm online on irc (jabber or whatever), jump in!" and it will be displayed in the system logs as a kernel notice.

Please, take note that this is not a chat system, but an "emergency system", so don't start using it as an everyday conversation protocol. This also isn't a patch that should be in the kernel mainstream, since ICMP packets of type 7 is unassigned, and NOT a communication protocol.

What about security?

Well, you might start asking yourself this "What if someone from the outside starts flooding my logs with dumb messages?". Right, well, the answer to this is netfilter; use iptables to drop these kind of package. Something like this:

iptables -A INPUT -p icmp --icmp-type 7 -j DROP

As you might know or guess, you can also block only one IP address or accept from a certain network like this:

iptables -A INPUT -p icmp --icmp-type 7 \! -s 10.0.0.1/24 -j DROP

Use more complex rules creating policies like "if someone exceed the number of 5 ICMP type 7 packets in a minute, drop any packet from the IP address".

Enough with the talking... How do I use it?

Great, right to the point. So the steps:

  1. First of all, patch and compile your kernel.
cd linux-2.6.31 && patch -p1 < patch_icmp_type_7_messages.diff

And compile and install your new kernel using the way you normally do (make config/menuconfig, etc...)

  1. Then compile the icmp_send.c program:
gcc icmp_send.c -o icmp_send
  1. Send a test message:
./icmp_send 127.0.0.1 "Hello world"
  1. Check out the dmesg output:
./dmesg | grep "ICMP 7 Message"

Get it! Anyways, this is a really nice thing to play with and I hope people find it useful. You can get the kernel patch and the ICMP message program from the links below.

patch_icmp_type_7_messages.diff

icmp_send.c

Have fun.




Using the ZTE MF 110 with 3g Movistar (Argentina on Linux

Posted on: Jan 2010

Hello all, Today I'm going to explain how to do something really simple. As some of you might already know, I got this year a EEE PC netbook (1000HA). I have to admit that this baby is going great, I'm running the latest Kwort on it and it's really resource saving if you know how to set it up correctly. If I add this netbook a 3g connection, I can say that I'm online everywhere almost all of the time. Well, this is what happened... As most of you already know, I've been working for Accenture for over a year now and they provided me (and some of my co-workers) a 3g modem with internet connection, which is pretty nice. So, on january 1st after all the people who came my home to celebrate the new year left I sitted on the computer to figure out how to make it work. This is a ZTE MF 110, and I found some people who made it work (kinda) or those who plugged it in at ubuntu and said that it works OoTB. Well, this is true kind of, but I hate when you don't really know how things works. Also, I found some people who made it parcially work with wvdial, which is a nice tool also. So, my quest was to make it work with plain pppd. And this isn't really hard to do if you know a little how to play with the AT commands.

Ok, let's put the hands in the mud, first of all, I'm one of those people who likes to have a latest kernel tuned for my device, so this implies that yeah, I compile my own kernel with almost every release... In this case we are compiling 2.6.32.2. So, for this you'll need the usb mass storage system in order to be able to switch from it to the modem mode.

Device Drivers -> USB Support -> (Select your usb version, ehci, uhci or ohci) USB Mass Storage support

Now, this GSM modem (as several others) needs the serial support... Well, actually, this is a serial GSM modem that you want to jack into the USB bus. So you need:

Device Drivers -> USB Support -> USB Serial Converter support

This will create the usbserial module. And now, you need the GSM modem support. So for this, you have to select:

Device Drivers -> USB Support -> USB Serial Converter support -> USB driver for GSM and CDMA modems

I would recommend you to compile them as modules (M) instead of built in, as this isn't a feature that you will be running all the time, so you can unload modules and free some memory (not too much, but everything counts nowadays).

I'm assumming that you already have the PPP support, if not, it's in the device drivers and Network Devices. But if you're reading this, you might already know.

Now, everything is ready for us to set it up.

We need usbmodeswitch, this tool will allow us to switch from the "ZeroCD" mode to the modem mode in order to allow us to call our provider. Basically we need this config (/etc/usbmodeswitch.conf):

DefaultVendor=0x19d2
DefaultProduct=0x2000

TargetVendor=0x19d2
TargetProduct=0x0031

MessageEndpoint=0x1
MessageContent="55534243b8fe6681000000000000061b000000020000000000000000000000"

This config file will make the usbmodeswtich to swtich the device 0x2000, of the vendor 0x19d2, to 0x0031 sending the message pointed by MessageContent. If the usbstorage module is loaded and you run:

usb_modeswtich -c /etc/usb_modeswitch.conf

And then you run lsusb you'll see the product id changed from 2000 to 0031.

If you got here, now it comes to nice part. In order for us to not use wvdial, we need a call script (also called chat script). I'm going to show you you the script I wrote (/etc/ppp/peers/chats/movistar):

ABORT BUSY ABORT 'NO CARRIER'
ABORT VOICE ABORT 'NO DIALTONE'
ABORT 'NO DIAL TONE' ABORT 'NO ANSWER'
ABORT DELAYED
'' ATZ
OK ATQ0\sV1\sE1\sS0=0\s&C1\s&D2\s+FCLASS=0
OK AT+CGDCONT=1,"IP","internet"
OK-AT-OK ATX3DT*99#
CONNECT \d\c

This basically it reads like this: abort in any of the conditions above (no carrier, no dialtone, etc...), then reset the modem waiting for nothing, initialize the modem, find out the CID for an APN GPRS, dial and connect. There's information about Hayes AT commands all over the web, so if you're interested you can google it yourself. :-)

Well, now we have to set up our user and password:

echo -e "internet\t*\tinternet" >> /etc/ppp/chap-secrets

And finally, the ppp configuration itself (/etc/ppp/peers/movistar):

lock
hide-password
noauth
connect "/usr/sbin/chat -v -f /etc/ppp/peers/chats/movistar"
/dev/ttyUSB2
460800
defaultroute
noipdefault
user "internet"
mtu 1492
ipparam movistar

Most of this options are self explanatory, but the importants one are the connect line and the "/dev/ttyUSB2" one. The first one tells pppd to use the chat program to connect the other point and the chat script that will be used (/etc/ppp/peers/chats/movistar, that we created before), if, for example, you set up a pptp connection you'll see this line pointing to the pptp client program. The second one tells pppd the modem device, maybe you have to play a little bit with this one trying /dev/ttyUSB2 or /dev/ttyUSB3 (if you don't wan't to try you can use minicom to find out, good luck with that :-P).

Well, now everything is ready to connect, you just need to run:

pppd call movistar

From now one, if you restart your laptop/netbook or normal PC, all you have to do is:

usb_modeswitch
sleep 1  # Let the device sync with the switch
pppd call movistar



The kpkg issues

Posted on: Dec 2009

Hello everybody... Today I'm going to speak about kpkg. Well, I wrote 4 package managers before I started kpkg, there was kwt-get, kum, kget and another one I can't remember. With every package manager I wrote things where from a very simple start, allowing to install, search and remove packages to a more complex usage allowing several mirrors, dependencies resolution out of the box, and finally the idea of third party packages (this last idea appeared in kpkg), package series, etc. Let's analyze those 4 functionalities: 1.- More than one mirror was something asked, but once I implemented, there wasn't more than 3 or 4 mirrors out there. 2.- Dependencies resolution is a huge deal, the real thing is that under the hood it sucks, and I see why big distributions with lots of developers has package managers supporting this feature, as they have several developers who everyone takes 10 or 20 packages, build them and fill the databases with the dependency tree. The fact is that this feature is bad implemented in any distribution, it shouldn't be something that the developer has to fill (the database with its dependencies), it should be something auto generated at build time, I don't know, a file listing its dependencies generated by configure (when using autotools) or something similar. I could spend like an hour talking about this feature since I made 3 different implementations of its resolution algorithm. 3.- Well, third party packages (also known as tpp). This actually wasn't a feature it was a way to deal with an inconsistency in kpkg, the fact that packages were registered in mirror databases, if one was repeated, it has to be a "third party package", so kpkg (without any environment variable altering its normal course) treated it as a non identified package (or a package provided by a third party developer not included in any mirror). Of course someone could deal with this using environment variables (MIRROR, STANDALONE and SERIE). So installing a package from the console without having it in a mirror and keeping the database clean without tpp was a huge deal. With tpp, kpkg tried to do, with the same tool, what debian does with a separated tool (dpkg). 4.- Series was kinda one of those features that supposed to help but didn't, in fact, it complicated things. If you start looking at a package system you think "Great, series, this is a way to pre-hash every package", well, it kinda did that job, but complicated all other things, actually this feature was one of those that pushed the "third party packages" "feature".

Despite with dependency resolution (now, a few years back it was supported), kpkg support all this features. By this time you might be asking "Why god why this package manager is so complex and twisted"... Well, the fact is that even I hate kpkg nowadays. Also, as most of you might know, kpkg is written in bash, with leave us a lot of issue. Why? Well, kpkg makes use of several console tools included in packages like coreutils (ls, rm, mktemp, md5sum, etc), findutils (find), sed, awk, grep, wget, tar, lzma, etc... Can you imagine what could happen if you try to update for example the coreutils? Well, to understand this question and being able to answer it, you need to know some of the kpkg internals, but summarizing what kpkg does is "Download the new package, remove the old package, install the new package", and almost every package managers do this (there's also some other algorithms to deal with this but you need to save more data of every file included in the package). Now, if you upgrade to a new version of, for example, the coreutils, what kpkg do is: "Download the new coreutils, remove the old coreutils, install the new coreutils", if you remove coreutils kpkg starts failing pathetically leaving your system out of use (sorry, toilet cleaning :-P) and we all have to pull the shades down and go home. In fact this happened some weeks ago and a user came to me with insults, ranting and all the bad things you can imagine. Well, he was right about my mistake, but I'm human and I can make tons of those (and thank god we all still making mistakes, it's a proof that we still humans) and the fact is that no one is paying me for developing Kwort and all its tools, so take it easy. Anyways, this leave us to the fact that we can't upgrade some (several) packages and with them, of course, the libc.

So, I'm dealing with all this problems re-writing kpkg in what we can call "kpkg new generation" (LOL, it even sounds cool eh? :-P). How I dealed with all this problems? Well, some of those original "features" were dropped, "dependencies resolution" was out of the table way before starting, "series" support was removed as with the new database it isn't needed anymore, and third party packages was also dropped since the new approach is more consistent. What about the fact that you can't upgrade several packages? Well, kpkg is now written in C and static compiled (so everything can be upgraded :-)).

The new kpkg use sqlite3 as database backend, libarchive for package decompressing (giving us support for tgz, tbz2, tar, lzma, xz, zip, etc) and libcurl for package retrieving which leave us support for tons of protocols. And every piece of the code is very well documented with doxygen which will help everyone who wants to read the source code.

So far, the new implementation of kpkg (in C) has support for almost the same options (search, install, remove, provides, update and download) the actual kpkg has, and only the upgrade support is the only one missing (I hope I have time to code it this week). So I will try to upload the source to github as soon as I can, so everyone can start to find bugs in it and improve it.

See you soon guys, and if I don't before Christmas, Merry Christmas :-)

Cheers!




New Kpkg hosting

Posted on: Dec 2009

Well, the C version of kpkg is now hosted at: http://code.google.com/p/kpkg. It would be cool if people start checking it out.

Upgrade support is working partially, as only one package at the time can be upgrated, I will try to finish the whole upgrade support soon.

If any people want to use kpkg in their personal distributions (I don't think ubuntu/suse/etc... users will want to run kpkg on their systems, but who knows), it would be nice to know.

Also patches to add more functionality, fixes or any kind of power, are always welcome.

Oh, and btw, the sqlite databases structures (for mirrors and personal systems) are included in datastructs.h. If you have any questions, please ask here or mail me. :-)

Cheers!




Vim bug using ctags

Posted on: Oct 2009

Well, lot of people know that I'm a vim fan and that I use it everyday, to me is like the killer app that everyone should know how to use in Unix. Even at work, I'm a programmer (doing C on Unix now), and some of my fellows were using Eclipse and after I show them Vim, they was like "woooo, I can use this editor as an IDE and still can use my machine for do something else while programming" (I was like, blame the one who introduced you to Eclipse :-P).

Anyways, I like using tags, allows me to browse the code really fast (for those using Eclipse, I think is like if you press F3 over a function name). But I found this weird behavior using ctags+vim. See the above code:

  1 #include <stdio.h>
  2
  3 int asd(int s,
  4         char a);
  5
  6 int main(int argc, char *argv[])
  7 {
  8     asd(1, 's');
  9     return 0;
 10 }
 11
 12 int asd(int s,
 13         char a)
 14 {
 15     return s;
 16 }

When I press ctrl+] over asd in line 8, it takes you to the 3rd line instead to the 12th... There's a "workaround" to this behavior, using --excmd=number while running ctags put the line numbers in the tags file (without this option ctags puts just an 'f' identifier to tell the editor that it is on that file). But it is just a visualization workaround, because you can't put any new line (or remove) in those files or your tags file will screw the tags file.

Does anyone knows a solution to this issue?

Thanks.