SFTP/SCP Atomic Copy

I’ve come across Mihai Secasiu’s very useful patch for OpenSSH, that enables SCP and SFTP to do atomic copying.

We needed that functionality on one of our servers, so I decided to give it a try. However, we were using OpenSSH 5.3p1 instead of 4.6 (the version the patch was made for) and the patch didn’t apply completely.

After a couple of tweaks, I’ve managed to make it apply on 5.3p1 and, in the same Open Source spirit shown by the original patch author’s , here’s my modified version that applies against 5.3p1:


Check the original patch post on PatchLog for instructions about how to build it and configure. There’s a lot more nice stuff on the site as well.

Nice job Mihai! :)


Dlr counters on the status page

This patch adds separate dlr counters on the status page.

If you use dlrs (Delivery Receipts) with Kannel, you’ve noticed that they’re counted along with MO traffic as incoming messages.

This leads to misunderstandings on how much incoming traffic you’re really sustaining: For example on SMPP, if you request dlrs, depending on the carrier having it enabled or not, you’ll get one or two more “incoming” messages counted (dlrs are very similar to mo messages in structure).

After applying this patch, the status page will display incoming and dlr traffic on separate counter, either for the total amouns as in each and every defined smsc connection. It will also display separate load indicators, so you’ll know at all times if your inbound traffic is actually traffic or just old/delayed dlrs.

Here’s the patch:


As usual, please try it and let me know what you think.


Facebook Risks Exposed!

My kid Juan wrote this wonderful article about the mostly unknown caveats of sharing content on your Facebook account.

Read the full article HERE

PAM Authentication for Kannel

Though kannel already has some pam functionality included, it’s far from optimal imho.

As it is now, to use pam authentication you have to:

1. Configure with –enable-pam and compile.
2. Create an smsbox-user called “pam” with a dummy password.
3. Create a pam configuration file called “kannel” on /etc/pam.d/, with your pam settings.
4. Kannel will then use only pam for authentication, so you could use LDAP, Radius or whatever supported authentication modules you have configured on the box.


* Other smsbox-user‘s are disabled, only the “pam” user is allowed to authenticate.
* All users would get logged as “pam”, so you cannot make settings per users of any kind.
* Only one pam group is allowed.

After applying the patch, pam authentication gets managed with a special group sendsms-pam-user, which shares most of sendsms-user parameters, except for username and password, and adds the acl parameter instead.

group = sendsms-pam-user
acl = kannel
<other sendsms-user parameters>

* You can define as many groups as needed, pointing to different pam configuration files.
* The acl parameter points to the pam module on /etc/pam.d/ (“kannel” in this case, but could be anything you want).
* Pam authentication is only attempted after trying the regular sendsms-user way, so you can have local users and pam users at the same time (local taking precedence).
* Each sendsms-pam-user group will be logged separately, and you’ll also get info about the pam user making the call.

To use the patch:

1. Download the patch here and apply it.
2. Run ./bootstrap.sh
3. Run ./configure –enable-pam
4. make and make install as usual.

As usual, please try it and let me know what you think.


New version: Custom MO parameters on generic http-smsc

NOTE: This patch is already committed to CVS, so if you download the latest CVS version, you’ll get it included.

Here’s a new version of my former patch to add support for custom MO parameters on the “generic” http-smsc.

This new version adds a few extra features:

  • Support to set the response message (nowadays is fixed to “Sent.”).
  • Support to use escape codes on the response message. You can now show the internal message id (or any other message field for what matters) when responding to a successful request.
  • Support to set the response code for successful and failed requests.
  • Documentation!

Download the patch from here.

As usual, please try it and let me know what you think.


Using individual meta-data fields on urls

With the addition of meta-data functionality in Kannel, now it’s possible to pass meta-data between different smsc’s and services.

When defining services or urls to send messages, the new %D parameter gets replaced with the complete meta-data information available.

However, there wasn’t any way to use only part of that data when posting to url’s. This is why I’ve created this patch that allows you to use individual meta-data fields in your urls.


To use it, a new set of parameters is defined, with the following format:


Where group is the meta-data group (for example: smpp, http or foo) and parameter is the individual meta-data parameter you want to replace.

For example, let’s suppose we’re using a generic http-smsc, and we want to pass a couple of extra parameters for a dynamic username and password (some aggregators do that). Right now, that would require patching the source code and inventing some method to pass the extra parameters from the sendsms interface.

With the patch applied, this would be as simple as this:

1. Pass the meta-data parameter on the sendsms request (urlencoded):


2. Define the send-url parameter on your http-smsc to pass those parameters:

send-url = http://myhost/sms?….&username=%#http#user#&password=#http#pass#

Note: I’m defining the http group here, but it could be anything, even the smpp group coming from an smpp bind, in which case the syntax would be #smpp#username# instead.

Download the patch from here.

Please try it and let me know if it works for you.

Custom MO parameters on generic http-smsc

This patch allows you to change the parameter names used when receiving incoming messages (MO’s) using the generic http-smsc.

To use it, you need to add a few extra entries for the parameters you want to be redefined. The format is: generic-param-<original-name> = <new-name>

For example, to redefine from, to, smsc and text:

generic-param-from = “phoneNumber”
generic-param-to = “shortCode”
generic-param-text = “message”
generic-param-smsc = “carrier”

That’s it, you’ll be able to use an url like this then:


Download the patch from here.

As usual, try it and let me know.


New SqlBox release: 0.7.2

I’ve just updated SqlBox. Version 0.7.2 adds:

* rpm target (already on the latest snapshot). You can now run ./configure and then make rpm to build an RPM!
* Support for MS-SQL and Sybase over FreeTDS. You need a current Kannel snapshot to support this.
* Some code cleanups.

You can get it from here.

As usual, try it and let me know what you think.


Retrying the dlrs from the store

If you’re using an external DB for dlr storage, there’s a slight chance that the carrier’s response to your MT (with the dlr information) would arrive after the dlr itself. If this happens, Kannel won’t be able to find the dlr (because it’s not there yet).

This patch implements an sleep and retry mechanism when calling dlr_get(). This aims to solve that problem.

2 new core parameters are defined:

dlr-retry-count -> How many times do we attempt to fetch the dlr? Default: 1
dlr-retry-delay -> How many milliseconds do we sleep before retrying? Default: 0

So, if you don’t set these parameters the behaviour remains as it was before patching. However, if you, for instance, set:

dlr-retry-count = 3
dlr-retry-delay = 200

Kannel will try 3 times in total (the original plus 2 more), pausing 200ms (0.2 seconds) before each attempt. If after the third attempt the DLR’s still missing, Kannel will display a warning as usual.

Download the patch from here: kannel-dlr-retry

Please try it and let me know what you think.



DLR extravaganza

NOTE: This patch was superseded by another one I’ve wrote that adds smsc-admin-id instead. The smsc-admin-id patch was already commited to CVS so the use of the smsc-dlr-alias is now officially deprecated.

A problem you may have faced with dlrs on Kannel: If you’re using dlrs and have more than one bind to a given carrier, you need to name them all the same. Otherwise, if the dlr come back over a different bind than the one you’ve used to send the MT message in the first place, Kannel won’t be able to match them, since they won’t share the same “smsc” field.

This is usually OK. However, you lose the ability to control the binds independently: you cannot shutdown a single bind, for example. The problem worsens yet more if your binds are to different data centers (some carriers have redundant SMSC’s on geographycally distant places).

That’s why I’ve created this patch that adds a new configuration option to SMSC groups:


Using this parameter, you can define an alias to use when storing dlrs, so they will match despite being sent/received over different binds.

For example:

#carrier link 1
group                      = smsc
smsc                       = smpp
smsc-id                  = “link1″
smsc-dlr-alias     = “myalias”
allowed-smsc-id = “link1;mylink”
host                        = “”
#carrier link 2
group                      = smsc
smsc                       = smpp
smsc-id                  = “link2″
smsc-dlr-alias     = “myalias”
allowed-smsc-id = “link2;mylink”
host                        = “”

Using this configuration, you just have to use the “&smsc=mylink” parameter on your send-sms url. The dlr will be stored using the alias “myalias” no matter which of these 2 routes the message takes. When getting the response back, again, it will be matched against “myalias”.

Download the patch here.

Please try it and let me know what you think.