From 2d5bb1fbed1137c773795a1e1977417be799a87b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 26 Oct 2005 05:43:36 +0000 Subject: [PATCH] boinc_cmd looks for password in file svn path=/trunk/boinc/; revision=8747 --- checkin_notes | 9 ++++++++- client/acct_setup.C | 5 ++++- lib/boinc_cmd.C | 31 +++++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 17e05053a0..25ce1b2a37 100755 --- a/checkin_notes +++ b/checkin_notes @@ -13362,4 +13362,11 @@ Charlie 25 Oct 2005 client/ gui_rpc_server.C - \ No newline at end of file + +David 25 Oct 2005 + - "boinc_cmd" looks for a password in gui_rpc_auth.cfg + + client/ + acct_setup.C + lib/ + boinc_cmd.C diff --git a/client/acct_setup.C b/client/acct_setup.C index 605d62de59..d9f16a98d3 100644 --- a/client/acct_setup.C +++ b/client/acct_setup.C @@ -22,6 +22,7 @@ #include "parse.h" #include "filesys.h" #include "util.h" +#include "client_msgs.h" #include "acct_setup.h" @@ -80,7 +81,9 @@ void ACCOUNT_IN::parse(char* buf) { int GET_PROJECT_CONFIG_OP::do_rpc(string master_url) { int retval; string url = master_url + "get_project_config.php"; - printf("doing RPC to %s, file %s\n", url.c_str(), GET_PROJECT_CONFIG_FILENAME); + msg_printf(NULL, MSG_INFO, + "Fetching config info from %s", url.c_str() + ); retval = gstate.gui_http.do_rpc(this, url, GET_PROJECT_CONFIG_FILENAME); if (retval) { error_num = retval; diff --git a/lib/boinc_cmd.C b/lib/boinc_cmd.C index 9301b1fe07..ca074de1c5 100644 --- a/lib/boinc_cmd.C +++ b/lib/boinc_cmd.C @@ -43,7 +43,7 @@ using std::string; #include "version.h" void usage() { - fprintf(stderr, "\ + fprintf(stderr, "\ Usage: boinc_cmd [--host hostname] [--passwd passwd] command\n\ Give --help as a command for a list of commands\n\ "); @@ -51,13 +51,13 @@ Give --help as a command for a list of commands\n\ } void version(){ - printf("boinc_cmd, built from %s \n", PACKAGE_STRING ); - exit(0); + printf("boinc_cmd, built from %s \n", PACKAGE_STRING ); + exit(0); } void help() { - printf("\n\n\ - usage: boinc_cmd [--host hostname] [--passwd passwd] command\n\n\ + printf("\n\n\ + usage: boinc_cmd [--host hostname] [--passwd passwd] command\n\n\ Commands:\n\ --get_state show entire state\n\ --get_results show results\n\ @@ -120,14 +120,33 @@ char* next_arg(int argc, char** argv, int& i) { } +// If there's a password file, read it +// +void read_password_from_file(char* buf) { + FILE* f = fopen("gui_rpc_auth.cfg", "r"); + if (!f) return; + fgets(buf, 256, f); + int n = strlen(buf); + + // trim CR + // + if (n && buf[n-1]=='\n') { + buf[n-1] = 0; + } + fclose(f); +} int main(int argc, char** argv) { RPC_CLIENT rpc; int i; + char passwd_buf[256]; MESSAGES messages; int retval; char* hostname = NULL; - char* passwd = NULL; + char* passwd = passwd_buf; + + strcpy(passwd_buf, ""); + read_password_from_file(passwd_buf); #ifdef _WIN32 WSADATA wsdata;