diff --git a/checkin_notes b/checkin_notes index 67471fb364..7b7ea58da6 100755 --- a/checkin_notes +++ b/checkin_notes @@ -9238,9 +9238,11 @@ Karl 2004-01-15 base64.h Karl 2004-01-15 + - renamed user_name to db_user + - applied changes by Daniel Sumers Myers - setup script creates log_ - - add support for field in config.XML + - add support for field in config.XML in C, python, php - missing default project.inc.sample fields db/ diff --git a/db/db_base.C b/db/db_base.C index 226d274206..3cd4546a78 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -12,10 +12,10 @@ DB_CONN::DB_CONN() { mysql = 0; } -int DB_CONN::open(char* db_name, char* db_host, char* dbpassword) { +int DB_CONN::open(char* db_name, char* db_host, char* db_user, char* dbpassword) { mysql = mysql_init(0); if (!mysql) return ERR_DB_CANT_INIT; - mysql = mysql_real_connect(mysql, db_host, 0, dbpassword, db_name, 0, 0, 0); + mysql = mysql_real_connect(mysql, db_host, db_user, dbpassword, db_name, 0, 0, 0); if (mysql == 0) return ERR_DB_CANT_CONNECT; return 0; } diff --git a/db/db_base.h b/db/db_base.h index 70ab02cfe5..77d35b502e 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -2,18 +2,18 @@ // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt -// +// // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is the Berkeley Open Infrastructure for Network Computing. -// +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 -// University of California at Berkeley. All Rights Reserved. -// +// University of California at Berkeley. All Rights Reserved. +// // Contributor(s): // @@ -32,7 +32,7 @@ struct CURSOR { class DB_CONN { public: DB_CONN(); - int open(char* name, char* host, char* passwd); + int open(char* name, char* host, char* user, char* passwd); int do_query(char*); void close(); int insert_id(); diff --git a/html/ops/db_ops.inc b/html/ops/db_ops.inc index 285abd44f8..417ea96ecd 100644 --- a/html/ops/db_ops.inc +++ b/html/ops/db_ops.inc @@ -1,14 +1,18 @@ "); + $pass = parse_config(""); + $retval = mysql_connect("localhost", $user, $pass); if (!$retval) { echo "Unable to connect to database - please try again later"; + echo mysql_error(); exit(); } $db_name = parse_config(""); if(!mysql_select_db($db_name)) { echo "Unable to select database '$db_name' - please try again later"; + echo mysql_error(); exit(); } diff --git a/html/user/db.inc b/html/user/db.inc index cd64e8775c..38bd0fc21d 100644 --- a/html/user/db.inc +++ b/html/user/db.inc @@ -10,14 +10,18 @@ function db_init($pathMod='') { echo "Project is shut down for maintenance - please try again later\n"; exit(); } - $retval = mysql_pconnect(); + $user = parse_config("", $pathMod); + $pass = parse_config("", $pathMod); + $retval = mysql_pconnect("localhost", $user, $pass); if (!$retval) { echo "Unable to connect to database - please try again later"; + echo mysql_error(); exit(); } $db_name = parse_config("", $pathMod); if(!mysql_select_db($db_name)) { echo "Unable to select database - please try again later"; + echo mysql_error(); exit(); } diff --git a/html/user/project.inc.sample b/html/user/project.inc.sample index 7d3f101c58..75f478e9c8 100644 --- a/html/user/project.inc.sample +++ b/html/user/project.inc.sample @@ -13,6 +13,7 @@ define('IMAGE_PATH', 'images/user_profile/'); define('PROFILE_PATH', 'user_profile/'); define('LANGUAGE_FILE', 'languages.txt'); define('STYLESHEET', 'white.css'); +define('COPYRIGHT_HOLDER', 'Test Group'); function project_intro() { echo" diff --git a/lib/Makefile.am b/lib/Makefile.am index 97257e6abe..28cac171a0 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -33,7 +33,8 @@ libboinc_a_SOURCES = \ xml_util.h \ shmem.h \ synch.h \ - util.h + util.h \ + base64.h # libboinc_graphics_a_SOURCES = \ # ../api/graphics_api.C \ diff --git a/lib/base64.C b/lib/base64.C index 418e4e9d93..c0d0a1c5dc 100644 --- a/lib/base64.C +++ b/lib/base64.C @@ -1,6 +1,6 @@ // Copyright 2003 Regents of the University of California -#include "parse.h" +#include "base64.h" // Table of characters coding the 64 values. static char base64_value_to_char[64] = diff --git a/lib/base64.h b/lib/base64.h index 486f1b6ee9..fece9ea3a1 100644 --- a/lib/base64.h +++ b/lib/base64.h @@ -1,3 +1,31 @@ +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + +#ifndef h_BASE64 +#define h_BASE64 + +#include +#include +#include + +using std::string; + class InvalidBase64Exception { }; @@ -9,3 +37,5 @@ inline string r_base64_decode (string const& from) throw(InvalidBase64Exception) return r_base64_decode(from.c_str(), from.length()); } + +#endif diff --git a/py/Boinc/setup_project.py b/py/Boinc/setup_project.py index 2ee5b4afa4..5375a186bc 100644 --- a/py/Boinc/setup_project.py +++ b/py/Boinc/setup_project.py @@ -326,12 +326,19 @@ class Project: def keydir(self, *dirs): return apply(os.path.join,(self.config.config.key_dir,)+dirs) + def logdir(self, *dirs): + return apply(os.path.join,("log_"+socket.getfqdn(),)+dirs) + def create_keys(self): if not os.path.exists(self.keydir()): os.mkdir(self.keydir()) _gen_key(self.keydir('upload')) _gen_key(self.keydir('code_sign')) + def create_logdir(self): + print "logdir = ", self.logdir(); + os.mkdir(self.logdir()); + def query_create_keys(self): return query_yesno("Keys don't exist in %s; generate them?"%self.keydir()) @@ -351,12 +358,12 @@ class Project: # TODO: that is a security risk; don't do this in the future - write # req/reply files somewhere else map(lambda dir: os.mkdir(self.dir(dir)), - [ '', 'cgi-bin', 'bin', 'upload', 'download', 'apps', 'log', + [ '', 'cgi-bin', 'bin', 'upload', 'download', 'apps', self.logdir(), 'html_ops', 'html_user', 'html_user/project_specific', 'html_user/class', 'html_user/include' ]) map(lambda dir: os.chmod(self.dir(dir), 0777), - [ 'cgi-bin', 'upload', 'log' ]) + [ 'cgi-bin', 'upload', self.logdir() ]) if not self.keys_exist(): if self.query_create_keys(): @@ -366,6 +373,9 @@ class Project: # copy the user and administrative PHP files to the project dir, verbose_echo(1, "Setting up server files: copying files") + # Create the project log directory +# self.create_logdir() + install_boinc_files(self.dir()) install_glob(srcdir('html_user/*.txt'), self.dir('html_user/')) diff --git a/sched/assimilator.C b/sched/assimilator.C index 2c064da405..130faf59bd 100644 --- a/sched/assimilator.C +++ b/sched/assimilator.C @@ -116,7 +116,7 @@ int main(int argc, char** argv) { // write_pid_file(PIDFILE); log_messages.printf(SchedMessages::NORMAL, "Starting\n"); - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't open DB\n"); exit(1); diff --git a/sched/db_dump.C b/sched/db_dump.C index 2483249de2..b10047d36d 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -597,7 +597,7 @@ int main(int argc, char** argv) { log_messages.printf(SchedMessages::NORMAL, "Can't parse config file\n"); exit(1); } - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::NORMAL, "Can't open DB\n"); exit(1); diff --git a/sched/feeder.C b/sched/feeder.C index e851ec0c36..46ba9344fd 100644 --- a/sched/feeder.C +++ b/sched/feeder.C @@ -383,7 +383,7 @@ int main(int argc, char** argv) { atexit(cleanup_shmem); install_stop_signal_handler(); - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "boinc_db.open: %d; %s\n", retval, boinc_db.error_string()); exit(1); diff --git a/sched/file_deleter.C b/sched/file_deleter.C index a1b80948af..49fd1633ce 100644 --- a/sched/file_deleter.C +++ b/sched/file_deleter.C @@ -168,7 +168,7 @@ int main(int argc, char** argv) { // write_pid_file(PIDFILE); log_messages.printf(SchedMessages::NORMAL, "Starting\n"); - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "can't open DB\n"); exit(1); diff --git a/sched/main.C b/sched/main.C index 6236971bfd..4f325c12c9 100644 --- a/sched/main.C +++ b/sched/main.C @@ -131,7 +131,7 @@ int main() { } } - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "can't open database\n"); project_stopped = true; diff --git a/sched/make_work.C b/sched/make_work.C index ddc75886a8..b4814f3632 100644 --- a/sched/make_work.C +++ b/sched/make_work.C @@ -133,7 +133,7 @@ void make_work() { exit(1); } - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "can't open db\n"); exit(1); diff --git a/sched/sched_config.C b/sched/sched_config.C index 962949f5f0..feff04dbb9 100644 --- a/sched/sched_config.C +++ b/sched/sched_config.C @@ -47,6 +47,7 @@ int SCHED_CONFIG::parse(istream& f) { memset(this, 0, sizeof(SCHED_CONFIG)); parse_str(buf.c_str(), "", db_name, sizeof(db_name)); + parse_str(buf.c_str(), "", db_user, sizeof(db_user)); parse_str(buf.c_str(), "", db_passwd, sizeof(db_passwd)); parse_str(buf.c_str(), "", db_host, sizeof(db_host)); parse_int(buf.c_str(), "", shmem_key); @@ -55,7 +56,6 @@ int SCHED_CONFIG::parse(istream& f) { parse_str(buf.c_str(), "", download_dir, sizeof(download_dir)); parse_str(buf.c_str(), "", upload_url, sizeof(upload_url)); parse_str(buf.c_str(), "", upload_dir, sizeof(upload_dir)); - parse_str(buf.c_str(), "", user_name, sizeof(user_name)); if (match_tag(buf.c_str(), "")) { one_result_per_user_per_wu = true; } diff --git a/sched/sched_config.h b/sched/sched_config.h index ff77bcd952..5424795321 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -28,6 +28,7 @@ using std::istream; class SCHED_CONFIG { public: char db_name[256]; + char db_user[256]; char db_passwd[256]; char db_host[256]; int shmem_key; @@ -36,7 +37,6 @@ public: char download_dir[256]; char upload_url[256]; char upload_dir[256]; - char user_name[256]; bool one_result_per_user_per_wu; int min_sendwork_interval; diff --git a/sched/transitioner.C b/sched/transitioner.C index c5d9a35e9d..afb7c7ec1f 100644 --- a/sched/transitioner.C +++ b/sched/transitioner.C @@ -356,7 +356,7 @@ bool do_pass() { void main_loop(bool one_pass) { int retval; - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "boinc_db.open: %d\n", retval); exit(1); diff --git a/sched/update_stats.C b/sched/update_stats.C index ed787884ab..865baf0867 100644 --- a/sched/update_stats.C +++ b/sched/update_stats.C @@ -172,7 +172,7 @@ int main(int argc, char** argv) { log_messages.printf(SchedMessages::CRITICAL, "Can't parse config file\n"); exit(1); } - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't open DB\n"); exit(1); diff --git a/sched/validate.C b/sched/validate.C index 575db45d9d..e8faee5284 100644 --- a/sched/validate.C +++ b/sched/validate.C @@ -336,7 +336,7 @@ int main_loop(bool one_pass) { bool did_something; char buf[256]; - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "boinc_db.open: %d\n", retval); exit(1); diff --git a/sched/wu_check.C b/sched/wu_check.C index 5a8476e397..4d80297752 100644 --- a/sched/wu_check.C +++ b/sched/wu_check.C @@ -88,7 +88,7 @@ int main(int argc, char** argv) { retval = config.parse_file(); if (retval) exit(1); - retval = boinc_db.open(config.db_name, config.db_host, config.db_passwd); + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); if (retval) { printf("boinc_db.open: %d\n", retval); exit(1); diff --git a/tools/create_work.C b/tools/create_work.C index a379a42ae4..2d1929fdf9 100644 --- a/tools/create_work.C +++ b/tools/create_work.C @@ -175,7 +175,7 @@ int main(int argc, char** argv) { #undef CHKARG #undef CHKARG_STR - if (boinc_db.open(db_name, "", db_passwd)) { + if (boinc_db.open(db_name, "", "", db_passwd)) { fprintf(stderr, "create_work: error opening database.\n" ); exit(0); }