mirror of https://github.com/BOINC/boinc.git
- client: removed sprawl
svn path=/trunk/boinc/; revision=14721
This commit is contained in:
parent
51286a03dc
commit
ee34cf3ab7
|
@ -1302,3 +1302,14 @@ David Feb 9 2008
|
|||
app_control.C
|
||||
sched/
|
||||
sched_hr.C
|
||||
|
||||
David Feb 12 2008
|
||||
- client: removed sprawl
|
||||
|
||||
client/
|
||||
app_start.C
|
||||
client_state.C,h
|
||||
file_names.h
|
||||
sandbox.C
|
||||
lib/
|
||||
util.C,h
|
||||
|
|
|
@ -328,10 +328,6 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
FILE_REF fref;
|
||||
FILE_INFO* fip;
|
||||
int retval;
|
||||
#ifdef _WIN32
|
||||
CLIENT_AUTHORIZATION ca;
|
||||
std::string cmd_line;
|
||||
#endif
|
||||
|
||||
if (first_time && log_flags.task) {
|
||||
msg_printf(result->project, MSG_INFO,
|
||||
|
@ -465,6 +461,7 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
STARTUPINFO startup_info;
|
||||
char slotdirpath[256];
|
||||
char error_msg[1024];
|
||||
std::string cmd_line;
|
||||
|
||||
memset(&process_info, 0, sizeof(process_info));
|
||||
memset(&startup_info, 0, sizeof(startup_info));
|
||||
|
@ -498,16 +495,15 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
cmd_line = exec_path + std::string(" ") + wup->command_line;
|
||||
relative_to_absolute(slot_dir, slotdirpath);
|
||||
bool success = false;
|
||||
ca.init();
|
||||
for (i=0; i<5; i++) {
|
||||
if (ca.use_authorizations) {
|
||||
if (strlen(gstate.sandbox_user_account_name) {
|
||||
HANDLE hToken;
|
||||
std::string username = ca.boinc_project.username;
|
||||
std::string password = r_base64_decode(ca.boinc_project.password);
|
||||
std::string username = gstate.sandbox_user_account_name;
|
||||
std::string password = r_base64_decode(gstate.sandbox_user_account_password);
|
||||
if (!LogonUser( username.c_str(), NULL, password.c_str(),
|
||||
LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT,
|
||||
&hToken ) )
|
||||
{
|
||||
LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT,
|
||||
&hToken)
|
||||
) {
|
||||
windows_error_string(error_msg, sizeof(error_msg));
|
||||
msg_printf(wup->project, MSG_INTERNAL_ERROR,
|
||||
"LogonUser failed: %s", error_msg
|
||||
|
|
|
@ -118,6 +118,10 @@ CLIENT_STATE::CLIENT_STATE():
|
|||
new_version_check_time = 0;
|
||||
all_projects_list_check_time = 0;
|
||||
detach_console = false;
|
||||
#ifdef _WIN32
|
||||
strcpy(sandbox_account_name, "");
|
||||
strcpy(sandbox_account_password, "");
|
||||
#endif
|
||||
#ifdef SANDBOX
|
||||
g_use_sandbox = true; // User can override with -insecure command-line arg
|
||||
#endif
|
||||
|
@ -207,6 +211,7 @@ int CLIENT_STATE::init() {
|
|||
"BOINC is running as a service and as a non-system user."
|
||||
);
|
||||
}
|
||||
read_client_auth_file();
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
|
|
@ -111,7 +111,11 @@ public:
|
|||
char attach_project_auth[256];
|
||||
bool exit_before_upload;
|
||||
// exit when about to upload a file
|
||||
#ifndef _WIN32
|
||||
#ifdef _WIN32
|
||||
char sandbox_account_name[256];
|
||||
char sandbox_account_password[256];
|
||||
void read_client_auth_file();
|
||||
#else
|
||||
gid_t boinc_project_gid;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -88,5 +88,6 @@ extern void send_log_after(const char* filename, double t, MIOFILE& mf);
|
|||
#define TIME_STATS_LOG "time_stats_log"
|
||||
#define JOB_LOG_BASE "job_log_"
|
||||
#define CA_BUNDLE_FILENAME "ca-bundle.crt"
|
||||
#define CLIENT_AUTH_FILENAME "client_auth.xml"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,21 @@
|
|||
|
||||
bool g_use_sandbox = false;
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
int CLIENT_STATE::read_client_auth_file() {
|
||||
FILE* f;
|
||||
|
||||
f = fopen(CLIENT_AUTH_FILENAME, "r");
|
||||
if (!r) return;
|
||||
while (fgets(buf, 256, f)) {
|
||||
if (parse_str(buf, "<username>", sandbox_account_name)) continue;
|
||||
if (parse_str(buf, "<username>", sandbox_account_password)) continue;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
#else
|
||||
#ifndef _DEBUG
|
||||
static int lookup_group(char* name, gid_t& gid) {
|
||||
struct group* gp = getgrnam(name);
|
||||
|
|
|
@ -65,7 +65,7 @@ class BossaJob {
|
|||
}
|
||||
function update($clause) {
|
||||
$db = BossaDb::get();
|
||||
return $db->update('bossa_job', $clause);
|
||||
return $db->update($this, 'bossa_job', $clause);
|
||||
}
|
||||
static function lookup_id($id) {
|
||||
$db = BossaDb::get();
|
||||
|
@ -140,10 +140,8 @@ class BossaJobInst {
|
|||
$this->finish_time = time();
|
||||
$this->update("finish_time=$this->finish_time, info='$this->info'");
|
||||
|
||||
$job->npending--;
|
||||
$job->nsuccess++;
|
||||
$job->more_needed = ($job->npending+$job->nsuccess < $job->nsuccess_needed);
|
||||
return $job->update("npending=$job->npending, nsuccess=$job->nsuccess, more_needed=$job->more_needed");
|
||||
$now = time();
|
||||
return $job->update("transition_time=$now");
|
||||
}
|
||||
|
||||
// The given job instance has timed out.
|
||||
|
|
|
@ -28,9 +28,8 @@ function handle_job_completion($bj, $bji) {
|
|||
$response->have_ellipse = 0;
|
||||
} else {
|
||||
$response->have_ellipse = 1;
|
||||
$pic = $_GET['pic'];
|
||||
$response->cx = $pic.x;
|
||||
$response->cy = $pic.y;
|
||||
$response->cx = get_int('pic_x');
|
||||
$response->cy = get_int('pic_y');
|
||||
}
|
||||
$bji->info = json_encode($response);
|
||||
$bji->completed($bj);
|
||||
|
|
112
lib/util.C
112
lib/util.C
|
@ -286,62 +286,12 @@ void update_average(
|
|||
//
|
||||
#ifdef _WIN32
|
||||
|
||||
void BOINC_PROJECT_ACCOUNT::clear() {
|
||||
username.clear();
|
||||
password.clear();
|
||||
}
|
||||
|
||||
int BOINC_PROJECT_ACCOUNT::parse(MIOFILE& in) {
|
||||
char buf[256];
|
||||
while (in.fgets(buf, 256)) {
|
||||
if (match_tag(buf, "</boinc_project>")) return 0;
|
||||
if (parse_str(buf, "<username>", username)) continue;
|
||||
if (parse_str(buf, "<password>", password)) continue;
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
|
||||
void CLIENT_AUTHORIZATION::clear() {
|
||||
use_authorizations = false;
|
||||
boinc_project.clear();
|
||||
}
|
||||
|
||||
int CLIENT_AUTHORIZATION::parse(MIOFILE& in) {
|
||||
char buf[256];
|
||||
use_authorizations = true;
|
||||
|
||||
while (in.fgets(buf, 256)) {
|
||||
if (match_tag(buf, "</client_authorization>")) return 0;
|
||||
if (match_tag(buf, "<boinc_project>")) {
|
||||
boinc_project.parse(in);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
int CLIENT_AUTHORIZATION::init() {
|
||||
MIOFILE mf;
|
||||
FILE* p;
|
||||
|
||||
clear();
|
||||
p = fopen("client_auth.xml", "r");
|
||||
if (p) {
|
||||
mf.init_file(p);
|
||||
parse(mf);
|
||||
fclose(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_program(
|
||||
const char* dir, const char* file, int argc, char *const argv[], double nsecs, HANDLE& id
|
||||
const char* dir, const char* file, int argc, char *const argv[], double nsecs
|
||||
) {
|
||||
int retval;
|
||||
PROCESS_INFORMATION process_info;
|
||||
STARTUPINFO startup_info;
|
||||
CLIENT_AUTHORIZATION ca;
|
||||
char cmdline[1024];
|
||||
unsigned long status;
|
||||
|
||||
|
@ -357,55 +307,19 @@ int run_program(
|
|||
}
|
||||
}
|
||||
|
||||
ca.init();
|
||||
if (ca.use_authorizations) {
|
||||
HANDLE hToken;
|
||||
std::string username = ca.boinc_project.username;
|
||||
std::string password = r_base64_decode(ca.boinc_project.password);
|
||||
retval = LogonUser(
|
||||
username.c_str(),
|
||||
NULL,
|
||||
password.c_str(),
|
||||
LOGON32_LOGON_SERVICE,
|
||||
LOGON32_PROVIDER_DEFAULT,
|
||||
&hToken
|
||||
);
|
||||
if (!retval) {
|
||||
return -1; // LogonUser returns 1 if successful, false if it failed.
|
||||
}
|
||||
retval = CreateProcess(
|
||||
file,
|
||||
cmdline,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
dir,
|
||||
&startup_info,
|
||||
&process_info
|
||||
);
|
||||
|
||||
retval = CreateProcessAsUser(
|
||||
hToken,
|
||||
file,
|
||||
cmdline,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
dir,
|
||||
&startup_info,
|
||||
&process_info
|
||||
);
|
||||
|
||||
CloseHandle(hToken);
|
||||
|
||||
} else {
|
||||
|
||||
retval = CreateProcess(
|
||||
file,
|
||||
cmdline,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
dir,
|
||||
&startup_info,
|
||||
&process_info
|
||||
);
|
||||
|
||||
}
|
||||
if (!retval) {
|
||||
return -1; // CreateProcess returns 1 if successful, false if it failed.
|
||||
}
|
||||
|
|
35
lib/util.h
35
lib/util.h
|
@ -71,42 +71,9 @@ extern int boinc_calling_thread_cpu_time(double&);
|
|||
//
|
||||
extern void mysql_timestamp(double, char*);
|
||||
|
||||
// C++ API follows
|
||||
#ifdef __cplusplus
|
||||
|
||||
class MIOFILE;
|
||||
|
||||
class BOINC_PROJECT_ACCOUNT {
|
||||
public:
|
||||
std::string username;
|
||||
std::string password;
|
||||
|
||||
BOINC_PROJECT_ACCOUNT() { clear(); }
|
||||
~BOINC_PROJECT_ACCOUNT() { clear(); }
|
||||
|
||||
int parse(MIOFILE&);
|
||||
void clear();
|
||||
};
|
||||
|
||||
class CLIENT_AUTHORIZATION {
|
||||
public:
|
||||
bool use_authorizations;
|
||||
BOINC_PROJECT_ACCOUNT boinc_project;
|
||||
|
||||
CLIENT_AUTHORIZATION() { clear(); }
|
||||
~CLIENT_AUTHORIZATION() { clear(); }
|
||||
|
||||
int parse(MIOFILE&);
|
||||
int init();
|
||||
void clear();
|
||||
};
|
||||
|
||||
#endif // C++ part
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
extern int run_program(
|
||||
const char* path, const char* cdir, int argc, char *const argv[], double, HANDLE&
|
||||
const char* path, const char* cdir, int argc, char *const argv[], double
|
||||
);
|
||||
extern void kill_program(HANDLE);
|
||||
extern int get_exit_status(HANDLE);
|
||||
|
|
Loading…
Reference in New Issue