diff --git a/db/schema.sql b/db/schema.sql index 6c6adc9b8c..c64eb3f355 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -114,8 +114,9 @@ create table user ( posts smallint not null, -- reused: salt for weak auth - -- the following 4 not used by BOINC seti_id integer not null, + -- reused as 'run jobs on my hosts' flag from remote job submission + -- the following 3 not used by BOINC seti_nresults integer not null, seti_last_result_time integer not null, seti_total_cpu double not null, diff --git a/html/user/submit.php b/html/user/submit.php index 681ce3ecc5..f9428002b1 100644 --- a/html/user/submit.php +++ b/html/user/submit.php @@ -2,7 +2,7 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2011 University of California +// Copyright (C) 2024 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License @@ -17,10 +17,12 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -// web interface for managing batches -// (e.g. as part of remote job submission). -// Lets you see the status of batches, get their output files, -// abort them, retire them, etc. +// web interface for remote job submission: +// - links to job-submission pages +// - Admin (if privileged user) +// - manage batches +// view status, get output files, abort, retire +// - toggle 'use only my computers' require_once("../inc/submit_db.inc"); require_once("../inc/util.inc"); @@ -108,7 +110,7 @@ function show_complete($batches, $limit, $user, $app) { $n++; if ($first) { $first = false; - echo "

Completed batches

\n"; + echo "

Completed batches

\n"; if ($limit) { show_all_link($batches, BATCH_STATE_COMPLETE, $limit, $user, $app); } @@ -220,6 +222,27 @@ function handle_main($user) { echo "\n"; } + echo '

Where your jobs run

'; + if ($user->seti_id) { + echo "

+ Jobs you submit can run only on your computers. +

+ "; + show_button( + 'submit.php?action=toggle_loc', + 'Allow them to run on any computer.' + ); + } else { + echo "

+ Jobs you submit can run on any computer. +

+ "; + show_button( + 'submit.php?action=toggle_loc', + 'Allow them to run only on your computers.' + ); + } + // show links to admin pages if relevant // $usas = BoincUserSubmitApp::enum("user_id=$user->id"); @@ -268,6 +291,15 @@ function handle_main($user) { page_tail(); } +function handle_toggle_loc($user) { + if ($user->seti_id) { + $user->update('seti_id=0'); + } else { + $user->update('seti_id=1'); + } + handle_main($user); +} + function check_admin_access($user, $app_id) { $user_submit = BoincUserSubmit::lookup_userid($user->id); if (!$user_submit) error_page("no access"); @@ -683,6 +715,7 @@ case 'query_job': handle_query_job($user); break; case 'retire_batch': handle_retire_batch($user); break; case 'retire_batch_confirm': handle_retire_batch_confirm(); break; case 'show_all': handle_show_all($user); break; +case 'toggle_loc': handle_toggle_loc($user); default: error_page("no such action $action"); } diff --git a/html/user/submit_rpc_handler.php b/html/user/submit_rpc_handler.php index 9b5cb5e189..4b62668aa9 100644 --- a/html/user/submit_rpc_handler.php +++ b/html/user/submit_rpc_handler.php @@ -216,7 +216,8 @@ function stage_files(&$jobs) { function submit_jobs( $jobs, $job_params, $app, $batch_id, $priority, $app_version_num, $input_template_filename, // batch-level; can also specify per job - $output_template_filename + $output_template_filename, + $user ) { global $input_templates, $output_templates; @@ -259,12 +260,14 @@ function submit_jobs( $x .= "\n"; } - $errfile = "/tmp/create_work_" . getmypid() . ".err"; $cmd = "cd " . project_dir() . "; ./bin/create_work --appname $app->name --batch $batch_id"; + + if ($user->seti_id) { + $cmd .= " --target_user $user->id "; + } if ($priority !== null) { $cmd .= " --priority $priority"; } - if ($input_template_filename) { $cmd .= " --wu_template templates/$input_template_filename"; } @@ -289,7 +292,13 @@ function submit_jobs( if ($job_params->delay_bound) { $cmd .= " --delay_bound $job_params->delay_bound"; } - $cmd .= " --stdin >$errfile 2>&1"; + $cmd .= " --stdin "; + + // send stdin/stderr to a temp file + $cmd .= sprintf(' >%s 2>&1', + "/tmp/create_work_" . getmypid() . ".err" + ); + $h = popen($cmd, "w"); if ($h === false) { xml_error(-1, "can't run create_work"); @@ -520,7 +529,8 @@ function submit_batch($r) { submit_jobs( $jobs, $job_params, $app, $batch_id, $priority, $app_version_num, $input_template_filename, - $output_template_filename + $output_template_filename, + $user ); // set state to IN_PROGRESS only after creating jobs;