diff options
Diffstat (limited to 'src/mgr/installmgr.cpp')
-rw-r--r-- | src/mgr/installmgr.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/src/mgr/installmgr.cpp b/src/mgr/installmgr.cpp index 1e83db5..fe1a674 100644 --- a/src/mgr/installmgr.cpp +++ b/src/mgr/installmgr.cpp @@ -2,7 +2,7 @@ * * installmgr.cpp - InstallMgr functions * - * $Id: installmgr.cpp 2980 2013-09-14 21:51:47Z scribe $ + * $Id: installmgr.cpp 3515 2017-11-01 11:38:09Z scribe $ * * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society @@ -59,7 +59,7 @@ SWORD_NAMESPACE_START namespace { static void removeTrailingSlash(SWBuf &buf) { - int len = buf.size(); + int len = (int)buf.size(); if ((buf[len-1] == '/') || (buf[len-1] == '\\')) buf.size(len-1); @@ -101,6 +101,8 @@ RemoteTransport *InstallMgr::createHTTPTransport(const char *host, StatusReporte InstallMgr::InstallMgr(const char *privatePath, StatusReporter *sr, SWBuf u, SWBuf p) { userDisclaimerConfirmed = false; + passive=true; + unverifiedPeerAllowed=true; statusReporter = sr; this->u = u; this->p = p; @@ -109,7 +111,7 @@ InstallMgr::InstallMgr(const char *privatePath, StatusReporter *sr, SWBuf u, SWB installConf = 0; stdstr(&(this->privatePath), privatePath); if (this->privatePath) { - int len = strlen(this->privatePath); + int len = (int)strlen(this->privatePath); if ((this->privatePath[len-1] == '/') || (this->privatePath[len-1] == '\\')) this->privatePath[len-1] = 0; @@ -145,12 +147,13 @@ void InstallMgr::readInstallConf() { clearSources(); setFTPPassive(stricmp((*installConf)["General"]["PassiveFTP"].c_str(), "false") != 0); + setUnverifiedPeerAllowed(stricmp((*installConf)["General"]["UnverifiedPeerAllowed"].c_str(), "false") != 0); - SectionMap::iterator confSection = installConf->Sections.find("Sources"); + SectionMap::iterator confSection = installConf->getSections().find("Sources"); ConfigEntMap::iterator sourceBegin; ConfigEntMap::iterator sourceEnd; - if (confSection != installConf->Sections.end()) { + if (confSection != installConf->getSections().end()) { sourceBegin = confSection->second.lower_bound("FTPSource"); sourceEnd = confSection->second.upper_bound("FTPSource"); @@ -204,8 +207,8 @@ void InstallMgr::readInstallConf() { } defaultMods.clear(); - confSection = installConf->Sections.find("General"); - if (confSection != installConf->Sections.end()) { + confSection = installConf->getSections().find("General"); + if (confSection != installConf->getSections().end()) { sourceBegin = confSection->second.lower_bound("DefaultMod"); sourceEnd = confSection->second.upper_bound("DefaultMod"); @@ -219,16 +222,17 @@ void InstallMgr::readInstallConf() { void InstallMgr::saveInstallConf() { - installConf->Sections["Sources"].clear(); + installConf->getSection("Sources").clear(); for (InstallSourceMap::iterator it = sources.begin(); it != sources.end(); ++it) { if (it->second) { - installConf->Sections["Sources"].insert(ConfigEntMap::value_type(it->second->type + "Source", it->second->getConfEnt().c_str())); + installConf->getSection("Sources").insert(ConfigEntMap::value_type(it->second->type + "Source", it->second->getConfEnt().c_str())); } } (*installConf)["General"]["PassiveFTP"] = (isFTPPassive()) ? "true" : "false"; + (*installConf)["General"]["UnverifiedPeerAllowed"] = (isUnverifiedPeerAllowed()) ? "true" : "false"; - installConf->Save(); + installConf->save(); } @@ -243,9 +247,9 @@ int InstallMgr::removeModule(SWMgr *manager, const char *moduleName) { // save our own copy, cuz when we remove the module from the SWMgr // it's likely we'll free the memory passed to us in moduleName SWBuf modName = moduleName; - module = manager->config->Sections.find(modName); + module = manager->config->getSections().find(modName); - if (module != manager->config->Sections.end()) { + if (module != manager->config->getSections().end()) { // to be sure all files are closed // this does not remove the .conf information from SWMgr manager->deleteModule(modName); @@ -285,7 +289,7 @@ int InstallMgr::removeModule(SWMgr *manager, const char *moduleName) { modFile += "/"; modFile += ent->d_name; SWConfig *config = new SWConfig(modFile.c_str()); - if (config->Sections.find(modName) != config->Sections.end()) { + if (config->getSections().find(modName) != config->getSections().end()) { delete config; FileMgr::removeFile(modFile.c_str()); } @@ -332,6 +336,8 @@ SWLog::getSystemLog()->logDebug("remoteCopy: %s, %s, %s, %c, %s", (is?is->source trans->setPasswd(p); } + trans->setUnverifiedPeerAllowed(unverifiedPeerAllowed); + SWBuf urlPrefix; if (is->type == "HTTP") { urlPrefix = (SWBuf) "http://"; @@ -361,6 +367,7 @@ SWLog::getSystemLog()->logDebug("remoteCopy: %s, %s, %s, %c, %s", (is?is->source SWBuf dir = (SWBuf)is->directory.c_str(); removeTrailingSlash(dir); dir += (SWBuf)"/" + src; //dont forget the final slash +SWLog::getSystemLog()->logDebug("remoteCopy: dirTransfer: %s", dir.c_str()); retVal = trans->copyDirectory(urlPrefix, dir, dest, suffix); @@ -393,6 +400,7 @@ SWLog::getSystemLog()->logDebug("remoteCopy: %s, %s, %s, %c, %s", (is?is->source int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is) { + int retVal = 0; SectionMap::iterator module, section; ConfigEntMap::iterator fileBegin; ConfigEntMap::iterator fileEnd; @@ -419,9 +427,9 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch SWMgr mgr(sourceDir.c_str()); - module = mgr.config->Sections.find(modName); + module = mgr.config->getSections().find(modName); - if (module != mgr.config->Sections.end()) { + if (module != mgr.config->getSections().end()) { entry = module->second.find("CipherKey"); if (entry != module->second.end()) @@ -449,14 +457,14 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch if (!aborted) { // DO THE INSTALL - while (fileBegin != fileEnd) { + while (fileBegin != fileEnd && !retVal) { SWBuf sourcePath = sourceDir; sourcePath += fileBegin->second.c_str(); SWBuf dest = destMgr->prefixPath; removeTrailingSlash(dest); dest += '/'; dest += fileBegin->second.c_str(); - FileMgr::copyFile(sourcePath.c_str(), dest.c_str()); + retVal = FileMgr::copyFile(sourcePath.c_str(), dest.c_str()); fileBegin++; } @@ -504,7 +512,7 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch } if (!aborted) { SWBuf destPath = (SWBuf)destMgr->prefixPath + relativePath; - FileMgr::copyDir(absolutePath.c_str(), destPath.c_str()); + retVal = FileMgr::copyDir(absolutePath.c_str(), destPath.c_str()); } if (is) { // delete tmp netCopied files // mgr->deleteModule(modName); @@ -516,17 +524,17 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch SWBuf confDir = sourceDir + "mods.d/"; if ((dir = opendir(confDir.c_str()))) { // find and copy .conf file rewinddir(dir); - while ((ent = readdir(dir))) { + while ((ent = readdir(dir)) && !retVal) { if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { modFile = confDir; modFile += ent->d_name; SWConfig *config = new SWConfig(modFile.c_str()); - if (config->Sections.find(modName) != config->Sections.end()) { + if (config->getSections().find(modName) != config->getSections().end()) { SWBuf targetFile = destMgr->configPath; //"./mods.d/"; removeTrailingSlash(targetFile); targetFile += "/"; targetFile += ent->d_name; - FileMgr::copyFile(modFile.c_str(), targetFile.c_str()); + retVal = FileMgr::copyFile(modFile.c_str(), targetFile.c_str()); if (cipher) { if (getCipherCode(modName, config)) { SWMgr newDest(destMgr->prefixPath); @@ -534,8 +542,8 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch aborted = true; } else { - config->Save(); - FileMgr::copyFile(modFile.c_str(), targetFile.c_str()); + config->save(); + retVal = FileMgr::copyFile(modFile.c_str(), targetFile.c_str()); } } } @@ -545,7 +553,7 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch closedir(dir); } } - return (aborted) ? -1 : 0; + return (aborted) ? -9 : retVal; } return 1; } @@ -660,8 +668,8 @@ int InstallMgr::refreshRemoteSourceConfiguration() { int errorCode = remoteCopy(&is, masterRepoList, masterRepoListPath.c_str(), false); if (!errorCode) { //sucessfully downloaded the repo list SWConfig masterList(masterRepoListPath); - SectionMap::iterator sections = masterList.Sections.find("Repos"); - if (sections != masterList.Sections.end()) { + SectionMap::iterator sections = masterList.getSections().find("Repos"); + if (sections != masterList.getSections().end()) { for (ConfigEntMap::iterator actions = sections->second.begin(); actions != sections->second.end(); actions++) { // Search through our current sources and see if we have a matching UID InstallSourceMap::iterator it; |