[Fedora-directory-commits] ldapserver/ldap/synctools/passwordsync/passsync syncserv.cpp, 1.7.2.2, 1.7.2.3
Nathan Kinder (nkinder)
fedora-directory-commits at redhat.com
Fri Oct 14 16:07:00 UTC 2005
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/synctools/passwordsync/passsync
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15860/passsync
Modified Files:
Tag: Directory71RtmBranch
syncserv.cpp
Log Message:
170556 - Make passsync obey backoff for retries when DS is down
Index: syncserv.cpp
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/synctools/passwordsync/passsync/syncserv.cpp,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -u -r1.7.2.2 -r1.7.2.3
--- syncserv.cpp 13 Oct 2005 18:59:21 -0000 1.7.2.2
+++ syncserv.cpp 14 Oct 2005 16:06:54 -0000 1.7.2.3
@@ -101,7 +101,7 @@
}
else
{
- maxBackoffTime = pow(2, 12) * SYNCSERV_BASE_BACKOFF_LEN;
+ maxBackoffTime = (1 << 12) * SYNCSERV_BASE_BACKOFF_LEN;
}
size = SYNCSERV_BUF_SIZE;
@@ -177,6 +177,18 @@
void PassSyncService::Run()
{
isRunning = true;
+
+ // Initialize NSS
+ if(ldapssl_client_init(certPath, &certdbh) != 0)
+ {
+ timeStamp(&outLog);
+ outLog << "Error initializing SSL: err=" << PR_GetError() << endl;
+ timeStamp(&outLog);
+ outLog << "Ensure that your SSL is setup correctly" << endl;
+
+ goto exit;
+ }
+
SyncPasswords();
while(isRunning)
@@ -229,6 +241,7 @@
}
}
+exit:
CloseHandle(passhookEventHandle);
}
@@ -244,15 +257,6 @@
char* dn;
int tempSize = passInfoList.size();
- if(Connect(&mainLdapConnection, ldapAuthUsername, ldapAuthPassword) < 0)
- {
- // log connection failure.
- timeStamp(&outLog);
- outLog << "Can not connect to ldap server in SyncPasswords" << endl;
-
- goto exit;
- }
-
if(loadSet(&passInfoList, dataFilename) == 0)
{
if((passInfoList.size() - tempSize) > 0)
@@ -293,6 +297,15 @@
}
}
+ if(Connect(&mainLdapConnection, ldapAuthUsername, ldapAuthPassword) < 0)
+ {
+ // log connection failure.
+ timeStamp(&outLog);
+ outLog << "Can not connect to ldap server in SyncPasswords" << endl;
+
+ goto exit;
+ }
+
currentPassInfo = passInfoList.begin();
while(currentPassInfo != passInfoList.end())
{
@@ -378,20 +391,6 @@
{
int result = 0;
- if(ldapssl_client_init(certPath, &certdbh) != 0)
- {
- result = PR_GetError();
-
- timeStamp(&outLog);
- outLog << "ldapssl_client_init failed in Connect" << endl;
- outLog << "\t" << result << ": " << ldap_err2string(result) << endl;
-
- result = GetLastError();
-
- result = -1;
- goto exit;
- }
-
*connection = ldapssl_init(ldapHostName, atoi(ldapHostPort), 1);
if(*connection == NULL)
@@ -604,7 +603,7 @@
if(backoff > 0)
{
- backoffTime = pow(2, backoff) * SYNCSERV_BASE_BACKOFF_LEN;
+ backoffTime = (1 << backoff) * SYNCSERV_BASE_BACKOFF_LEN;
}
return backoffTime;
@@ -624,12 +623,12 @@
currentPassInfo = passInfoList.begin();
while(currentPassInfo != passInfoList.end())
{
- if((currentPassInfo->atTime + (BackoffTime(currentPassInfo->backoffCount) / 1000)) <= currentTime)
+ if(((unsigned long)currentPassInfo->atTime + (BackoffTime(currentPassInfo->backoffCount) / 1000)) <= (unsigned long)currentTime)
{
currentPassInfo->backoffCount++;
}
- if((currentTime - currentPassInfo->atTime) > (maxBackoffTime / 1000))
+ if(((unsigned long)currentTime - (unsigned long)currentPassInfo->atTime) > (maxBackoffTime / 1000))
{
timeStamp(&outLog);
outLog << "Abandoning password change for " << currentPassInfo->username << ", backoff expired" << endl;
@@ -656,7 +655,7 @@
for(currentPassInfo = passInfoList.begin(); currentPassInfo != passInfoList.end(); currentPassInfo++)
{
- if(currentPassInfo->backoffCount < minBackoff)
+ if((unsigned long)currentPassInfo->backoffCount < minBackoff)
{
minBackoff = currentPassInfo->backoffCount;
}
More information about the 389-commits
mailing list