boinc_cmd looks for password in file

svn path=/trunk/boinc/; revision=8747
This commit is contained in:
David Anderson 2005-10-26 05:43:36 +00:00
parent fb0a3565e0
commit 2d5bb1fbed
3 changed files with 37 additions and 8 deletions

View File

@ -13362,4 +13362,11 @@ Charlie 25 Oct 2005
client/
gui_rpc_server.C
David 25 Oct 2005
- "boinc_cmd" looks for a password in gui_rpc_auth.cfg
client/
acct_setup.C
lib/
boinc_cmd.C

View File

@ -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;

View File

@ -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;