mirror of https://github.com/BOINC/boinc.git
Client: eliminate errors/warning if a project changes its master URL from http: to https:
This PR lets a project change its URL from http: to https: without user involvement. But the old URL can be present in various places, leading to errors. This commit fixes these problem, mostly by using a URL comparison function (urls_match()) that ignores the protocol prefix, and by changing lookup_project() to ignore the prefix. The places are: - task state files - account manager replies - active tasks in state file - master URLs in command-line args - master URLs in config file (e.g. GPU exclusion) - GUI RPCs that specify a project
This commit is contained in:
parent
1585e89a6f
commit
b93ec216cb
|
@ -69,6 +69,7 @@ using std::vector;
|
|||
#include "shmem.h"
|
||||
#include "str_replace.h"
|
||||
#include "str_util.h"
|
||||
#include "url.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "client_msgs.h"
|
||||
|
@ -1633,7 +1634,7 @@ void ACTIVE_TASK::read_task_state_file() {
|
|||
);
|
||||
return;
|
||||
}
|
||||
if (strcmp(s, result->project->master_url)) {
|
||||
if (!urls_match(s, result->project->master_url)) {
|
||||
msg_printf(wup->project, MSG_INTERNAL_ERROR,
|
||||
"wrong project URL in task state file"
|
||||
);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "parse.h"
|
||||
#include "str_replace.h"
|
||||
#include "str_util.h"
|
||||
#include "url.h"
|
||||
#include "util.h"
|
||||
#ifdef _WIN32
|
||||
#include "run_app_windows.h"
|
||||
|
@ -1189,21 +1190,21 @@ bool CLIENT_STATE::poll_slow_events() {
|
|||
|
||||
#endif // ifndef SIM
|
||||
|
||||
// See if the project specified by master_url already exists
|
||||
// in the client state record. Ignore any trailing "/" characters
|
||||
// Find the project with the given master_url.
|
||||
// Ignore differences in protocol, case, and trailing /
|
||||
//
|
||||
PROJECT* CLIENT_STATE::lookup_project(const char* master_url) {
|
||||
int len1, len2;
|
||||
char *mu;
|
||||
char buf[256];
|
||||
|
||||
len1 = (int)strlen(master_url);
|
||||
if (master_url[strlen(master_url)-1] == '/') len1--;
|
||||
safe_strcpy(buf, master_url);
|
||||
canonicalize_master_url(buf, sizeof(buf));
|
||||
char* p = strstr(buf, "//");
|
||||
if (!p) return NULL;
|
||||
|
||||
for (unsigned int i=0; i<projects.size(); i++) {
|
||||
mu = projects[i]->master_url;
|
||||
len2 = (int)strlen(mu);
|
||||
if (mu[strlen(mu)-1] == '/') len2--;
|
||||
if (!strncmp(master_url, projects[i]->master_url, max(len1,len2))) {
|
||||
char* q = strstr(projects[i]->master_url, "//");
|
||||
if (!q) continue;
|
||||
if (!strcmp(p, q)) {
|
||||
return projects[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -748,7 +748,7 @@ static void handle_get_project_init_status(GUI_RPC_CONN& grc) {
|
|||
//
|
||||
for (unsigned i=0; i<gstate.projects.size(); i++) {
|
||||
PROJECT* p = gstate.projects[i];
|
||||
if (!strcmp(p->master_url, gstate.project_init.url)) {
|
||||
if (urls_match(p->master_url, gstate.project_init.url)) {
|
||||
gstate.project_init.remove();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "parse.h"
|
||||
#include "str_replace.h"
|
||||
#include "str_util.h"
|
||||
#include "url.h"
|
||||
|
||||
#include "client_state.h"
|
||||
#include "client_msgs.h"
|
||||
|
@ -681,7 +682,7 @@ void process_gpu_exclusions() {
|
|||
for (j=0; j<cc_config.exclude_gpus.size(); j++) {
|
||||
EXCLUDE_GPU& eg = cc_config.exclude_gpus[j];
|
||||
if (!eg.type.empty() && (eg.type != cp.type)) continue;
|
||||
if (strcmp(eg.url.c_str(), p->master_url)) continue;
|
||||
if (!urls_match(eg.url.c_str(), p->master_url)) continue;
|
||||
COPROC_INSTANCE_BITMAP mask;
|
||||
if (eg.device_num >= 0) {
|
||||
int index = cp.device_num_index(eg.device_num);
|
||||
|
@ -775,7 +776,7 @@ bool gpu_excluded(APP* app, COPROC& cp, int ind) {
|
|||
PROJECT* p = app->project;
|
||||
for (unsigned int i=0; i<cc_config.exclude_gpus.size(); i++) {
|
||||
EXCLUDE_GPU& eg = cc_config.exclude_gpus[i];
|
||||
if (strcmp(eg.url.c_str(), p->master_url)) continue;
|
||||
if (!urls_match(eg.url.c_str(), p->master_url)) continue;
|
||||
if (!eg.type.empty() && (eg.type != cp.type)) continue;
|
||||
if (!eg.appname.empty() && (eg.appname != app->name)) continue;
|
||||
if (eg.device_num >= 0 && eg.device_num != cp.device_nums[ind]) continue;
|
||||
|
|
|
@ -248,6 +248,15 @@ bool is_https_transition(const char* url1, const char* url2) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// return true if url1 and url2 are the same except protocol
|
||||
//
|
||||
bool urls_match(const char* url1, const char* url2) {
|
||||
const char* p = strstr(url1, "//");
|
||||
const char* q = strstr(url2, "//");
|
||||
if (!p || !q) return false;
|
||||
return strcmp(p, q) == 0;
|
||||
}
|
||||
|
||||
// is the string a valid master URL, in canonical form?
|
||||
//
|
||||
bool valid_master_url(char* buf) {
|
||||
|
|
|
@ -47,5 +47,5 @@ extern void canonicalize_master_url(char *url, int len);
|
|||
extern void canonicalize_master_url(std::string&);
|
||||
extern bool is_https(const char*);
|
||||
extern bool is_https_transition(const char* ur1l, const char* url2);
|
||||
|
||||
extern bool urls_match(const char* url1, const char* url2);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue