[Pkg-voip-commits] [SCM] reSIProcate branch, master, updated. upstream/1.8.0_pre1-66-gb4403d3
Daniel Pocock
daniel at pocock.com.au
Wed May 23 13:04:31 UTC 2012
The following commit has been merged in the master branch:
commit b073d8b25b2e1c9d6c1de7c0f1663dc2562c19cd
Author: Daniel Pocock <daniel at pocock.com.au>
Date: Wed May 23 11:44:28 2012 +0000
Imported Upstream version 1.8.0~pre6
diff --git a/repro/AbstractDb.cxx b/repro/AbstractDb.cxx
index 7609738..5445bb0 100644
--- a/repro/AbstractDb.cxx
+++ b/repro/AbstractDb.cxx
@@ -17,6 +17,7 @@ using namespace std;
#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
+#define REPRO_DB_VERSION_USERS 3
static void
encodeString(oDataStream& s, const Data& data)
@@ -115,7 +116,7 @@ AbstractDb::encodeUser(const UserRecord& rec, resip::Data& data)
{
oDataStream s(data);
- short version=2;
+ short version = REPRO_DB_VERSION_USERS;
assert( sizeof( version) == 2 );
s.write( (char*)(&version) , sizeof(version) );
@@ -123,6 +124,7 @@ AbstractDb::encodeUser(const UserRecord& rec, resip::Data& data)
encodeString( s, rec.domain);
encodeString( s, rec.realm);
encodeString( s, rec.passwordHash);
+ encodeString( s, rec.passwordHashAlt);
encodeString( s, rec.name);
encodeString( s, rec.email);
encodeString( s, rec.forwardAddress);
@@ -169,16 +171,31 @@ AbstractDb::getUser( const AbstractDb::Key& key ) const
assert( sizeof(version) == 2 );
s.read( (char*)(&version), sizeof(version) );
- if ( version == 2 )
+ if ( version == REPRO_DB_VERSION_USERS )
{
decodeString(s, rec.user);
decodeString(s, rec.domain);
decodeString(s, rec.realm);
decodeString(s, rec.passwordHash);
+ decodeString(s, rec.passwordHashAlt);
decodeString(s, rec.name);
decodeString(s, rec.email);
decodeString(s, rec.forwardAddress);
}
+ else if ( version == 2 )
+ {
+ // We can read from the older version DB, but the entry
+ // will be written back in the new format with
+ // passwordHashAlt blank
+ decodeString(s, rec.user);
+ decodeString(s, rec.domain);
+ decodeString(s, rec.realm);
+ decodeString(s, rec.passwordHash);
+ decodeString(s, rec.name);
+ decodeString(s, rec.email);
+ decodeString(s, rec.forwardAddress);
+ rec.passwordHashAlt = Data::Empty;
+ }
else
{
// unknown version
diff --git a/repro/AbstractDb.hxx b/repro/AbstractDb.hxx
index 0f315bb..6426663 100644
--- a/repro/AbstractDb.hxx
+++ b/repro/AbstractDb.hxx
@@ -27,6 +27,7 @@ class AbstractDb
resip::Data domain;
resip::Data realm;
resip::Data passwordHash;
+ resip::Data passwordHashAlt;
resip::Data name;
resip::Data email;
resip::Data forwardAddress;
diff --git a/repro/Makefile.am b/repro/Makefile.am
index 4c999eb..60cec5c 100644
--- a/repro/Makefile.am
+++ b/repro/Makefile.am
@@ -193,6 +193,7 @@ reproInfo.hxx:
ReproVersion.cxx: reproInfo.hxx
dist_man_MANS = doc/repro.8
+dist_man_MANS += doc/reprocmd.8
sysconf_DATA = etc/repro.conf
diff --git a/repro/Makefile.in b/repro/Makefile.in
index 10e3229..17de5e8 100644
--- a/repro/Makefile.in
+++ b/repro/Makefile.in
@@ -450,7 +450,7 @@ nobase_reproinclude_HEADERS = AbstractDb.hxx \
XmlRpcConnection.hxx \
XmlRpcServerBase.hxx
-dist_man_MANS = doc/repro.8
+dist_man_MANS = doc/repro.8 doc/reprocmd.8
sysconf_DATA = etc/repro.conf
all: all-recursive
diff --git a/repro/MySqlDb.cxx b/repro/MySqlDb.cxx
index 2c76f47..26e6d1c 100644
--- a/repro/MySqlDb.cxx
+++ b/repro/MySqlDb.cxx
@@ -287,10 +287,22 @@ MySqlDb::addUser(const AbstractDb::Key& key, const AbstractDb::UserRecord& rec)
Data command;
{
DataStream ds(command);
- ds << "REPLACE INTO users SET user='" << rec.user
+ ds << "INSERT INTO users (user, domain, realm, passwordHash, passwordHashAlt, name, email, forwardAddress)"
+ << " VALUES('"
+ << rec.user << "', '"
+ << rec.domain << "', '"
+ << rec.realm << "', '"
+ << rec.passwordHash << "', '"
+ << rec.passwordHashAlt << "', '"
+ << rec.name << "', '"
+ << rec.email << "', '"
+ << rec.forwardAddress << "')"
+ << " ON DUPLICATE KEY UPDATE"
+ << " user='" << rec.user
<< "', domain='" << rec.domain
<< "', realm='" << rec.realm
<< "', passwordHash='" << rec.passwordHash
+ << "', passwordHashAlt='" << rec.passwordHashAlt
<< "', name='" << rec.name
<< "', email='" << rec.email
<< "', forwardAddress='" << rec.forwardAddress
@@ -321,7 +333,7 @@ MySqlDb::getUser( const AbstractDb::Key& key ) const
Data command;
{
DataStream ds(command);
- ds << "SELECT user, domain, realm, passwordHash, name, email, forwardAddress FROM users ";
+ ds << "SELECT user, domain, realm, passwordHash, passwordHashAlt, name, email, forwardAddress FROM users ";
userWhereClauseToDataStream(key, ds);
}
@@ -340,13 +352,15 @@ MySqlDb::getUser( const AbstractDb::Key& key ) const
MYSQL_ROW row = mysql_fetch_row(result);
if (row)
{
- ret.user = Data(row[0]);
- ret.domain = Data(row[1]);
- ret.realm = Data(row[2]);
- ret.passwordHash = Data(row[3]);
- ret.name = Data(row[4]);
- ret.email = Data(row[5]);
- ret.forwardAddress = Data(row[6]);
+ int col = 0;
+ ret.user = Data(row[col++]);
+ ret.domain = Data(row[col++]);
+ ret.realm = Data(row[col++]);
+ ret.passwordHash = Data(row[col++]);
+ ret.passwordHashAlt = Data(row[col++]);
+ ret.name = Data(row[col++]);
+ ret.email = Data(row[col++]);
+ ret.forwardAddress = Data(row[col++]);
}
mysql_free_result(result);
diff --git a/repro/UserStore.cxx b/repro/UserStore.cxx
index 678722f..1ce3322 100644
--- a/repro/UserStore.cxx
+++ b/repro/UserStore.cxx
@@ -52,6 +52,7 @@ UserStore::addUser( const Data& username,
const Data& domain,
const Data& realm,
const Data& password,
+ const Data& passwordHashAlt,
bool applyA1HashToPassword,
const Data& fullName,
const Data& emailAddress )
@@ -70,10 +71,23 @@ UserStore::addUser( const Data& username,
<< password;
a1.flush();
rec.passwordHash = a1.getHex();
+
+ // Some UAs might calculate A1
+ // using user at domain:realm:password
+ // so we store the hash of that permutation too
+ MD5Stream a1b;
+ a1b << username << Symbols::AT_SIGN << domain
+ << Symbols::COLON
+ << realm
+ << Symbols::COLON
+ << password;
+ a1b.flush();
+ rec.passwordHashAlt = a1b.getHex();
}
else
{
rec.passwordHash = password;
+ rec.passwordHashAlt = passwordHashAlt;
}
rec.name = fullName;
rec.email = emailAddress;
@@ -95,13 +109,14 @@ UserStore::updateUser( const Key& originalKey,
const resip::Data& domain,
const resip::Data& realm,
const resip::Data& password,
+ const resip::Data& passwordHashAlt,
bool applyA1HashToPassword,
const resip::Data& fullName,
const resip::Data& emailAddress )
{
Key newkey = buildKey(user, domain);
- bool ret = addUser(user, domain, realm, password, applyA1HashToPassword, fullName, emailAddress);
+ bool ret = addUser(user, domain, realm, password, passwordHashAlt, applyA1HashToPassword, fullName, emailAddress);
if ( newkey != originalKey )
{
eraseUser(originalKey);
diff --git a/repro/UserStore.hxx b/repro/UserStore.hxx
index ee9658c..af285b0 100644
--- a/repro/UserStore.hxx
+++ b/repro/UserStore.hxx
@@ -35,6 +35,7 @@ class UserStore
const resip::Data& domain,
const resip::Data& realm,
const resip::Data& password,
+ const resip::Data& passwordHashAlt,
bool applyA1HashToPassword,
const resip::Data& fullName,
const resip::Data& emailAddress );
@@ -46,6 +47,7 @@ class UserStore
const resip::Data& domain,
const resip::Data& realm,
const resip::Data& password,
+ const resip::Data& passwordHashAlt,
bool applyA1HashToPassword,
const resip::Data& fullName,
const resip::Data& emailAddress );
diff --git a/repro/WebAdmin.cxx b/repro/WebAdmin.cxx
index d4c8681..00f7860 100644
--- a/repro/WebAdmin.cxx
+++ b/repro/WebAdmin.cxx
@@ -96,6 +96,7 @@ WebAdmin::WebAdmin( Proxy& proxy,
Data::Empty, // domain
Data::Empty, // realm
(adminPassword==""?Data("admin"):adminPassword), // password
+ Data::Empty,
true, // applyA1HashToPassword
Data::Empty, // name
Data::Empty ); // email
@@ -113,6 +114,7 @@ WebAdmin::WebAdmin( Proxy& proxy,
Data::Empty,
Data::Empty,
adminPassword,
+ Data::Empty,
true, // applyA1HashToPassword
Data::Empty,
Data::Empty);
@@ -584,7 +586,7 @@ WebAdmin::buildAddUserSubPage( DataStream& s)
// realm = mHttpParams["domain"];
// }
- if(mStore.mUserStore.addUser(user,domain,domain,mHttpParams["password"],true,mHttpParams["name"],mHttpParams["email"]))
+ if(mStore.mUserStore.addUser(user,domain,domain,mHttpParams["password"],Data::Empty,true,mHttpParams["name"],mHttpParams["email"]))
{
s << "<p><em>Added:</em> " << user << "@" << domain << "</p>\n";
}
@@ -775,6 +777,7 @@ WebAdmin::buildShowUsersSubPage(DataStream& s)
Data domain = mHttpParams["domain"];
Data realm = mHttpParams["domain"]; // eventually sort out realms
Data password = mHttpParams["password"];
+ Data passwordHashAlt = Data::Empty;
Data name = mHttpParams["name"];
Data email = mHttpParams["email"];
bool applyA1HashToPassword = true;
@@ -783,10 +786,11 @@ WebAdmin::buildShowUsersSubPage(DataStream& s)
if(password == "" && user == rec.user && realm == rec.realm)
{
password = rec.passwordHash;
+ passwordHashAlt = rec.passwordHashAlt;
applyA1HashToPassword = false;
}
// write out the updated record to the database now
- if(mStore.mUserStore.updateUser(key, user, domain, realm, password, applyA1HashToPassword, name, email))
+ if(mStore.mUserStore.updateUser(key, user, domain, realm, password, passwordHashAlt, applyA1HashToPassword, name, email))
{
s << "<p><em>Updated:</em> " << key << "</p>" << endl;
}
diff --git a/repro/create_mysql_reprodb.sql b/repro/create_mysql_reprodb.sql
index 0bc47a9..75df053 100644
--- a/repro/create_mysql_reprodb.sql
+++ b/repro/create_mysql_reprodb.sql
@@ -9,14 +9,16 @@ USE repro;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
+ `id` INT PRIMARY KEY AUTO_INCREMENT,
`user` VARCHAR(64) NOT NULL,
`domain` VARCHAR(253),
`realm` VARCHAR(253),
`passwordHash` VARCHAR(32),
+ `passwordHashAlt` VARCHAR(32),
`name` VARCHAR(256),
`email` VARCHAR(256),
`forwardAddress` VARCHAR(256),
- PRIMARY KEY (`user`, `domain`)
+ CONSTRAINT c_user_domain UNIQUE INDEX idx_user_domain (`user`, `domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/repro/doc/reprocmd.8 b/repro/doc/reprocmd.8
new file mode 100644
index 0000000..c3e3386
--- /dev/null
+++ b/repro/doc/reprocmd.8
@@ -0,0 +1,58 @@
+.TH reprocmd 8 "May 2012"
+.\" ====================================================================
+.\" Copyright 2012 Daniel Pocock. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\"
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in
+.\" the documentation and/or other materials provided with the
+.\" distribution.
+.\"
+.\" 3. Neither the name of the author(s) nor the names of any contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" ====================================================================
+.\"
+.\"
+.\"
+.SH NAME
+reprocmd \- control the repro SIP proxy server
+.SH SYNOPSIS
+.B
+reprocmd [OPTIONS...]
+
+.SH DESCRIPTION
+.B reprocmd
+controls the
+.B repro
+SIP proxy server.
+
+.SH SEE ALSO
+Repro web site at
+.B http://www.resiprocate.org/About_Repro/
+
+.\".SH AUTHORS
+
+.\".SH BUGS
+
+
+
--
reSIProcate
More information about the Pkg-voip-commits
mailing list