Authentication username in Astersik SIP peer

Asterisk use peername as username during SIP inbound digest authentication.
This patch add authuser parameter in SIP peer definition and use authuser in digest authentication:

Peer definition in /etc/asterisk/sip.conf


[pietro](sip-client-base)
authuser=MyUsername
secret=XXXXX
qualify=yes
nat=yes

Peer definition in my SIP client (Twinkle)
client configuration

REGISTER message from my SIP client

REGISTER sip:bertera.it SIP/2.0
Via: SIP/2.0/UDP 88.149.226.66:10458;rport;branch=z9hG4bKkqpevlic
Max-Forwards: 70
To: “Pietro”
From: “Pietro” ;tag=ntlug
Call-ID: mqezxbywgtulavj@bertuccia
CSeq: 681 REGISTER
Contact: ;expires=3600
Authorization: Digest username=”MyUsername”,realm=”bertera.it”,nonce=”27f804de”,uri=”sip:bertera.it”,response=”47dbf0a57d80faffd148b58d84edc2db”,algorithm=MD5 Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,PRACK,REFER,NOTIFY,SUBSCRIBE,INFO,MESSAGE
User-Agent: Twinkle/1.4.2
Content-Length: 0

Message in Asterisk CLI:

[Feb 4 23:23:35] NOTICE[24864]: chan_sip.c:13016 register_verify: Trying athenticate peer ‘pietro’ using authuser: ‘MyUsername’
— Registered SIP ‘pietro’ at 88.149.226.66 port 10458

REGISTER Confirmation from Asterisk:

SIP/2.0 200 OK
Via: SIP/2.0/UDP 88.149.226.66:10458;branch=z9hG4bKkqpevlic;received=88.149.226.66;rport=10458
From: “Pietro” ;tag=ntlug
To: “Pietro” ;tag=as49faff1f
Call-ID: mqezxbywgtulavj@bertuccia
CSeq: 681 REGISTER
Server: Asterisk PBX 1.6.2.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Expires: 3600
Contact: ;expires=3600
Date: Thu, 04 Feb 2010 22:23:35 GMT
Content-Length: 0

http://www.bertera.it/software/asterisk-stuff/asterisk-1.6.2.2-sip-peer-authuser-patch.diff

plugin di vim per salvarsi dalla noia

Plugin per incrementare il serial in un file di zona di Bind:

root@dumbo:/etc/bind# cat ~/.vim/plugin/Soa.vim
function! INCSERIAL(date, num)
        if (strftime("%Y%m%d") == a:date)
                return a:date . a:num+1
        endif
        return strftime("%Y%m%d") . ‘01′
endfunction

command SER :%s/\(2[0-9]\{7}\)\([0-9]\{2}\)\s*;\s*Serial/\=INCSERIAL(submatch(1), submatch(2)) . ‘     ; Serial’/gc

GNU/Find posix acl support

Cercare file che corrispondono a delle acl posix all’interno di un filesystem molto intricato è sempre un delirio.

Questa patch aggiunge l’opzione -acl al comando find (GNU/Findutils).

Esempio d’uso:

$ touch 1 2 3 4
$ mkdir 5
$ setfacl -m u:root:rx 1
$ setfacl -m g:bin:rw 2
$ setfacl -m u:pietro:--- 3
$ setfacl -m g:bin:rw 3
$ setfacl -m g:wheel:r 4
$ setfacl -m d:u:root:rwx 5
$ touch 5/6
$ setfacl -m g:wheel:r 5/6

$ find . -acl u:root:rx
./1
$ find . -acl u:root:*
./1
./5/6
$ find . -acl u:*:rx
./1
$ find . -acl g:*:*
./4
./3
./5/6
./2
$ find . -acl d:u:*:*
./5

Questa patch funziona solo su Linux, è scaricabile qua: http://www.bertera.it/software/findutils-acl/ è disponibile per la versione 4.42 e 4.5.6 di findutils