diff options
author | Nathan Kinder <nkinder@redhat.com> | 2005-10-14 16:06:58 +0000 |
---|---|---|
committer | Nathan Kinder <nkinder@redhat.com> | 2005-10-14 16:06:58 +0000 |
commit | 79dfc67a91a7f1491f6f9ee418c59b78a4f8055a (patch) | |
tree | de15749dc7dc31512f55db1c440265b55ff859d5 | |
parent | aa2298b0dfbaeff67ef758cd54dd55a90c1b4400 (diff) | |
download | ds-79dfc67a91a7f1491f6f9ee418c59b78a4f8055a.tar.gz ds-79dfc67a91a7f1491f6f9ee418c59b78a4f8055a.tar.xz ds-79dfc67a91a7f1491f6f9ee418c59b78a4f8055a.zip |
170556 - Make passsync obey backoff for retries when DS is down
-rw-r--r-- | ldap/synctools/passwordsync/passsync/syncserv.cpp | 55 | ||||
-rw-r--r-- | ldap/synctools/passwordsync/wix/PassSync.wxs | 2 |
2 files changed, 28 insertions, 29 deletions
diff --git a/ldap/synctools/passwordsync/passsync/syncserv.cpp b/ldap/synctools/passwordsync/passsync/syncserv.cpp index b767e511..247184dd 100644 --- a/ldap/synctools/passwordsync/passsync/syncserv.cpp +++ b/ldap/synctools/passwordsync/passsync/syncserv.cpp @@ -101,7 +101,7 @@ PassSyncService::PassSyncService(const TCHAR *serviceName) : CNTService(serviceN } 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::OnShutdown() 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 @@ void PassSyncService::Run() } } +exit: CloseHandle(passhookEventHandle); } @@ -244,15 +257,6 @@ int PassSyncService::SyncPasswords() 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 @@ int PassSyncService::SyncPasswords() } } + 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 PassSyncService::Connect(LDAP** connection, char* dn, char* auth) { 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 @@ unsigned long PassSyncService::BackoffTime(int backoff) if(backoff > 0) { - backoffTime = pow(2, backoff) * SYNCSERV_BASE_BACKOFF_LEN; + backoffTime = (1 << backoff) * SYNCSERV_BASE_BACKOFF_LEN; } return backoffTime; @@ -624,12 +623,12 @@ void PassSyncService::UpdateBackoff() 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 @@ int PassSyncService::GetMinBackoff() for(currentPassInfo = passInfoList.begin(); currentPassInfo != passInfoList.end(); currentPassInfo++) { - if(currentPassInfo->backoffCount < minBackoff) + if((unsigned long)currentPassInfo->backoffCount < minBackoff) { minBackoff = currentPassInfo->backoffCount; } diff --git a/ldap/synctools/passwordsync/wix/PassSync.wxs b/ldap/synctools/passwordsync/wix/PassSync.wxs index b1a0d730..9ea3a63b 100644 --- a/ldap/synctools/passwordsync/wix/PassSync.wxs +++ b/ldap/synctools/passwordsync/wix/PassSync.wxs @@ -137,7 +137,7 @@ <ServiceInstall Id='PassSyncEXE' Name='PassSync' DisplayName='Password Synchronization' Type='ownProcess' Interactive='yes' Start='auto' Vital='yes' ErrorControl='normal'/> - <ServiceControl Id='PassSyncEXE' Name='PassSync' Start='install' Stop='both' Remove='uninstall' Wait='yes'/> + <ServiceControl Id='PassSyncEXE' Name='PassSync' Start='install' Stop='both' Remove='uninstall' Wait='no'/> <Registry Id='InstPath' Root='HKLM' Key='Software\PasswordSync' Name='Install Path' Action='write' Type='string' Value='[INSTALLDIR]' /> <Registry Id='HostName' Root='HKLM' Key='Software\PasswordSync' Name='Host Name' Action='write' Type='string' Value='[HOSTNAME]' /> |