Store Tools for Kannel

One of the problems with Kannel’s store formats is that they’re binary packed and it’s not easy to manipulate them. Specially with the store-file format, getting rid of a single message requires editing the binary file and it’s not a trivial task. Converting between file and spool formats it’s not easy, and if you want to export the content to some other format you need to rely on the web interface.

That’s why I’ve created these simple store-manipulation program: store_tools.

What store_tools do is to read the store location and format from your kannel.conf file and allows you to perform a series of commands with it. The available commands are:

list [limit/start] [limit] Allows you to list the content of the store. Optional parameters allows you to list limit records, or start at a given record and also limit the amount returned.
delete <uid> Allows you to delete a message. You can retrieve the uid by using the list command.
export <format> <location> Allows you to export the store into another format. Possible formats are: text, xml, html, spool and file. <location> specifies the path where you want the exported data to be written.

NOTE: Since the delete command modifies the store, you should do it with kannel stopped.

Please download the patch here: kannel_store_tools

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

-Alex-

Comments (10)

AndrewOctober 14th, 2009 at 6:58 AM

I’m running the stock kannel from CentOS 5.3 and I’ve also installed the kannel-devel and libxml2 package. Now how do I compile your code? I don’t have the complete kannel source and don’t intent to rebuild it.

alexOctober 14th, 2009 at 7:04 AM

The code is intended to be built along with the rest of Kannel, a lot of macros and definitions are inherited from other parts of the code.
The easy way is to compile it with the rest, you don’t need to _install_ kannel again anyway, just compile it and then copy the store_tools executable from the test/ folder on the source tree.

AndrewOctober 16th, 2009 at 12:14 AM

Thanks for the reply. As suggested, I’ve managed to built it with the source rpm of the same version that is installed on my system. I haven’t got any message in the store file yet but when I tested listing it, I’m getting a segmentation fault at the end of the output. I’m running kannel-1.4.2-1.

$ store_tools -c /etc/kannel.conf list
Listing records 1 -> 100
+-���<————————————-+-p��<———–+- ��<———–+-���<—————+-�rj—————————————————+
| message id | from | to | smsc | text |
+-p��<————————————-+-p��<———–+- ��<———–+-���<—————+—————————————————-+
| Store is Empty |
+- ��<————————————-+- ��<———–+-`��<———–+-p��<—————+-���<—————————————————+
Segmentation fault

ChaitanyaJanuary 11th, 2010 at 6:27 AM

Hey !

I am already using kannel. Can you please guide me how to add this patch into Live Kannel ?

alexJanuary 11th, 2010 at 8:41 AM

You need to patch the source code (usually placing the file on your source code root and running something like “patch -p0 < kannel_store_tools.patch") and recompile. You'll find the store_tools executable on the test/ folder.

michelangeloFebruary 2nd, 2010 at 4:21 AM

I’m using Kannel v1.4.3 and i recompiled all the application, with your tool included. It created the store_tools executable in the test folder, but it also gives me segmentaion fault:
store_tools -c ~/kannel/config/kannel.conf list
Listing records 1 -> 100
Segmentation fault

Do you have an ideea why this is happening?

alexFebruary 2nd, 2010 at 6:43 AM

Can you give me more information? Platform? 32/64 bits? A backtrace from gdb would be useful as well.

saleemAugust 30th, 2010 at 5:51 AM

I have same issue as michelangelo.

Kannel version: 1.4.3
OS: debian 5.0.3 64 bit

Please note kannel-status shows store size is 11.

Also, please explain “A backtrace from gdb would be useful as well”

This is log printed by store_tools

x2.u:/opt/gateway-1.4.3# test/store_tools -c gw/smskannel.conf list
Listing records 1 -> 100
+-`��————————————-+-`��———–+-@��———–+-���—————+-@��—————————————————+
| message id | from | to | smsc | text |
*** glibc detected *** test/store_tools: malloc(): memory corruption: 0x00000000024cf760 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f8214f10928]
/lib/libc.so.6[0x7f8214f1315c]
/lib/libc.so.6(__libc_malloc+0x98)[0x7f8214f14a58]
test/store_tools(gw_native_malloc+0x11)[0x415511]
test/store_tools(repeat_char+0x1a)[0x4097ea]
test/store_tools(print_sep+0xa0)[0x4098c0]
test/store_tools(print_header+0xb9)[0x409a19]
test/store_tools(main+0x275)[0x409c95]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7f8214ebb1a6]
test/store_tools[0x4092a9]
======= Memory map: ========
00400000-0043f000 r-xp 00000000 08:01 13665330 /opt/gateway-1.4.3/test/store_tools
0063e000-00640000 rw-p 0003e000 08:01 13665330 /opt/gateway-1.4.3/test/store_tools
00640000-006da000 rw-p 00640000 00:00 0
024bc000-02540000 rw-p 024bc000 00:00 0 [heap]
7f8210000000-7f8210021000 rw-p 7f8210000000 00:00 0
7f8210021000-7f8214000000 —p 7f8210021000 00:00 0
7f8214427000-7f821443d000 r-xp 00000000 08:01 3244035 /lib/libgcc_s.so.1
7f821443d000-7f821463d000 —p 00016000 08:01 3244035 /lib/libgcc_s.so.1
7f821463d000-7f821463e000 rw-p 00016000 08:01 3244035 /lib/libgcc_s.so.1
7f821463e000-7f8214648000 r-xp 00000000 08:01 3245225 /lib/libnss_files-2.7.so
7f8214648000-7f8214848000 —p 0000a000 08:01 3245225 /lib/libnss_files-2.7.so
7f8214848000-7f821484a000 rw-p 0000a000 08:01 3245225 /lib/libnss_files-2.7.so
7f821484a000-7f8214852000 r-xp 00000000 08:01 3245236 /lib/libcrypt-2.7.so
7f8214852000-7f8214a52000 —p 00008000 08:01 3245236 /lib/libcrypt-2.7.so
7f8214a52000-7f8214a54000 rw-p 00008000 08:01 3245236 /lib/libcrypt-2.7.so
7f8214a54000-7f8214a82000 rw-p 7f8214a54000 00:00 0
7f8214a82000-7f8214a98000 r-xp 00000000 08:01 4032635 /usr/lib/libz.so.1.2.3.3
7f8214a98000-7f8214c98000 —p 00016000 08:01 4032635 /usr/lib/libz.so.1.2.3.3
7f8214c98000-7f8214c99000 rw-p 00016000 08:01 4032635 /usr/lib/libz.so.1.2.3.3
7f8214c99000-7f8214c9b000 r-xp 00000000 08:01 3245230 /lib/libdl-2.7.so
7f8214c9b000-7f8214e9b000 —p 00002000 08:01 3245230 /lib/libdl-2.7.so
7f8214e9b000-7f8214e9d000 rw-p 00002000 08:01 3245230 /lib/libdl-2.7.so
7f8214e9d000-7f8214fe7000 r-xp 00000000 08:01 3245238 /lib/libc-2.7.so
7f8214fe7000-7f82151e6000 —p 0014a000 08:01 3245238 /lib/libc-2.7.so
7f82151e6000-7f82151e9000 r–p 00149000 08:01 3245238 /lib/libc-2.7.so
7f82151e9000-7f82151eb000 rw-p 0014c000 08:01 3245238 /lib/libc-2.7.so
7f82151eb000-7f82151f0000 rw-p 7f82151eb000 00:00 0
7f82151f0000-7f82153b2000 r-xp 00000000 08:01 4037376 /usr/lib/libmysqlclient_r.so.15.0.0
7f82153b2000-7f82155b1000 —p 001c2000 08:01 4037376 /usr/lib/libmysqlclient_r.so.15.0.0
7f82155b1000-7f82155fc000 rw-p 001c1000 08:01 4037376 /usr/lib/libmysqlclient_r.so.15.0.0
7f82155fc000-7f82155fe000 rw-p 7f82155fc000 00:00 0
7f82155fe000-7f8215750000 r-xp 00000000 08:01 4036826 /usr/lib/libxml2.so.2.6.32
7f8215750000-7f821594f000 —p 00152000 08:01 4036826 /usr/lib/libxml2.so.2.6.32
7f821594f000-7f8215959000 rw-p 00151000 08:01 4036826 /usr/lib/libxml2.so.2.6.32
7f8215959000-7f821595a000 rw-p 7f8215959000 00:00 0
7f821595a000-7f8215970000 r-xp 00000000 08:01 3245241 /lib/libpthread-2.7.so
7f8215970000-7f8215b70000 —p 00016000 08:01 3245241 /lib/libpthread-2.7.so
7f8215b70000-7f8215b72000 rw-p 00016000 08:01 3245241 /lib/libpthread-2.7.so
7f8215b72000-7f8215b76000 rw-p 7f8215b72000 00:00 0
7f8215b76000-7f8215bf8000 r-xp 00000000 08:01 3245243 /lib/libm-2.7.so
7f8215bf8000-7f8215df7000 —p 00082000 08:01 3245243 /lib/libm-2.7.so
7f8215df7000-7f8215df9000 rw-p 00081000 08:01 3245243 /lib/libm-2.7.so
7f8215df9000-7f8215e0e000 r-xp 00000000 08:01 3245237 /lib/libnsl-2.7.so
7f8215e0e000-7f821600d000 —p 00015000 08:01 3245237 /lib/libnsl-2.7.so
7f821600d000-7f821600f000 rw-p 00014000 08:01 3245237 /lib/libnsl-2.7.so
7f821600f000-7f8216011000 rw-p 7f821600f000 00:00 0
7f8216011000-7f8216021000 r-xp 00000000 08:01 3245239 /lib/libresolv-2.7.so
7f8216021000-7f8216221000 —p 00010000 08:01 3245239 /lib/libresolv-2.7.so
7f8216221000-7f8216223000 rw-p 00010000 08:01 3245239 /lib/libresolv-2.7.so
7f8216223000-7f8216225000 rw-p 7f8216223000 00:00 0
7f8216225000-7f821622d000 r-xp 00000000 08:01 3245229 /lib/librt-2.7.so
7f821622d000-7f821642c000 —p 00008000 08:01 3245229 /lib/librt-2.7.so
7f821642c000-7f821642e000 rw-p 00007000 08:01 3245229 /lib/librt-2.7.so
7f821642e000-7f821644a000 r-xp 00000000 08:01 3245232 /lib/ld-2.7.so
7f821663d000-7f8216642000 rw-p 7f821663d000 00:00 0
7f8216645000-7f8216649000 rw-p 7f8216645000 00:00 0
7f8216649000-7f821664b000 rw-p 0001b000 08:01 3245232 /lib/ld-2.7.so
7fff1e635000-7fff1e64a000 rw-p 7ffffffea000 00:00 0 [stack]
7fff1e7fe000-7fff1e7ff000 r-xp 7fff1e7fe000 00:00 0 [vdso]
ffffffffff60000Aborted

VeerabahuNovember 23rd, 2010 at 9:25 AM

on running the same following error is dumped
{
Listing records 1 -> 100
+-�+————————————-+-X+———–+-X+———–+-X+—————+-X+—————————————————+
| message id | from | to | smsc | text |
+-Z+————————————-+-(Y+———–+-xX+———–+-X+—————+-�+————————————————–+
*** glibc detected *** free(): invalid next size (fast): 0x0944c0c8 ***
Aborted

}
eventually nothing is listed
command used is test/store_tools -c kannel.conf list
Linux RHEL 4 32 bit version
(GCC) 3.4.6 20060404 (Red Hat 3.4.6-8)

thuyleJanuary 18th, 2011 at 1:54 AM

I tried, it worked but after deleting about 500 messages, it shew this error when I were trying to list messages again:
./store_tools -c /etc/kannel/kannel.conf list
Listing records 1 -> 100
+-˜Q®————————————-+-pQ®———–+-ˆQ®———-+-ˆQ®—————+- Q®—————————————————+
| message id | from | to | smsc | text |
+-°Q®————————————-+-pQ®———–+-ˆQ®———-+-ˆQ®—————+- Q®—————————————————+
| f2dd97f9-7a0e-4fb2-9cb1-f54325a4e504 | +84904539184 | +047527 | VMS | XSMB |
*** glibc detected *** ./store_tools: free(): invalid next size (fast): 0x08a687d0 ***
======= Backtrace: =========
/lib/libc.so.6[0x9f85a5]
/lib/libc.so.6(cfree+0x59)[0x9f89e9]
./store_tools(octstr_destroy+0x3d)[0x8069f4d]
./store_tools(octstr_format_valist_real+0x213)[0x806b4f3]
./store_tools(octstr_format+0x1b)[0x806be9b]
./store_tools[0x8051820]
./store_tools[0x8051979]
./store_tools[0x8051e68]
./store_tools(main+0x27b)[0x804fa8b]
/lib/libc.so.6(__libc_start_main+0xdc)[0x9a4e9c]
./store_tools[0x804f361]
======= Memory map: ========
00101000-0022d000 r-xp 00000000 fd:00 3947847 /usr/lib/libxml2.so.2.6.26
0022d000-00232000 rwxp 0012c000 fd:00 3947847 /usr/lib/libxml2.so.2.6.26
00232000-00233000 rwxp 00232000 00:00 0
00235000-0035f000 r-xp 00000000 fd:00 2228298 /lib/libcrypto.so.0.9.8e
0035f000-00372000 rwxp 00129000 fd:00 2228298 /lib/libcrypto.so.0.9.8e
00372000-00376000 rwxp 00372000 00:00 0
00376000-003b1000 r-xp 00000000 fd:00 2229671 /lib/libsepol.so.1
003b1000-003b2000 rwxp 0003b000 fd:00 2229671 /lib/libsepol.so.1
003b2000-003bc000 rwxp 003b2000 00:00 0
00483000-00485000 r-xp 00000000 fd:00 2228262 /lib/libcom_err.so.2.1
00485000-00486000 rwxp 00001000 fd:00 2228262 /lib/libcom_err.so.2.1
00488000-004ae000 r-xp 00000000 fd:00 3945735 /usr/lib/libk5crypto.so.3.1
004ae000-004af000 rwxp 00025000 fd:00 3945735 /usr/lib/libk5crypto.so.3.1
004b1000-004f5000 r-xp 00000000 fd:00 2228280 /lib/libssl.so.0.9.8e
004f5000-004f9000 rwxp 00043000 fd:00 2228280 /lib/libssl.so.0.9.8e
00970000-0098b000 r-xp 00000000 fd:00 2228286 /lib/ld-2.5.so
0098b000-0098c000 r-xp 0001a000 fd:00 2228286 /lib/ld-2.5.so
0098c000-0098d000 rwxp 0001b000 fd:00 2228286 /lib/ld-2.5.so
0098f000-00ae2000 r-xp 00000000 fd:00 2229116 /lib/libc-2.5.so
00ae2000-00ae4000 r-xp 00152000 fd:00 2229116 /lib/libc-2.5.so
00ae4000-00ae5000 rwxp 00154000 fd:00 2229116 /lib/libc-2.5.so
00ae5000-00ae8000 rwxp 00ae5000 00:00 0
00aea000-00aed000 r-xp 00000000 fd:00 2229659 /lib/libdl-2.5.so
00aed000-00aee000 r-xp 00002000 fd:00 2229659 /lib/libdl-2.5.so
00aee000-00aef000 rwxp 00003000 fd:00 2229659 /lib/libdl-2.5.so
00af1000-00b06000 r-xp 00000000 fd:00 2229664 /lib/libpthread-2.5.so
00b06000-00b07000 r-xp 00015000 fd:00 2229664 /lib/libpthread-2.5.so
00b07000-00b08000 rwxp 00016000 fd:00 2229664 /lib/libpthread-2.5.so
00b08000-00b0a000 rwxp 00b08000 00:00 0
00b0c000-00b33000 r-xp 00000000 fd:00 2229660 /lib/libm-2.5.so
00b33000-00b34000 r-xp 00026000 fd:00 2229660 /lib/libm-2.5.so
00b34000-00b35000 rwxp 00027000 fd:00 2229660 /lib/libm-2.5.so
00b37000-00b49000 r-xp 00000000 fd:00 3945618 /usr/lib/libz.so.1.2.3
00b49000-00b4a000 rwxp 00011000 fd:00 3945618 /usr/lib/libz.so.1.2.3
00b4c000-00b53000 r-xp 00000000 fd:00 2229665 /lib/librt-2.5.so
00b53000-00b54000 r-xp 00007000 fd:00 2229665 /lib/librt-2.5.so
00b54000-00b55000 rwxp 00008000 fd:00 2229665 /lib/librt-2.5.so
00b57000-00b6d000 r-xp 00000000 fd:00 2229672 /lib/libselinux.so.1
00b6d000-00b6f000 rwxp 00015000 fd:00 2229672 /lib/libselinux.so.1
00b9a000-00b9b000 r-xp 00b9a000 00:00 0 [vdso]
00c59000-00c6e000 r-xp 00000000 fd:00 2229663 /lib/libnsl-2.5.so
00c6e000-00c6f000 r-xp 00014000 fd:00 2229663 /lib/libnsl-2.5.so
00c6f000-00c70000 rwxp 00015000 fd:00 2229663 /lib/libnsl-2.5.so
00c70000-00c72000 rwxp 00c70000 00:00 0
00c74000-00c7f000 r-xp 00000000 fd:00 2229661 /lib/libgcc_s-4.1.2-20080825.so.1
00c7f000-00c80000 rwxp 0000a000 fd:00 2229661 /lib/libgcc_s-4.1.2-20080825.so.1
00d24000-00d51000 r-xp 00000000 fd:00 3942427 /usr/lib/libgssapi_krb5.so.2.2
00d51000-00d52000 rwxp 0002d000 fd:00 3942427 /usr/lib/libgssapi_krb5.so.2.2
00d64000-00d66000 r-xp 00000000 fd:00 2228317 /lib/libkeyutils-1.2.so
00d66000-00d67000 rwxp 00001000 fd:00 2228317 /lib/libkeyutils-1.2.so
00d69000-00d79000 r-xp 00000000 fd:00 2229678 /lib/libresolv-2.5.so
00d79000-00d7a000 r-xp 0000f000 fd:00 2229678 /lib/libresolv-2.5.so
00d7a000-00d7b000 rwxp 00010000 fd:00 2229678 /lib/libresolv-2.5.so
00d7b000-00d7d000 rwxp 00d7b000 00:00 0
00dcf000-00dd7000 r-xp 00000000 fd:00 3940306 /usr/lib/libkrb5support.so.0.1
00dd7000-00dd8000 rwxp 00007000 fd:00 3940306 /usr/lib/libkrb5support.so.0.1
00e5f000-00e69000 r-xp 00000000 fd:00 2229196 /lib/libnss_files-2.5.so
00e69000-00e6a000 r-xp 00009000 fd:00 2229196 /lib/libnss_files-2.5.so
00e6a000-00e6b000 rwxp 0000a000 fd:00 2229196 /lib/libnss_files-2.5.so
04461000-044f4000 r-xp 00000000 fd:00 3942417 /usr/lib/libkrb5.so.3.3
044f4000-044f7000 rwxp 00092000 fd:00 3942417 /usr/lib/libkrb5.so.3.3
08048000-08083000 r-xp 00000000 fd:00 4588417 /home/thuylx/gateway-1.4.3/test/store_tools
08083000-08084000 rw-p 0003b000 fd:00 4588417 /home/thuylx/gateway-1.4.3/test/store_tools
08084000-08112000 rw-p 08084000 00:00 0
089f1000-08a96000 rw-p 089f1000 00:00 0 [heap]
b7f7f000-b7f85000 rw-p b7f7f000 00:00 0
b7f90000-b7f91000 rw-p b7f90000 00:00 0
bfe5b000-bfe70000 rw-p bffe9000 00:00 0 [stack]
Aborted