2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-02-06 21:26:21 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2005-02-06 21:26:21 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-02-06 21:26:21 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-02-06 21:26:21 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-02-06 21:26:21 +00:00
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
#include "cpp.h"
|
|
|
|
|
2005-02-06 21:26:21 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "boinc_win.h"
|
2008-01-17 18:09:30 +00:00
|
|
|
#else
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2008-02-27 23:26:38 +00:00
|
|
|
#include <cstring>
|
2010-05-11 19:10:29 +00:00
|
|
|
#endif
|
2009-11-05 18:02:51 +00:00
|
|
|
|
2005-02-06 21:26:21 +00:00
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "client_msgs.h"
|
2007-02-21 16:26:51 +00:00
|
|
|
#include "str_util.h"
|
2009-06-16 20:54:44 +00:00
|
|
|
#include "str_replace.h"
|
2009-11-05 18:02:51 +00:00
|
|
|
#include "url.h"
|
2005-02-06 21:26:21 +00:00
|
|
|
#include "file_names.h"
|
|
|
|
#include "filesys.h"
|
|
|
|
#include "client_state.h"
|
2005-08-05 18:41:46 +00:00
|
|
|
#include "gui_http.h"
|
2005-12-14 23:43:50 +00:00
|
|
|
#include "crypt.h"
|
2005-02-06 21:26:21 +00:00
|
|
|
|
|
|
|
#include "acct_mgr.h"
|
|
|
|
|
2005-12-09 07:12:56 +00:00
|
|
|
static const char *run_mode_name[] = {"", "always", "auto", "never"};
|
2005-06-21 08:22:18 +00:00
|
|
|
|
2006-06-01 19:03:00 +00:00
|
|
|
ACCT_MGR_OP::ACCT_MGR_OP() {
|
|
|
|
global_prefs_xml = 0;
|
|
|
|
}
|
|
|
|
|
2006-01-24 21:38:03 +00:00
|
|
|
// do an account manager RPC;
|
2008-01-17 18:09:30 +00:00
|
|
|
// if URL is null, detach from current account manager
|
2006-01-24 21:38:03 +00:00
|
|
|
//
|
2005-11-26 00:12:44 +00:00
|
|
|
int ACCT_MGR_OP::do_rpc(
|
2007-04-06 00:37:07 +00:00
|
|
|
std::string _url, std::string name, std::string password_hash,
|
2006-06-01 05:29:37 +00:00
|
|
|
bool _via_gui
|
2005-11-26 00:12:44 +00:00
|
|
|
) {
|
2005-02-06 21:26:21 +00:00
|
|
|
int retval;
|
2005-12-09 22:29:21 +00:00
|
|
|
unsigned int i;
|
2007-04-06 00:37:07 +00:00
|
|
|
char url[256], password[256], buf[256];
|
2006-01-06 23:13:21 +00:00
|
|
|
FILE *pwdf;
|
2005-02-06 21:26:21 +00:00
|
|
|
|
2007-04-06 00:37:07 +00:00
|
|
|
strlcpy(url, _url.c_str(), sizeof(url));
|
2005-06-28 23:56:56 +00:00
|
|
|
|
2005-09-15 00:16:55 +00:00
|
|
|
error_num = ERR_IN_PROGRESS;
|
2006-06-01 05:29:37 +00:00
|
|
|
via_gui = _via_gui;
|
2006-06-01 19:03:00 +00:00
|
|
|
if (global_prefs_xml) {
|
|
|
|
free(global_prefs_xml);
|
|
|
|
global_prefs_xml = 0;
|
|
|
|
}
|
2005-09-15 00:16:55 +00:00
|
|
|
|
2007-06-11 18:34:26 +00:00
|
|
|
// if null URL, detach from current AMS
|
2006-10-23 16:00:51 +00:00
|
|
|
//
|
2010-09-08 18:06:56 +00:00
|
|
|
if (!strlen(url) && strlen(gstate.acct_mgr_info.master_url)) {
|
2005-09-15 00:16:55 +00:00
|
|
|
msg_printf(NULL, MSG_INFO, "Removing account manager info");
|
2005-06-28 23:56:56 +00:00
|
|
|
gstate.acct_mgr_info.clear();
|
|
|
|
boinc_delete_file(ACCT_MGR_URL_FILENAME);
|
|
|
|
boinc_delete_file(ACCT_MGR_LOGIN_FILENAME);
|
2005-09-15 00:16:55 +00:00
|
|
|
error_num = 0;
|
2006-01-24 21:38:03 +00:00
|
|
|
for (i=0; i<gstate.projects.size(); i++) {
|
2010-12-01 18:04:18 +00:00
|
|
|
gstate.projects[i]->detach_ams();
|
2006-01-24 21:38:03 +00:00
|
|
|
}
|
2005-06-28 23:56:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-06 00:37:07 +00:00
|
|
|
canonicalize_master_url(url);
|
|
|
|
if (!valid_master_url(url)) {
|
2005-09-15 00:16:55 +00:00
|
|
|
error_num = ERR_INVALID_URL;
|
2005-06-17 06:31:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-03-07 23:28:27 +00:00
|
|
|
|
2010-09-08 18:06:56 +00:00
|
|
|
strlcpy(ami.master_url, url, sizeof(ami.master_url));
|
|
|
|
strlcpy(ami.project_name, "", sizeof(ami.project_name));
|
2006-03-09 10:21:07 +00:00
|
|
|
strlcpy(ami.login_name, name.c_str(), sizeof(ami.login_name));
|
|
|
|
strlcpy(ami.password_hash, password_hash.c_str(), sizeof(ami.password_hash));
|
2005-06-21 08:22:18 +00:00
|
|
|
|
2005-12-09 22:29:21 +00:00
|
|
|
FILE* f = boinc_fopen(ACCT_MGR_REQUEST_FILENAME, "w");
|
|
|
|
if (!f) return ERR_FOPEN;
|
|
|
|
fprintf(f,
|
|
|
|
"<acct_mgr_request>\n"
|
|
|
|
" <name>%s</name>\n"
|
2005-12-14 01:44:11 +00:00
|
|
|
" <password_hash>%s</password_hash>\n"
|
2005-12-09 22:29:21 +00:00
|
|
|
" <host_cpid>%s</host_cpid>\n"
|
2006-01-09 07:14:58 +00:00
|
|
|
" <domain_name>%s</domain_name>\n"
|
2005-12-09 22:29:21 +00:00
|
|
|
" <client_version>%d.%d.%d</client_version>\n"
|
2006-06-01 20:53:59 +00:00
|
|
|
" <run_mode>%s</run_mode>\n",
|
2005-12-14 01:44:11 +00:00
|
|
|
name.c_str(), password_hash.c_str(),
|
2005-11-28 00:40:54 +00:00
|
|
|
gstate.host_info.host_cpid,
|
2006-01-09 07:14:58 +00:00
|
|
|
gstate.host_info.domain_name,
|
2006-12-14 00:42:43 +00:00
|
|
|
gstate.core_client_version.major,
|
|
|
|
gstate.core_client_version.minor,
|
|
|
|
gstate.core_client_version.release,
|
2006-11-10 17:55:22 +00:00
|
|
|
run_mode_name[gstate.run_mode.get_perm()]
|
2005-11-28 00:40:54 +00:00
|
|
|
);
|
2006-03-02 07:17:18 +00:00
|
|
|
if (strlen(gstate.acct_mgr_info.previous_host_cpid)) {
|
2006-01-09 07:14:58 +00:00
|
|
|
fprintf(f,
|
|
|
|
" <previous_host_cpid>%s</previous_host_cpid>\n",
|
2006-03-02 07:17:18 +00:00
|
|
|
gstate.acct_mgr_info.previous_host_cpid
|
2006-01-09 07:14:58 +00:00
|
|
|
);
|
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
|
|
|
|
// If the AMS requested it, send GUI RPC port and password hash.
|
|
|
|
// This is for the "farm" account manager so it
|
|
|
|
// can know where to send GUI RPC requests to
|
|
|
|
// without having to configure each host
|
|
|
|
//
|
2006-01-06 23:13:21 +00:00
|
|
|
if (gstate.acct_mgr_info.send_gui_rpc_info) {
|
|
|
|
if (gstate.cmdline_gui_rpc_port) {
|
|
|
|
fprintf(f," <gui_rpc_port>%d</gui_rpc_port>\n", gstate.cmdline_gui_rpc_port);
|
|
|
|
} else {
|
|
|
|
fprintf(f," <gui_rpc_port>%d</gui_rpc_port>\n", GUI_RPC_PORT);
|
|
|
|
}
|
|
|
|
if (boinc_file_exists(GUI_RPC_PASSWD_FILE)) {
|
|
|
|
strcpy(password, "");
|
|
|
|
pwdf = fopen(GUI_RPC_PASSWD_FILE, "r");
|
|
|
|
if (pwdf) {
|
2007-03-04 02:30:48 +00:00
|
|
|
if (fgets(password, 256, pwdf)) {
|
|
|
|
strip_whitespace(password);
|
|
|
|
}
|
2006-01-06 23:13:21 +00:00
|
|
|
fclose(pwdf);
|
|
|
|
}
|
|
|
|
fprintf(f," <gui_rpc_password>%s</gui_rpc_password>\n", password);
|
|
|
|
}
|
|
|
|
}
|
2005-12-09 22:29:21 +00:00
|
|
|
for (i=0; i<gstate.projects.size(); i++) {
|
|
|
|
PROJECT* p = gstate.projects[i];
|
2010-11-17 20:04:58 +00:00
|
|
|
double not_started_dur, in_progress_dur;
|
|
|
|
p->get_task_durs(not_started_dur, in_progress_dur);
|
2006-01-25 23:43:38 +00:00
|
|
|
fprintf(f,
|
|
|
|
" <project>\n"
|
|
|
|
" <url>%s</url>\n"
|
|
|
|
" <project_name>%s</project_name>\n"
|
|
|
|
" <suspended_via_gui>%d</suspended_via_gui>\n"
|
|
|
|
" <account_key>%s</account_key>\n"
|
|
|
|
" <hostid>%d</hostid>\n"
|
2010-11-17 20:04:58 +00:00
|
|
|
" <not_started_dur>%f</not_started_dur>\n"
|
|
|
|
" <in_progress_dur>%f</in_progress_dur>\n"
|
2010-12-02 19:38:25 +00:00
|
|
|
" <attached_via_acct_mgr>%d</attached_via_acct_mgr>\n"
|
|
|
|
" <dont_request_more_work>%d</dont_request_more_work>\n"
|
|
|
|
" <detach_when_done>%d</detach_when_done>\n"
|
|
|
|
" <ended>%d</ended>\n"
|
2006-01-25 23:43:38 +00:00
|
|
|
" </project>\n",
|
|
|
|
p->master_url,
|
|
|
|
p->project_name,
|
2010-11-27 04:02:15 +00:00
|
|
|
p->suspended_via_gui?1:0,
|
2006-01-25 23:43:38 +00:00
|
|
|
p->authenticator,
|
|
|
|
p->hostid,
|
2010-11-17 20:04:58 +00:00
|
|
|
not_started_dur,
|
|
|
|
in_progress_dur,
|
2010-11-27 04:02:15 +00:00
|
|
|
p->attached_via_acct_mgr?1:0,
|
|
|
|
p->dont_request_more_work?1:0,
|
|
|
|
p->detach_when_done?1:0,
|
|
|
|
p->ended?1:0
|
2006-01-25 23:43:38 +00:00
|
|
|
);
|
2005-12-09 22:29:21 +00:00
|
|
|
}
|
2006-06-01 19:03:00 +00:00
|
|
|
if (boinc_file_exists(GLOBAL_PREFS_FILE_NAME)) {
|
|
|
|
FILE* fprefs = fopen(GLOBAL_PREFS_FILE_NAME, "r");
|
|
|
|
if (fprefs) {
|
|
|
|
copy_stream(fprefs, f);
|
|
|
|
fclose(fprefs);
|
|
|
|
}
|
|
|
|
}
|
2010-11-27 20:15:48 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
mf.init_file(f);
|
|
|
|
gstate.host_info.write(mf, !config.suppress_net_info, true);
|
2011-01-06 23:09:13 +00:00
|
|
|
if (strlen(gstate.acct_mgr_info.opaque)) {
|
|
|
|
fprintf(f,
|
|
|
|
" <opaque>\n%s\n"
|
|
|
|
" </opaque>\n",
|
|
|
|
gstate.acct_mgr_info.opaque
|
|
|
|
);
|
|
|
|
}
|
2005-12-09 22:29:21 +00:00
|
|
|
fprintf(f, "</acct_mgr_request>\n");
|
|
|
|
fclose(f);
|
2007-04-06 00:37:07 +00:00
|
|
|
sprintf(buf, "%srpc.php", url);
|
2005-12-09 22:29:21 +00:00
|
|
|
retval = gstate.gui_http.do_rpc_post(
|
2010-07-22 19:13:36 +00:00
|
|
|
this, buf, ACCT_MGR_REQUEST_FILENAME, ACCT_MGR_REPLY_FILENAME, true
|
2005-12-09 22:29:21 +00:00
|
|
|
);
|
2005-06-17 06:31:32 +00:00
|
|
|
if (retval) {
|
2005-09-15 00:16:55 +00:00
|
|
|
error_num = retval;
|
2005-06-17 06:31:32 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2007-04-06 00:37:07 +00:00
|
|
|
msg_printf(NULL, MSG_INFO, "Contacting account manager at %s", url);
|
2005-03-11 00:33:25 +00:00
|
|
|
|
2005-02-06 21:26:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-12 18:18:15 +00:00
|
|
|
int AM_ACCOUNT::parse(XML_PARSER& xp) {
|
|
|
|
char tag[256];
|
2011-01-06 23:09:13 +00:00
|
|
|
bool is_tag, btemp;
|
|
|
|
int retval;
|
2007-03-21 03:23:50 +00:00
|
|
|
double dtemp;
|
2005-12-15 00:55:09 +00:00
|
|
|
|
2005-12-08 19:21:56 +00:00
|
|
|
detach = false;
|
2006-03-17 20:18:39 +00:00
|
|
|
update = false;
|
2010-12-02 04:53:12 +00:00
|
|
|
no_cpu = false;
|
|
|
|
no_cuda = false;
|
|
|
|
no_ati = false;
|
2007-03-21 03:23:50 +00:00
|
|
|
dont_request_more_work.init();
|
|
|
|
detach_when_done.init();
|
2010-11-17 20:04:58 +00:00
|
|
|
suspend.init();
|
|
|
|
abort_not_started.init();
|
2005-12-14 23:43:50 +00:00
|
|
|
url = "";
|
2005-12-15 00:55:09 +00:00
|
|
|
strcpy(url_signature, "");
|
2005-12-14 23:43:50 +00:00
|
|
|
authenticator = "";
|
2007-03-21 03:23:50 +00:00
|
|
|
resource_share.init();
|
2005-12-14 23:43:50 +00:00
|
|
|
|
2006-09-12 18:18:15 +00:00
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
2011-01-06 23:09:13 +00:00
|
|
|
if (!is_tag) {
|
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2007-01-25 23:39:06 +00:00
|
|
|
"[unparsed_xml] AM_ACCOUNT::parse: unexpected text %s",
|
|
|
|
tag
|
|
|
|
);
|
2011-01-06 23:09:13 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2006-09-12 18:18:15 +00:00
|
|
|
if (!strcmp(tag, "/account")) {
|
2007-10-31 23:22:24 +00:00
|
|
|
if (url.length()) return 0;
|
2005-03-10 00:43:22 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2006-09-12 18:18:15 +00:00
|
|
|
if (xp.parse_string(tag, "url", url)) continue;
|
|
|
|
if (!strcmp(tag, "url_signature")) {
|
|
|
|
retval = xp.element_contents("</url_signature>", url_signature, sizeof(url_signature));
|
2005-12-15 00:55:09 +00:00
|
|
|
if (retval) return retval;
|
2011-01-06 23:09:13 +00:00
|
|
|
strcat(url_signature, "\n");
|
2005-12-15 00:55:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-09-12 18:18:15 +00:00
|
|
|
if (xp.parse_string(tag, "authenticator", authenticator)) continue;
|
|
|
|
if (xp.parse_bool(tag, "detach", detach)) continue;
|
|
|
|
if (xp.parse_bool(tag, "update", update)) continue;
|
2010-12-02 04:53:12 +00:00
|
|
|
if (xp.parse_bool(tag, "no_cpu", no_cpu)) continue;
|
|
|
|
if (xp.parse_bool(tag, "no_cuda", no_cuda)) continue;
|
|
|
|
if (xp.parse_bool(tag, "no_ati", no_ati)) continue;
|
2007-03-21 03:23:50 +00:00
|
|
|
if (xp.parse_bool(tag, "dont_request_more_work", btemp)) {
|
|
|
|
dont_request_more_work.set(btemp);
|
2007-06-08 07:55:27 +00:00
|
|
|
continue;
|
2007-03-21 03:23:50 +00:00
|
|
|
}
|
|
|
|
if (xp.parse_bool(tag, "detach_when_done", btemp)) {
|
|
|
|
detach_when_done.set(btemp);
|
2007-06-08 07:55:27 +00:00
|
|
|
continue;
|
2007-03-21 03:23:50 +00:00
|
|
|
}
|
|
|
|
if (xp.parse_double(tag, "resource_share", dtemp)) {
|
2010-04-07 16:20:49 +00:00
|
|
|
if (dtemp >= 0) {
|
2008-03-27 18:25:29 +00:00
|
|
|
resource_share.set(dtemp);
|
|
|
|
} else {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"Resource share out of range: %f", dtemp
|
|
|
|
);
|
|
|
|
}
|
2007-06-08 07:55:27 +00:00
|
|
|
continue;
|
2007-03-21 03:23:50 +00:00
|
|
|
}
|
2010-11-17 20:04:58 +00:00
|
|
|
if (xp.parse_bool(tag, "suspend", btemp)) {
|
|
|
|
suspend.set(btemp);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.parse_bool(tag, "abort_not_started", btemp)) {
|
|
|
|
abort_not_started.set(btemp);
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-08 07:55:27 +00:00
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"[unparsed_xml] AM_ACCOUNT: unrecognized %s", tag
|
|
|
|
);
|
|
|
|
}
|
2007-07-03 21:55:50 +00:00
|
|
|
xp.skip_unexpected(tag, log_flags.unparsed_xml, "AM_ACCOUNT::parse");
|
2005-03-10 00:43:22 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
2005-02-06 21:26:21 +00:00
|
|
|
}
|
|
|
|
|
2005-12-15 00:55:09 +00:00
|
|
|
int ACCT_MGR_OP::parse(FILE* f) {
|
2006-09-12 18:18:15 +00:00
|
|
|
char tag[1024];
|
2011-01-06 23:09:13 +00:00
|
|
|
bool is_tag;
|
2006-01-09 07:14:58 +00:00
|
|
|
string message;
|
2005-02-06 21:26:21 +00:00
|
|
|
int retval;
|
2011-01-06 23:09:13 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
mf.init_file(f);
|
|
|
|
XML_PARSER xp(&mf);
|
2005-02-06 21:26:21 +00:00
|
|
|
|
|
|
|
accounts.clear();
|
2005-06-21 08:22:18 +00:00
|
|
|
error_str = "";
|
2006-02-01 12:18:10 +00:00
|
|
|
error_num = 0;
|
2005-11-26 00:12:44 +00:00
|
|
|
repeat_sec = 0;
|
2006-06-01 19:03:00 +00:00
|
|
|
strcpy(host_venue, "");
|
2011-01-06 23:09:13 +00:00
|
|
|
strcpy(ami.opaque, "");
|
2010-09-08 20:20:02 +00:00
|
|
|
rss_feeds.clear();
|
2011-01-06 23:09:13 +00:00
|
|
|
if (!xp.parse_start("acct_mgr_reply")) return ERR_XML_PARSE;
|
2006-09-12 18:18:15 +00:00
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
2011-01-06 23:09:13 +00:00
|
|
|
if (!is_tag) {
|
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2007-01-25 23:39:06 +00:00
|
|
|
"[unparsed_xml] ACCT_MGR_OP::parse: unexpected text %s",
|
|
|
|
tag
|
|
|
|
);
|
2011-01-06 23:09:13 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2006-09-12 18:18:15 +00:00
|
|
|
if (!strcmp(tag, "/acct_mgr_reply")) return 0;
|
2010-09-08 18:06:56 +00:00
|
|
|
if (xp.parse_str(tag, "name", ami.project_name, 256)) continue;
|
2006-09-12 18:18:15 +00:00
|
|
|
if (xp.parse_int(tag, "error_num", error_num)) continue;
|
|
|
|
if (xp.parse_string(tag, "error", error_str)) continue;
|
|
|
|
if (xp.parse_double(tag, "repeat_sec", repeat_sec)) continue;
|
|
|
|
if (xp.parse_string(tag, "message", message)) {
|
2006-01-09 07:14:58 +00:00
|
|
|
msg_printf(NULL, MSG_INFO, "Account manager: %s", message.c_str());
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-06 23:09:13 +00:00
|
|
|
if (!strcmp(tag, "opaque")) {
|
|
|
|
retval = xp.element_contents("</opaque>", ami.opaque, sizeof(ami.opaque));
|
|
|
|
if (retval) return retval;
|
|
|
|
continue;
|
|
|
|
}
|
2006-09-12 18:18:15 +00:00
|
|
|
if (!strcmp(tag, "signing_key")) {
|
|
|
|
retval = xp.element_contents("</signing_key>", ami.signing_key, sizeof(ami.signing_key));
|
2005-12-15 00:55:09 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
continue;
|
|
|
|
}
|
2006-11-02 00:16:02 +00:00
|
|
|
if (!strcmp(tag, "account")) {
|
2005-11-26 00:12:44 +00:00
|
|
|
AM_ACCOUNT account;
|
2006-09-12 18:18:15 +00:00
|
|
|
retval = account.parse(xp);
|
2007-10-31 23:22:24 +00:00
|
|
|
if (retval) {
|
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
|
|
|
"Can't parse account in account manager reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
accounts.push_back(account);
|
|
|
|
}
|
2005-12-15 00:55:09 +00:00
|
|
|
continue;
|
2005-03-10 00:43:22 +00:00
|
|
|
}
|
2006-11-02 00:16:02 +00:00
|
|
|
if (!strcmp(tag, "global_preferences")) {
|
2006-06-01 19:03:00 +00:00
|
|
|
retval = dup_element_contents(
|
|
|
|
f,
|
|
|
|
"</global_preferences>",
|
|
|
|
&global_prefs_xml
|
|
|
|
);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-06-01 19:03:00 +00:00
|
|
|
"Can't parse global prefs in account manager reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2010-09-08 20:20:02 +00:00
|
|
|
if (xp.parse_str(tag, "host_venue", host_venue, sizeof(host_venue))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "rss_feeds")) {
|
|
|
|
got_rss_feeds = true;
|
|
|
|
parse_rss_feed_descs(mf, rss_feeds);
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-08 07:55:27 +00:00
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"[unparsed_xml] ACCT_MGR_OP::parse: unrecognized %s", tag
|
|
|
|
);
|
|
|
|
}
|
2007-07-03 21:55:50 +00:00
|
|
|
xp.skip_unexpected(tag, log_flags.unparsed_xml, "ACCT_MGR_OP::parse");
|
2005-03-10 00:43:22 +00:00
|
|
|
}
|
2005-02-06 21:26:21 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2005-08-05 22:00:19 +00:00
|
|
|
void ACCT_MGR_OP::handle_reply(int http_op_retval) {
|
2010-09-24 20:02:42 +00:00
|
|
|
#ifndef SIM
|
2005-03-10 00:43:22 +00:00
|
|
|
unsigned int i;
|
2005-08-05 18:41:46 +00:00
|
|
|
int retval;
|
2005-12-14 23:43:50 +00:00
|
|
|
bool verified;
|
2005-11-26 00:12:44 +00:00
|
|
|
PROJECT* pp;
|
2005-12-15 00:55:09 +00:00
|
|
|
bool sig_ok;
|
2005-08-05 18:41:46 +00:00
|
|
|
|
|
|
|
if (http_op_retval == 0) {
|
|
|
|
FILE* f = fopen(ACCT_MGR_REPLY_FILENAME, "r");
|
|
|
|
if (f) {
|
2005-12-15 00:55:09 +00:00
|
|
|
retval = parse(f);
|
2005-08-05 18:41:46 +00:00
|
|
|
fclose(f);
|
|
|
|
} else {
|
|
|
|
retval = ERR_FOPEN;
|
|
|
|
}
|
|
|
|
} else {
|
2006-02-01 12:18:10 +00:00
|
|
|
error_num = http_op_retval;
|
2005-08-05 18:41:46 +00:00
|
|
|
}
|
2006-02-01 12:18:10 +00:00
|
|
|
|
2006-06-01 05:29:37 +00:00
|
|
|
gstate.acct_mgr_info.password_error = false;
|
|
|
|
if (error_num == ERR_BAD_PASSWD && !via_gui) {
|
|
|
|
gstate.acct_mgr_info.password_error = true;
|
|
|
|
}
|
2006-02-01 12:18:10 +00:00
|
|
|
// check both error_str and error_num since an account manager may only
|
|
|
|
// return a BOINC based error code for password failures or invalid
|
|
|
|
// email addresses
|
|
|
|
//
|
|
|
|
if (error_str.size()) {
|
2009-12-23 18:02:40 +00:00
|
|
|
msg_printf(NULL, MSG_USER_ALERT,
|
2010-06-08 23:37:44 +00:00
|
|
|
"%s %s: %s",
|
2010-09-08 18:06:56 +00:00
|
|
|
gstate.acct_mgr_info.project_name,
|
2010-06-08 23:37:44 +00:00
|
|
|
_("error"),
|
2010-06-04 16:57:33 +00:00
|
|
|
error_str.c_str()
|
2007-01-25 23:39:06 +00:00
|
|
|
);
|
2006-02-01 12:18:10 +00:00
|
|
|
if (!error_num) {
|
|
|
|
error_num = ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
} else if (error_num) {
|
2009-12-23 18:02:40 +00:00
|
|
|
msg_printf(NULL, MSG_USER_ALERT,
|
2010-06-08 23:37:44 +00:00
|
|
|
"%s %s: %s",
|
2010-09-08 18:06:56 +00:00
|
|
|
gstate.acct_mgr_info.project_name,
|
2010-06-08 23:37:44 +00:00
|
|
|
_("error"),
|
2010-06-04 16:57:33 +00:00
|
|
|
boincerror(error_num)
|
2007-01-25 23:39:06 +00:00
|
|
|
);
|
2006-01-09 07:14:58 +00:00
|
|
|
}
|
2005-06-21 08:22:18 +00:00
|
|
|
|
2010-11-25 04:35:50 +00:00
|
|
|
if (error_num) {
|
|
|
|
gstate.acct_mgr_info.next_rpc_time =
|
|
|
|
gstate.now
|
|
|
|
+ calculate_exponential_backoff(
|
|
|
|
gstate.acct_mgr_info.nfailures,
|
|
|
|
ACCT_MGR_MIN_BACKOFF, ACCT_MGR_MAX_BACKOFF
|
|
|
|
)
|
|
|
|
;
|
|
|
|
gstate.acct_mgr_info.nfailures++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gstate.acct_mgr_info.nfailures = 0;
|
2006-02-01 12:18:10 +00:00
|
|
|
|
|
|
|
msg_printf(NULL, MSG_INFO, "Account manager contact succeeded");
|
|
|
|
|
2005-12-14 23:43:50 +00:00
|
|
|
// demand a signing key
|
|
|
|
//
|
2005-12-15 00:55:09 +00:00
|
|
|
sig_ok = true;
|
2005-12-14 23:43:50 +00:00
|
|
|
if (!strlen(ami.signing_key)) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
|
|
|
"No signing key from account manager"
|
|
|
|
);
|
2005-12-15 00:55:09 +00:00
|
|
|
sig_ok = false;
|
2005-12-14 23:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// don't accept new signing key if we already have one
|
|
|
|
//
|
|
|
|
if (strlen(gstate.acct_mgr_info.signing_key)
|
|
|
|
&& strcmp(gstate.acct_mgr_info.signing_key, ami.signing_key)
|
|
|
|
) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
|
|
|
"Inconsistent signing key from account manager"
|
|
|
|
);
|
2005-12-15 00:55:09 +00:00
|
|
|
sig_ok = false;
|
2005-12-14 23:43:50 +00:00
|
|
|
}
|
2005-06-21 08:22:18 +00:00
|
|
|
|
2005-12-15 00:55:09 +00:00
|
|
|
if (sig_ok) {
|
2010-09-08 18:06:56 +00:00
|
|
|
strcpy(gstate.acct_mgr_info.master_url, ami.master_url);
|
|
|
|
strcpy(gstate.acct_mgr_info.project_name, ami.project_name);
|
2006-03-02 07:17:18 +00:00
|
|
|
strcpy(gstate.acct_mgr_info.signing_key, ami.signing_key);
|
2006-03-07 23:28:27 +00:00
|
|
|
strcpy(gstate.acct_mgr_info.login_name, ami.login_name);
|
|
|
|
strcpy(gstate.acct_mgr_info.password_hash, ami.password_hash);
|
2011-01-06 23:09:13 +00:00
|
|
|
strcpy(gstate.acct_mgr_info.opaque, ami.opaque);
|
2005-12-15 00:55:09 +00:00
|
|
|
|
2006-06-01 19:03:00 +00:00
|
|
|
// process projects
|
2005-12-15 00:55:09 +00:00
|
|
|
//
|
|
|
|
for (i=0; i<accounts.size(); i++) {
|
|
|
|
AM_ACCOUNT& acct = accounts[i];
|
|
|
|
retval = verify_string2(acct.url.c_str(), acct.url_signature, ami.signing_key, verified);
|
|
|
|
if (retval || !verified) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
|
|
|
"Bad signature for URL %s", acct.url.c_str()
|
|
|
|
);
|
2005-12-15 00:55:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pp = gstate.lookup_project(acct.url.c_str());
|
|
|
|
if (pp) {
|
|
|
|
if (acct.detach) {
|
2011-01-20 00:36:45 +00:00
|
|
|
if (pp->attached_via_acct_mgr) {
|
|
|
|
gstate.detach_project(pp);
|
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
} else {
|
2007-10-31 23:22:24 +00:00
|
|
|
// BAM! leaves authenticator blank if our request message
|
|
|
|
// had the current account info
|
|
|
|
//
|
|
|
|
if (acct.authenticator.size() && strcmp(pp->authenticator, acct.authenticator.c_str())) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(pp, MSG_INFO,
|
2005-12-15 00:55:09 +00:00
|
|
|
"Already attached under another account"
|
|
|
|
);
|
|
|
|
} else {
|
2006-05-09 19:34:30 +00:00
|
|
|
//msg_printf(pp, MSG_INFO, "Already attached");
|
2005-12-15 00:55:09 +00:00
|
|
|
pp->attached_via_acct_mgr = true;
|
2007-03-21 03:23:50 +00:00
|
|
|
if (acct.dont_request_more_work.present) {
|
|
|
|
pp->dont_request_more_work = acct.dont_request_more_work.value;
|
|
|
|
}
|
|
|
|
if (acct.detach_when_done.present) {
|
|
|
|
pp->detach_when_done = acct.detach_when_done.value;
|
- scheduler: add <workload_sim> config option.
If set, the scheduler will use EDF simulation,
together with the in-progress workload reported by the client,
to avoid sending results that
1) will miss their deadline, or
2) will cause an in-progress result to miss its deadline, or
3) will make an in-progress result miss its deadline
by more than is already predicted.
If this option is not set, or if the client request doesn't
include a workload description (i.e. the client is old)
use the existing approach, which assumes there's no workload.
NOTE: this is experimental. Production projects should not use it.
- EDF sim: write debug stuff to stderr instead of stdout
- Account manager:
- if an account is detach_when_done, set dont_request_more_work
- check done_request_more_work even for first-time projects
- update_uotd: generate a file for use by Google gadget
- user_links(): use full URLs (so can use in Google gadget)
client/
acct_mgr.C
work_fetch.C
html/
inc/
uotd.inc
util.inc
user/
uotd_gadget.php (new)
sched/
Makefile.am
edf_sim.C
sched_config.C,h
sched_resend.C
sched_send.C,h
server_types.C,h
svn path=/trunk/boinc/; revision=12639
2007-05-10 21:50:52 +00:00
|
|
|
if (pp->detach_when_done) {
|
|
|
|
pp->dont_request_more_work = true;
|
|
|
|
}
|
2007-03-21 03:23:50 +00:00
|
|
|
}
|
2006-03-17 20:18:39 +00:00
|
|
|
|
|
|
|
// initiate a scheduler RPC if requested by AMS
|
|
|
|
//
|
|
|
|
if (acct.update) {
|
2006-09-01 22:21:20 +00:00
|
|
|
pp->sched_rpc_pending = RPC_REASON_ACCT_MGR_REQ;
|
2006-03-17 20:18:39 +00:00
|
|
|
pp->min_rpc_time = 0;
|
|
|
|
}
|
2007-03-21 03:23:50 +00:00
|
|
|
if (acct.resource_share.present) {
|
|
|
|
pp->ams_resource_share = acct.resource_share.value;
|
2006-10-23 16:00:51 +00:00
|
|
|
pp->resource_share = pp->ams_resource_share;
|
2007-01-26 23:40:05 +00:00
|
|
|
} else {
|
|
|
|
// no host-specific resource share;
|
|
|
|
// if currently have one, restore to value from web
|
|
|
|
//
|
|
|
|
if (pp->ams_resource_share >= 0) {
|
|
|
|
pp->ams_resource_share = -1;
|
|
|
|
PROJECT p2;
|
|
|
|
strcpy(p2.master_url, pp->master_url);
|
|
|
|
retval = p2.parse_account_file();
|
|
|
|
if (!retval) {
|
|
|
|
pp->resource_share = p2.resource_share;
|
|
|
|
} else {
|
|
|
|
pp->resource_share = 100;
|
|
|
|
}
|
|
|
|
}
|
2006-10-23 16:00:51 +00:00
|
|
|
}
|
2010-11-17 20:04:58 +00:00
|
|
|
|
|
|
|
if (acct.suspend.present) {
|
|
|
|
if (acct.suspend.value) {
|
|
|
|
pp->suspend();
|
|
|
|
} else {
|
|
|
|
pp->resume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (acct.abort_not_started.present) {
|
|
|
|
if (acct.abort_not_started.value) {
|
|
|
|
pp->abort_not_started();
|
|
|
|
}
|
|
|
|
}
|
2010-12-02 04:53:12 +00:00
|
|
|
pp->no_cpu_ams = acct.no_cpu;
|
|
|
|
pp->no_cuda_ams = acct.no_cuda;
|
|
|
|
pp->no_ati_ams = acct.no_ati;
|
2005-12-15 00:55:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2010-06-22 18:57:30 +00:00
|
|
|
// here we don't already have the project.
|
|
|
|
// Attach to it, unless the acct mgr is telling us to detach
|
|
|
|
//
|
|
|
|
if (!acct.detach && !(acct.detach_when_done.present && acct.detach_when_done.value)) {
|
2006-03-17 20:18:39 +00:00
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"Attaching to %s", acct.url.c_str()
|
|
|
|
);
|
|
|
|
gstate.add_project(
|
2006-12-26 00:37:25 +00:00
|
|
|
acct.url.c_str(), acct.authenticator.c_str(), "", true
|
2006-03-17 20:18:39 +00:00
|
|
|
);
|
2010-12-02 04:53:12 +00:00
|
|
|
pp = gstate.lookup_project(acct.url.c_str());
|
|
|
|
if (pp) {
|
|
|
|
pp->no_cpu_ams = acct.no_cpu;
|
|
|
|
pp->no_cuda_ams = acct.no_cuda;
|
|
|
|
pp->no_ati_ams = acct.no_ati;
|
|
|
|
if (acct.dont_request_more_work.present) {
|
2010-06-22 17:50:25 +00:00
|
|
|
pp->dont_request_more_work = acct.dont_request_more_work.value;
|
|
|
|
}
|
2010-12-02 04:53:12 +00:00
|
|
|
} else {
|
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
|
|
|
"Failed to add project: %s",
|
|
|
|
acct.url.c_str()
|
|
|
|
);
|
- scheduler: add <workload_sim> config option.
If set, the scheduler will use EDF simulation,
together with the in-progress workload reported by the client,
to avoid sending results that
1) will miss their deadline, or
2) will cause an in-progress result to miss its deadline, or
3) will make an in-progress result miss its deadline
by more than is already predicted.
If this option is not set, or if the client request doesn't
include a workload description (i.e. the client is old)
use the existing approach, which assumes there's no workload.
NOTE: this is experimental. Production projects should not use it.
- EDF sim: write debug stuff to stderr instead of stdout
- Account manager:
- if an account is detach_when_done, set dont_request_more_work
- check done_request_more_work even for first-time projects
- update_uotd: generate a file for use by Google gadget
- user_links(): use full URLs (so can use in Google gadget)
client/
acct_mgr.C
work_fetch.C
html/
inc/
uotd.inc
util.inc
user/
uotd_gadget.php (new)
sched/
Makefile.am
edf_sim.C
sched_config.C,h
sched_resend.C
sched_send.C,h
server_types.C,h
svn path=/trunk/boinc/; revision=12639
2007-05-10 21:50:52 +00:00
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-26 00:12:44 +00:00
|
|
|
}
|
2006-06-01 19:03:00 +00:00
|
|
|
|
2006-06-02 20:32:20 +00:00
|
|
|
bool read_prefs = false;
|
|
|
|
if (strlen(host_venue) && strcmp(host_venue, gstate.main_host_venue)) {
|
|
|
|
strcpy(gstate.main_host_venue, host_venue);
|
|
|
|
read_prefs = true;
|
|
|
|
}
|
|
|
|
|
2006-06-01 19:03:00 +00:00
|
|
|
// process prefs if any
|
|
|
|
//
|
|
|
|
if (global_prefs_xml) {
|
|
|
|
retval = gstate.save_global_prefs(
|
2010-09-08 18:06:56 +00:00
|
|
|
global_prefs_xml, ami.master_url, ami.master_url
|
2006-06-01 19:03:00 +00:00
|
|
|
);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't save global prefs");
|
2006-06-01 19:03:00 +00:00
|
|
|
}
|
2006-06-02 20:32:20 +00:00
|
|
|
read_prefs = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// process prefs if prefs or venue changed
|
|
|
|
//
|
|
|
|
if (read_prefs) {
|
|
|
|
gstate.read_global_prefs();
|
2006-06-01 19:03:00 +00:00
|
|
|
}
|
2010-09-08 20:20:02 +00:00
|
|
|
|
|
|
|
if (got_rss_feeds) {
|
|
|
|
handle_sr_feeds(rss_feeds, &gstate.acct_mgr_info);
|
|
|
|
}
|
2005-11-26 00:12:44 +00:00
|
|
|
}
|
|
|
|
|
2006-03-02 07:17:18 +00:00
|
|
|
strcpy(gstate.acct_mgr_info.previous_host_cpid, gstate.host_info.host_cpid);
|
2005-11-26 00:12:44 +00:00
|
|
|
if (repeat_sec) {
|
|
|
|
gstate.acct_mgr_info.next_rpc_time = gstate.now + repeat_sec;
|
|
|
|
} else {
|
|
|
|
gstate.acct_mgr_info.next_rpc_time = gstate.now + 86400;
|
2005-03-11 00:33:25 +00:00
|
|
|
}
|
2005-12-09 22:29:21 +00:00
|
|
|
gstate.acct_mgr_info.write_info();
|
2005-12-15 00:55:09 +00:00
|
|
|
gstate.set_client_state_dirty("account manager RPC");
|
2010-09-24 20:02:42 +00:00
|
|
|
#endif
|
2005-02-06 21:26:21 +00:00
|
|
|
}
|
2005-06-21 08:22:18 +00:00
|
|
|
|
|
|
|
int ACCT_MGR_INFO::write_info() {
|
|
|
|
FILE* p;
|
2010-09-08 18:06:56 +00:00
|
|
|
if (strlen(master_url)) {
|
2005-06-21 08:22:18 +00:00
|
|
|
p = fopen(ACCT_MGR_URL_FILENAME, "w");
|
|
|
|
if (p) {
|
2011-01-06 23:09:13 +00:00
|
|
|
fprintf(p,
|
2005-06-21 08:22:18 +00:00
|
|
|
"<acct_mgr>\n"
|
|
|
|
" <name>%s</name>\n"
|
2005-12-14 23:43:50 +00:00
|
|
|
" <url>%s</url>\n",
|
2010-09-08 18:06:56 +00:00
|
|
|
project_name,
|
|
|
|
master_url
|
2005-06-21 08:22:18 +00:00
|
|
|
);
|
2006-03-02 07:17:18 +00:00
|
|
|
if (send_gui_rpc_info) fprintf(p," <send_gui_rpc_info/>\n");
|
2005-12-14 23:43:50 +00:00
|
|
|
if (strlen(signing_key)) {
|
2011-01-06 23:09:13 +00:00
|
|
|
fprintf(p,
|
2006-09-12 18:18:15 +00:00
|
|
|
" <signing_key>\n%s\n</signing_key>\n",
|
2005-12-14 23:43:50 +00:00
|
|
|
signing_key
|
|
|
|
);
|
|
|
|
}
|
2011-01-06 23:09:13 +00:00
|
|
|
fprintf(p,
|
2005-12-14 23:43:50 +00:00
|
|
|
"</acct_mgr>\n"
|
|
|
|
);
|
2005-06-21 08:22:18 +00:00
|
|
|
fclose(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-28 23:56:56 +00:00
|
|
|
if (strlen(login_name)) {
|
2005-06-21 08:22:18 +00:00
|
|
|
p = fopen(ACCT_MGR_LOGIN_FILENAME, "w");
|
|
|
|
if (p) {
|
|
|
|
fprintf(
|
2011-01-06 23:09:13 +00:00
|
|
|
p,
|
2005-06-21 08:22:18 +00:00
|
|
|
"<acct_mgr_login>\n"
|
|
|
|
" <login>%s</login>\n"
|
2005-12-14 01:44:11 +00:00
|
|
|
" <password_hash>%s</password_hash>\n"
|
2006-01-09 07:14:58 +00:00
|
|
|
" <previous_host_cpid>%s</previous_host_cpid>\n"
|
2005-11-26 00:12:44 +00:00
|
|
|
" <next_rpc_time>%f</next_rpc_time>\n"
|
2011-01-06 23:09:13 +00:00
|
|
|
" <opaque>\n%s\n"
|
|
|
|
" </opaque>\n"
|
2005-06-21 08:22:18 +00:00
|
|
|
"</acct_mgr_login>\n",
|
2005-06-28 23:56:56 +00:00
|
|
|
login_name,
|
2005-12-14 01:44:11 +00:00
|
|
|
password_hash,
|
2006-01-09 07:14:58 +00:00
|
|
|
previous_host_cpid,
|
2006-09-12 18:18:15 +00:00
|
|
|
next_rpc_time,
|
2011-01-06 23:09:13 +00:00
|
|
|
opaque
|
2005-06-21 08:22:18 +00:00
|
|
|
);
|
|
|
|
fclose(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-28 23:56:56 +00:00
|
|
|
void ACCT_MGR_INFO::clear() {
|
2010-09-08 18:06:56 +00:00
|
|
|
strcpy(project_name, "");
|
|
|
|
strcpy(master_url, "");
|
2005-06-28 23:56:56 +00:00
|
|
|
strcpy(login_name, "");
|
2005-12-14 01:44:11 +00:00
|
|
|
strcpy(password_hash, "");
|
2005-12-14 23:43:50 +00:00
|
|
|
strcpy(signing_key, "");
|
2006-01-09 07:14:58 +00:00
|
|
|
strcpy(previous_host_cpid, "");
|
2011-01-06 23:09:13 +00:00
|
|
|
strcpy(opaque, "");
|
2005-12-09 22:29:21 +00:00
|
|
|
next_rpc_time = 0;
|
2010-11-25 04:35:50 +00:00
|
|
|
nfailures = 0;
|
2006-01-06 23:13:21 +00:00
|
|
|
send_gui_rpc_info = false;
|
2006-06-01 05:29:37 +00:00
|
|
|
password_error = false;
|
2005-06-28 23:56:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ACCT_MGR_INFO::ACCT_MGR_INFO() {
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
2006-11-03 19:24:21 +00:00
|
|
|
int ACCT_MGR_INFO::parse_login_file(FILE* p) {
|
2011-01-06 23:09:13 +00:00
|
|
|
char tag[1024];
|
|
|
|
bool is_tag;
|
2006-11-03 19:24:21 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
mf.init_file(p);
|
|
|
|
XML_PARSER xp(&mf);
|
|
|
|
if (!xp.parse_start("acct_mgr_login")) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
|
|
|
if (!is_tag) {
|
|
|
|
printf("unexpected text: %s\n", tag);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "/acct_mgr_login")) break;
|
|
|
|
else if (xp.parse_str(tag, "login", login_name, 256)) continue;
|
|
|
|
else if (xp.parse_str(tag, "password_hash", password_hash, 256)) continue;
|
|
|
|
else if (xp.parse_str(tag, "previous_host_cpid", previous_host_cpid, sizeof(previous_host_cpid))) continue;
|
|
|
|
else if (xp.parse_double(tag, "next_rpc_time", next_rpc_time)) continue;
|
|
|
|
else if (!strcmp(tag, "opaque")) {
|
|
|
|
retval = xp.element_contents("</opaque>", opaque, sizeof(opaque));
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-08 07:55:27 +00:00
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"[unparsed_xml] ACCT_MGR_INFO::parse_login: unrecognized %s", tag
|
|
|
|
);
|
|
|
|
}
|
2007-07-03 21:55:50 +00:00
|
|
|
xp.skip_unexpected(
|
|
|
|
tag, log_flags.unparsed_xml, "ACCT_MGR_INFO::parse_login_file"
|
|
|
|
);
|
2006-11-03 19:24:21 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-21 08:22:18 +00:00
|
|
|
int ACCT_MGR_INFO::init() {
|
2011-01-06 23:09:13 +00:00
|
|
|
char tag[1024];
|
|
|
|
bool is_tag;
|
2005-06-21 08:22:18 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
FILE* p;
|
2005-12-14 23:43:50 +00:00
|
|
|
int retval;
|
2005-06-21 08:22:18 +00:00
|
|
|
|
2005-06-28 23:56:56 +00:00
|
|
|
clear();
|
2005-06-21 08:22:18 +00:00
|
|
|
p = fopen(ACCT_MGR_URL_FILENAME, "r");
|
2005-12-14 23:43:50 +00:00
|
|
|
if (!p) return 0;
|
|
|
|
mf.init_file(p);
|
2011-01-06 23:09:13 +00:00
|
|
|
XML_PARSER xp(&mf);
|
|
|
|
if (!xp.parse_start("acct_mgr_login")) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
|
|
|
if (!is_tag) {
|
|
|
|
printf("unexpected text: %s\n", tag);
|
|
|
|
continue;
|
|
|
|
}
|
2006-09-12 18:18:15 +00:00
|
|
|
if (!strcmp(tag, "/acct_mgr")) break;
|
2010-09-08 18:06:56 +00:00
|
|
|
else if (xp.parse_str(tag, "name", project_name, 256)) continue;
|
|
|
|
else if (xp.parse_str(tag, "url", master_url, 256)) continue;
|
2006-09-12 18:18:15 +00:00
|
|
|
else if (xp.parse_bool(tag, "send_gui_rpc_info", send_gui_rpc_info)) continue;
|
|
|
|
else if (!strcmp(tag, "signing_key")) {
|
|
|
|
retval = xp.element_contents("</signing_key>", signing_key, sizeof(signing_key));
|
|
|
|
continue;
|
2005-06-21 08:22:18 +00:00
|
|
|
}
|
2009-06-12 21:34:33 +00:00
|
|
|
else if (xp.parse_bool(tag, "cookie_required", cookie_required)) continue;
|
|
|
|
else if (xp.parse_str(tag, "cookie_failure_url", cookie_failure_url, 256)) continue;
|
2007-06-08 07:55:27 +00:00
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"[unparsed_xml] ACCT_MGR_INFO::init: unrecognized %s", tag
|
|
|
|
);
|
|
|
|
}
|
2007-07-03 21:55:50 +00:00
|
|
|
xp.skip_unexpected(tag, log_flags.unparsed_xml, "ACCT_MGR_INFO::init");
|
2005-06-21 08:22:18 +00:00
|
|
|
}
|
2005-12-14 23:43:50 +00:00
|
|
|
fclose(p);
|
2005-06-21 08:22:18 +00:00
|
|
|
|
|
|
|
p = fopen(ACCT_MGR_LOGIN_FILENAME, "r");
|
|
|
|
if (p) {
|
2006-11-03 19:24:21 +00:00
|
|
|
parse_login_file(p);
|
2005-06-21 08:22:18 +00:00
|
|
|
fclose(p);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2005-09-22 08:46:51 +00:00
|
|
|
|
2005-11-26 00:12:44 +00:00
|
|
|
bool ACCT_MGR_INFO::poll() {
|
2010-09-08 18:06:56 +00:00
|
|
|
if (!using_am()) return false;
|
2009-12-22 03:56:24 +00:00
|
|
|
if (gstate.gui_http.is_busy()) return false;
|
2006-02-01 12:18:10 +00:00
|
|
|
|
2005-11-26 00:12:44 +00:00
|
|
|
if (gstate.now > next_rpc_time) {
|
2010-11-25 04:35:50 +00:00
|
|
|
|
|
|
|
// default synch period is 1 day
|
|
|
|
//
|
2005-11-28 06:28:55 +00:00
|
|
|
next_rpc_time = gstate.now + 86400;
|
2006-06-01 05:29:37 +00:00
|
|
|
gstate.acct_mgr_op.do_rpc(
|
2010-09-08 18:06:56 +00:00
|
|
|
master_url, login_name, password_hash, false
|
2006-06-01 05:29:37 +00:00
|
|
|
);
|
2005-11-26 00:12:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|