2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-11-12 18:11:31 +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.
|
2003-11-23 00:08:49 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +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.
|
2003-10-19 01:48:32 +00:00
|
|
|
//
|
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/>.
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2004-01-30 22:19:19 +00:00
|
|
|
// command-line parsing, and handling of 1-time actions
|
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
#include "cpp.h"
|
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2005-04-15 21:05:58 +00:00
|
|
|
#else
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2009-02-26 00:23:23 +00:00
|
|
|
#include <cstdio>
|
2005-04-15 21:05:58 +00:00
|
|
|
#include <unistd.h>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2007-02-21 16:26:51 +00:00
|
|
|
#include "str_util.h"
|
2009-11-05 18:02:51 +00:00
|
|
|
#include "url.h"
|
2009-06-16 20:54:44 +00:00
|
|
|
#include "str_replace.h"
|
2004-04-07 06:51:42 +00:00
|
|
|
#include "util.h"
|
2009-12-05 00:51:05 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2003-10-19 01:48:32 +00:00
|
|
|
#include "client_state.h"
|
2009-12-05 00:51:05 +00:00
|
|
|
#include "cs_proxy.h"
|
2012-04-30 21:00:28 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "project.h"
|
|
|
|
#include "sandbox.h"
|
2003-10-19 01:48:32 +00:00
|
|
|
|
|
|
|
static void print_options(char* prog) {
|
|
|
|
printf(
|
2007-06-20 16:27:27 +00:00
|
|
|
"The command-line options for %s are intended for debugging.\n"
|
2008-05-01 22:11:08 +00:00
|
|
|
"The recommended command-line interface is a separate program,'boinccmd'.\n"
|
2008-05-15 16:08:52 +00:00
|
|
|
"Run boinccmd in the same directory as %s.\n"
|
2007-06-20 16:27:27 +00:00
|
|
|
"\n"
|
2003-10-19 01:48:32 +00:00
|
|
|
"Usage: %s [options]\n"
|
2009-02-18 19:47:02 +00:00
|
|
|
" --abort_jobs_on_exit when client exits, abort and report jobs\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --allow_remote_gui_rpc allow remote GUI RPC connections\n"
|
|
|
|
" --allow_multiple_clients allow >1 instances per host\n"
|
|
|
|
" --attach_project <URL> <key> attach to a project\n"
|
|
|
|
" --check_all_logins for idle detection, check remote logins too\n"
|
|
|
|
" --daemon run as daemon (Unix)\n"
|
2011-06-12 20:58:43 +00:00
|
|
|
" --detach_console detach from console (Windows)\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --detach_project <URL> detach from a project\n"
|
|
|
|
" --dir <path> use given dir as BOINC home\n"
|
|
|
|
" --exit_after_app_start N exit N seconds after an app starts\n"
|
2009-02-18 19:47:02 +00:00
|
|
|
" --exit_after_finish exit right after finishing a job\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --exit_before_start exit right before starting a job\n"
|
|
|
|
" --exit_before_upload exit right before starting an upload \n"
|
|
|
|
" --exit_when_idle exit when there are no results\n"
|
2010-06-02 17:50:47 +00:00
|
|
|
" --fetch_minimal_work fetch only 1 job per device\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --file_xfer_giveup_period N give up on file xfers after N sec\n"
|
|
|
|
" --gui_rpc_port <port> port for GUI RPCs\n"
|
2014-01-31 06:57:44 +00:00
|
|
|
" --gui_rpc_unix_domain use Unix domain for GUI RPCs\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --help show options\n"
|
|
|
|
" --insecure disable app sandboxing (Unix)\n"
|
2013-03-12 05:38:29 +00:00
|
|
|
#ifdef __APPLE__
|
2008-10-23 21:56:08 +00:00
|
|
|
" --launched_by_manager client was launched by Manager\n"
|
2013-03-12 05:38:29 +00:00
|
|
|
#endif
|
2009-02-18 19:47:02 +00:00
|
|
|
" --master_fetch_interval N limiting period of master retry\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --master_fetch_period N reload master URL after N RPC failures\n"
|
|
|
|
" --master_fetch_retry_cap N exponential backoff limit\n"
|
2010-10-30 23:22:22 +00:00
|
|
|
" --no_gpus don't check for GPUs\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --no_gui_rpc don't allow GUI RPC, don't make socket\n"
|
2010-09-27 20:34:47 +00:00
|
|
|
" --no_info_fetch don't fetch project list or client version info\n"
|
2009-03-20 18:56:54 +00:00
|
|
|
" --no_priority_change run apps at same priority as client\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --pers_giveup N giveup time for persistent file xfer\n"
|
|
|
|
" --pers_retry_delay_max N max for file xfer exponential backoff\n"
|
2009-02-18 19:47:02 +00:00
|
|
|
" --pers_retry_delay_min N min for file xfer exponential backoff\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --redirectio redirect stdout and stderr to log files\n"
|
2009-02-18 19:47:02 +00:00
|
|
|
" --reset_project <URL> reset (clear) a project\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --retry_cap N exponential backoff limit\n"
|
|
|
|
" --run_cpu_benchmarks run the CPU benchmarks\n"
|
|
|
|
" --run_by_updater set by updater\n"
|
2013-03-12 05:38:29 +00:00
|
|
|
#ifdef __APPLE__
|
2008-10-23 21:56:08 +00:00
|
|
|
" --saver client was launched by screensaver\n"
|
2013-03-12 05:38:29 +00:00
|
|
|
#endif
|
2008-10-23 21:56:08 +00:00
|
|
|
" --sched_retry_delay_max N max for RPC exponential backoff\n"
|
2009-02-18 19:47:02 +00:00
|
|
|
" --sched_retry_delay_min N min for RPC exponential backoff\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --show_projects show attached projects\n"
|
|
|
|
" --skip_cpu_benchmarks don't run CPU benchmarks\n"
|
|
|
|
" --start_delay X delay starting apps for X secs\n"
|
2013-02-28 18:09:53 +00:00
|
|
|
" --suppress_net_info don't send network addrs to server\n"
|
2009-10-07 18:42:51 +00:00
|
|
|
" --unsigned_apps_ok allow unsigned apps (for testing)\n"
|
2008-10-23 21:56:08 +00:00
|
|
|
" --update_prefs <URL> contact a project to update preferences\n"
|
|
|
|
" --version show version info\n"
|
2005-07-23 08:10:39 +00:00
|
|
|
,
|
2007-06-20 16:27:27 +00:00
|
|
|
prog, prog, prog
|
2003-10-19 01:48:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the command line arguments passed to the client
|
|
|
|
// NOTE: init() has not been called at this point
|
|
|
|
// (i.e. client_state.xml has not been parsed)
|
2005-03-23 06:26:19 +00:00
|
|
|
// So just record the args here.
|
|
|
|
// The actions get done in do_cmdline_actions()
|
2003-10-19 01:48:32 +00:00
|
|
|
//
|
2007-02-12 23:53:16 +00:00
|
|
|
// Check for both -X (deprecated) and --X
|
|
|
|
//
|
2004-01-19 20:53:40 +00:00
|
|
|
#define ARGX2(s1,s2) (!strcmp(argv[i], s1)||!strcmp(argv[i], s2))
|
|
|
|
#define ARG(S) ARGX2("-"#S, "--"#S)
|
|
|
|
|
2003-10-19 01:48:32 +00:00
|
|
|
void CLIENT_STATE::parse_cmdline(int argc, char** argv) {
|
|
|
|
int i;
|
|
|
|
bool show_options = false;
|
|
|
|
|
2013-07-09 12:55:53 +00:00
|
|
|
// NOTE: if you change or add anything, make the same change
|
2009-02-18 19:47:02 +00:00
|
|
|
// in show_options() (above) and in doc/client.php
|
|
|
|
|
2003-10-19 01:48:32 +00:00
|
|
|
for (i=1; i<argc; i++) {
|
2009-02-18 19:47:02 +00:00
|
|
|
if (0) {
|
|
|
|
} else if (ARG(abort_jobs_on_exit)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.abort_jobs_on_exit = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(allow_multiple_clients)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.allow_multiple_clients = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(allow_remote_gui_rpc)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.allow_remote_gui_rpc = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(attach_project)) {
|
|
|
|
if (i >= argc-2) {
|
|
|
|
show_options = true;
|
|
|
|
} else {
|
|
|
|
safe_strcpy(attach_project_url, argv[++i]);
|
|
|
|
safe_strcpy(attach_project_auth, argv[++i]);
|
|
|
|
}
|
2004-06-15 00:46:59 +00:00
|
|
|
} else if (ARG(check_all_logins)) {
|
|
|
|
check_all_logins = true;
|
2005-01-07 20:47:40 +00:00
|
|
|
} else if (ARG(daemon)) {
|
|
|
|
executing_as_daemon = true;
|
2013-05-20 21:51:33 +00:00
|
|
|
} else if (ARG(detach_phase_two) || ARG(detach) || ARG(detach_console)) {
|
2009-02-18 19:47:02 +00:00
|
|
|
detach_console = true;
|
|
|
|
} else if (ARG(detach_project)) {
|
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else safe_strcpy(detach_project_url, argv[++i]);
|
|
|
|
} else if (ARG(dir)) {
|
|
|
|
if (i == argc-1) {
|
|
|
|
show_options = true;
|
|
|
|
} else {
|
2019-11-25 23:28:15 +00:00
|
|
|
if (chdir(argv[++i])) {
|
|
|
|
perror("chdir");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
cmdline_dir = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
}
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(exit_after_app_start)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else exit_after_app_start_secs = atoi(argv[++i]);
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(exit_after_finish)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.exit_after_finish = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(exit_before_start)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.exit_before_start = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(exit_before_upload)) {
|
|
|
|
exit_before_upload = true;
|
|
|
|
} else if (ARG(exit_when_idle)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.exit_when_idle = true;
|
|
|
|
cc_config.report_results_immediately = true;
|
2010-06-02 17:50:47 +00:00
|
|
|
} else if (ARG(fetch_minimal_work)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.fetch_minimal_work = true;
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(file_xfer_giveup_period)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else file_xfer_giveup_period = atoi(argv[++i]);
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(gui_rpc_port)) {
|
2011-02-08 01:06:18 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else cmdline_gui_rpc_port = atoi(argv[++i]);
|
2014-01-31 06:57:44 +00:00
|
|
|
} else if (ARG(gui_rpc_unix_domain)) {
|
|
|
|
gui_rpc_unix_domain = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(help)) {
|
|
|
|
print_options(argv[0]);
|
|
|
|
exit(0);
|
|
|
|
} else if (ARG(insecure)) {
|
|
|
|
g_use_sandbox = false;
|
|
|
|
} else if (ARG(launched_by_manager)) {
|
|
|
|
launched_by_manager = true;
|
|
|
|
} else if (ARG(master_fetch_interval)) {
|
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else master_fetch_interval = atoi(argv[++i]);
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(master_fetch_period)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else master_fetch_period = atoi(argv[++i]);
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(master_fetch_retry_cap)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else master_fetch_retry_cap = atoi(argv[++i]);
|
2009-11-09 20:00:45 +00:00
|
|
|
} else if (ARG(no_gpus)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.no_gpus = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(no_gui_rpc)) {
|
|
|
|
no_gui_rpc = true;
|
2010-09-27 20:34:47 +00:00
|
|
|
} else if (ARG(no_info_fetch)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.no_info_fetch = true;
|
2009-03-20 18:56:54 +00:00
|
|
|
} else if (ARG(no_priority_change)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.no_priority_change = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(pers_giveup)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
else pers_giveup = atoi(argv[++i]);
|
|
|
|
} else if (ARG(pers_retry_delay_max)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
else pers_retry_delay_max = atoi(argv[++i]);
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(pers_retry_delay_min)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else pers_retry_delay_min = atoi(argv[++i]);
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (!strncmp(argv[i], "-psn_", strlen("-psn_"))) {
|
|
|
|
// ignore -psn argument on Mac OS X
|
|
|
|
} else if (ARG(redirectio)) {
|
|
|
|
redirect_io = true;
|
|
|
|
} else if (ARG(reset_project)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
else safe_strcpy(reset_project_url, argv[++i]);
|
|
|
|
} else if (ARG(retry_cap)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
else retry_cap = atoi(argv[++i]);
|
|
|
|
} else if (ARG(run_by_updater)) {
|
|
|
|
run_by_updater = true;
|
|
|
|
} else if (ARG(run_cpu_benchmarks)) {
|
|
|
|
run_cpu_benchmarks = true;
|
|
|
|
} else if (ARG(saver)) {
|
|
|
|
started_by_screensaver = true;
|
|
|
|
} else if (ARG(sched_retry_delay_max)) {
|
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else sched_retry_delay_max = atoi(argv[++i]);
|
|
|
|
} else if (ARG(sched_retry_delay_min)) {
|
|
|
|
if (i == argc-1) show_options = true;
|
|
|
|
else sched_retry_delay_min = atoi(argv[++i]);
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(show_projects)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
show_projects = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(skip_cpu_benchmarks)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.skip_cpu_benchmarks = true;
|
2009-02-18 19:47:02 +00:00
|
|
|
} else if (ARG(start_delay)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
2014-05-08 07:51:18 +00:00
|
|
|
else cc_config.start_delay = atof(argv[++i]);
|
2013-02-28 18:09:53 +00:00
|
|
|
} else if (ARG(suppress_net_info)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.suppress_net_info = true;
|
2009-10-07 18:42:51 +00:00
|
|
|
} else if (ARG(unsigned_apps_ok)) {
|
2014-05-08 07:51:18 +00:00
|
|
|
cc_config.unsigned_apps_ok = true;
|
|
|
|
cc_config.dont_check_file_sizes = true;
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(update_prefs)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
if (i == argc-1) show_options = true;
|
2007-09-24 22:57:00 +00:00
|
|
|
else safe_strcpy(update_prefs_url, argv[++i]);
|
2003-11-23 00:08:49 +00:00
|
|
|
} else if (ARG(version)) {
|
2004-07-13 15:07:42 +00:00
|
|
|
printf(BOINC_VERSION_STRING " " HOSTTYPE "\n");
|
2003-10-19 01:48:32 +00:00
|
|
|
exit(0);
|
2011-11-10 22:53:12 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// workaround for bug in XCode 4.2: accept but ignore
|
|
|
|
// argument -NSDocumentRevisionsDebugMode=YES
|
|
|
|
} else if (ARG(NSDocumentRevisionsDebugMode)) {
|
|
|
|
++i;
|
|
|
|
#endif
|
2013-07-09 12:55:53 +00:00
|
|
|
// detect_gpus is for internal use only - do not
|
|
|
|
// add it to show_options() or doc/client.php
|
|
|
|
// This statement just avoids Unknown option warning
|
|
|
|
} else if (ARG(detect_gpus)) {
|
2003-10-19 01:48:32 +00:00
|
|
|
} else {
|
|
|
|
printf("Unknown option: %s\n", argv[i]);
|
|
|
|
show_options = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (show_options) {
|
|
|
|
print_options(argv[0]);
|
2003-11-23 00:08:49 +00:00
|
|
|
exit(1);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-19 20:53:40 +00:00
|
|
|
#undef ARG
|
|
|
|
#undef ARGX2
|
|
|
|
|
2003-10-19 01:48:32 +00:00
|
|
|
void CLIENT_STATE::parse_env_vars() {
|
2009-08-07 18:16:21 +00:00
|
|
|
char *p;
|
2009-11-07 06:00:08 +00:00
|
|
|
PARSED_URL purl;
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2004-07-13 18:35:47 +00:00
|
|
|
p = getenv("HTTP_PROXY");
|
|
|
|
if (p && strlen(p) > 0) {
|
2009-11-07 06:00:08 +00:00
|
|
|
parse_url(p, purl);
|
|
|
|
switch (purl.protocol) {
|
|
|
|
case URL_PROTOCOL_HTTP:
|
|
|
|
case URL_PROTOCOL_HTTPS:
|
2009-12-05 00:51:05 +00:00
|
|
|
env_var_proxy_info.present = true;
|
|
|
|
env_var_proxy_info.use_http_proxy = true;
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(env_var_proxy_info.http_user_name, purl.user);
|
|
|
|
safe_strcpy(env_var_proxy_info.http_user_passwd, purl.passwd);
|
|
|
|
safe_strcpy(env_var_proxy_info.http_server_name, purl.host);
|
2009-12-05 00:51:05 +00:00
|
|
|
env_var_proxy_info.http_server_port = purl.port;
|
2009-11-07 06:00:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-10-18 20:09:51 +00:00
|
|
|
msg_printf_notice(0, false,
|
2017-11-15 23:23:53 +00:00
|
|
|
"https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=proxy_env",
|
2010-06-08 23:37:44 +00:00
|
|
|
_("The HTTP_PROXY environment variable must specify an HTTP proxy")
|
2009-11-07 06:00:08 +00:00
|
|
|
);
|
|
|
|
}
|
2004-07-13 18:35:47 +00:00
|
|
|
}
|
|
|
|
p = getenv("HTTP_USER_NAME");
|
|
|
|
if (p) {
|
2009-12-05 00:51:05 +00:00
|
|
|
env_var_proxy_info.use_http_auth = true;
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(env_var_proxy_info.http_user_name, p);
|
2004-07-13 18:35:47 +00:00
|
|
|
p = getenv("HTTP_USER_PASSWD");
|
|
|
|
if (p) {
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(env_var_proxy_info.http_user_passwd, p);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-06 23:09:13 +00:00
|
|
|
p = getenv("SOCKS_SERVER");
|
|
|
|
if (!p) p = getenv("SOCKS5_SERVER");
|
2006-11-20 17:12:55 +00:00
|
|
|
if (p && strlen(p)) {
|
2009-11-07 06:00:08 +00:00
|
|
|
parse_url(p, purl);
|
2009-12-05 00:51:05 +00:00
|
|
|
env_var_proxy_info.present = true;
|
|
|
|
env_var_proxy_info.use_socks_proxy = true;
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(env_var_proxy_info.socks5_user_name, purl.user);
|
|
|
|
safe_strcpy(env_var_proxy_info.socks5_user_passwd, purl.passwd);
|
|
|
|
safe_strcpy(env_var_proxy_info.socks_server_name, purl.host);
|
2009-12-05 00:51:05 +00:00
|
|
|
env_var_proxy_info.socks_server_port = purl.port;
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 23:09:13 +00:00
|
|
|
p = getenv("SOCKS5_USER");
|
|
|
|
if (!p) p = getenv("SOCKS_USER");
|
2006-11-20 17:12:55 +00:00
|
|
|
if (p) {
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(env_var_proxy_info.socks5_user_name, p);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 23:09:13 +00:00
|
|
|
p = getenv("SOCKS5_PASSWD");
|
2006-11-20 17:12:55 +00:00
|
|
|
if (p) {
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(env_var_proxy_info.socks5_user_passwd, p);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLIENT_STATE::do_cmdline_actions() {
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (show_projects) {
|
|
|
|
printf("projects:\n");
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
msg_printf(NULL, MSG_INFO, "URL: %s name: %s\n",
|
|
|
|
projects[i]->master_url, projects[i]->project_name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(detach_project_url)) {
|
2013-05-28 06:08:02 +00:00
|
|
|
canonicalize_master_url(detach_project_url, sizeof(detach_project_url));
|
2003-10-19 01:48:32 +00:00
|
|
|
PROJECT* project = lookup_project(detach_project_url);
|
|
|
|
if (project) {
|
2007-07-31 03:25:59 +00:00
|
|
|
// do this before detaching - it frees the project
|
|
|
|
//
|
|
|
|
msg_printf(project, MSG_INFO, "detaching from %s\n", detach_project_url);
|
2003-10-19 01:48:32 +00:00
|
|
|
detach_project(project);
|
|
|
|
} else {
|
2010-06-08 23:37:44 +00:00
|
|
|
msg_printf(NULL, MSG_INFO, "project %s not found\n", detach_project_url);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(reset_project_url)) {
|
2013-05-28 06:08:02 +00:00
|
|
|
canonicalize_master_url(reset_project_url, sizeof(reset_project_url));
|
2003-10-19 01:48:32 +00:00
|
|
|
PROJECT* project = lookup_project(reset_project_url);
|
|
|
|
if (project) {
|
2007-12-03 17:46:07 +00:00
|
|
|
reset_project(project, false);
|
2003-10-19 01:48:32 +00:00
|
|
|
msg_printf(project, MSG_INFO, "Project %s has been reset", reset_project_url);
|
|
|
|
} else {
|
2010-06-08 23:37:44 +00:00
|
|
|
msg_printf(NULL, MSG_INFO, "project %s not found\n", reset_project_url);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(update_prefs_url)) {
|
2013-05-28 06:08:02 +00:00
|
|
|
canonicalize_master_url(update_prefs_url, sizeof(update_prefs_url));
|
2003-10-19 01:48:32 +00:00
|
|
|
PROJECT* project = lookup_project(update_prefs_url);
|
|
|
|
if (project) {
|
2006-09-01 22:21:20 +00:00
|
|
|
project->sched_rpc_pending = RPC_REASON_USER_REQ;
|
2003-10-19 01:48:32 +00:00
|
|
|
} else {
|
2010-06-08 23:37:44 +00:00
|
|
|
msg_printf(NULL, MSG_INFO, "project %s not found\n", update_prefs_url);
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-23 06:26:19 +00:00
|
|
|
|
|
|
|
if (strlen(attach_project_url)) {
|
2013-05-28 06:08:02 +00:00
|
|
|
canonicalize_master_url(attach_project_url, sizeof(attach_project_url));
|
2006-12-26 00:37:25 +00:00
|
|
|
add_project(attach_project_url, attach_project_auth, "", false);
|
2005-03-23 06:26:19 +00:00
|
|
|
}
|
2003-10-19 01:48:32 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|