Summary:ASTERISK-11338: SIP username -> defaultuser confuses realtime system(s)
Reporter:Daniel Hazelbaker (cabal95)Labels:
Date Opened:2008-01-30 11:24:57.000-0600Date Closed:2008-01-30 17:07:32.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 11880.patch
Description:In 1.6.0 the SIP username field was renamed to defaultuser.  The sip.conf file still works in a deprecated form as username is still allowed and will give a warning.  Realtime systems (example the res_mysql in addons) directly use the new field absolutely, which causes a MySQL error.

1- Realtime systems supported should provide a "deprecated" check to see if the table is still using the username field instead of defaultuser and then warn the user but continue to work (and internally translate "defaultuser" into "username"), or

2- Provide suggested workarounds for people that cannot update their tables immediately.  We have our production server use realtime SIP records and our test server (now 1.6.0) using realtime SIP records from the same database for call routing information.  My fix was to create an SQL VIEW that translates the field names.

Number 1 would be preferable from a user standpoint, but I don't know enough about the realtime system to know if that is even possible.  At the very least the UPGRADE file should be updated to let users of realtime SIP know that username will simply not work anymore, period.
Comments:By: Mark Michelson (mmichelson) 2008-01-30 16:43:58.000-0600

I have implemented option 1 in 11880.patch. The first time that "username" is found in either sip.conf or in realtime, a deprecation notice will be printed. Realtime updates should be properly made based on whether "username" or "defaultuser" was used when configuring.

Please test and see if this clears up the problem. Thanks for bringing this to our attention!

By: Daniel Hazelbaker (cabal95) 2008-01-30 16:58:02.000-0600

That looks like it works.  I was able to switch the extconfig.conf file to use the "real" sip users table and it pulled it up fine that time, and also printed the deprecated warning.  It printed twice, once for my phone and once for a different phone (though the other phone was offline and shouldn't have been connecting.

By: Mark Michelson (mmichelson) 2008-01-30 17:04:48.000-0600

Oh, oops. I forgot to make the deprecation_warning variable static. That will fix the problem of it printing twice. But since the rest of the patch is working, I'll go ahead and get this merged. Thanks for the testing.

By: Digium Subversion (svnbot) 2008-01-30 17:07:32.000-0600

Repository: asterisk
Revision: 101344

U   trunk/channels/chan_sip.c

r101344 | mmichelson | 2008-01-30 17:07:31 -0600 (Wed, 30 Jan 2008) | 13 lines

The deprecation of "username" in favor of "defaultuser" for SIP peers unfortunately
broke realtime configurations which still used the "username" field. This was taken
care of properly when reading from realtime but was not handled properly when updating
a realtime peer. This change also adds a deprecation NOTICE CLI message that will print
if using the deprecated "username" field.

(closes issue ASTERISK-11338)
Reported by: cabal95
     11880.patch uploaded by putnopvut (license 60)
 Tested by: cabal95