From 7ef53b13b494090ff37e9a33d61873d4612a0b91 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Sat, 4 Oct 2014 09:27:11 +0200 Subject: [PATCH] MGR: Sync browser cookie lookups to David's commit last night. --- clientgui/browser.cpp | 147 +++++++++++++++++++++--------------------- clientgui/browser.h | 11 +++- doc/concierge.php | 2 +- 3 files changed, 83 insertions(+), 77 deletions(-) diff --git a/clientgui/browser.cpp b/clientgui/browser.cpp index c07bd79ed6..08f2477e3c 100644 --- a/clientgui/browser.cpp +++ b/clientgui/browser.cpp @@ -1229,79 +1229,6 @@ bool detect_cookie_ie(std::string& project_url, std::string& name, std::string& #endif -// -// walk through the various browsers looking up the -// various cookies that make up the simple account creation scheme. -// -// give preference to the default platform specific browers first before going -// to the platform independant browsers since most people don't switch from -// the default. -// -bool detect_simple_account_credentials( - std::string& action, std::string& project_name, std::string& project_url, std::string& authenticator, std::string& creation_time -) { - bool retval = false; - std::string strCookieServer("boinc.berkeley.edu"); - std::string strCookieAction("action"); - std::string strCookieProjectName("project_name"); - std::string strCookieProjectURL("project_url"); - std::string strCookieAuthenticator("authenticator"); - std::string strCookieCreationTime("creation_time"); - -#ifdef _WIN32 - if ( detect_cookie_ie(strCookieServer, strCookieAction, action) && - detect_cookie_ie(strCookieServer, strCookieProjectName, project_name) && - detect_cookie_ie(strCookieServer, strCookieProjectURL, project_url) && - detect_cookie_ie(strCookieServer, strCookieCreationTime, creation_time) - ){ - detect_cookie_ie(strCookieServer, strCookieAuthenticator, authenticator); - goto END; - } -#endif -#ifdef __APPLE__ - if ( detect_cookie_safari(strCookieServer, strCookieAction, action) && - detect_cookie_safari(strCookieServer, strCookieProjectName, project_name) && - detect_cookie_safari(strCookieServer, strCookieProjectURL, project_url) && - detect_cookie_safari(strCookieServer, strCookieCreationTime, creation_time) - ){ - detect_cookie_safari(strCookieServer, strCookieAuthenticator, authenticator); - goto END; - } -#endif - if ( detect_cookie_chrome(strCookieServer, strCookieAction, action) && - detect_cookie_chrome(strCookieServer, strCookieProjectName, project_name) && - detect_cookie_chrome(strCookieServer, strCookieProjectURL, project_url) && - detect_cookie_chrome(strCookieServer, strCookieCreationTime, creation_time) - ){ - detect_cookie_chrome(strCookieServer, strCookieAuthenticator, authenticator); - goto END; - } - if ( detect_cookie_firefox_3(strCookieServer, strCookieAction, action) && - detect_cookie_firefox_3(strCookieServer, strCookieProjectName, project_name) && - detect_cookie_firefox_3(strCookieServer, strCookieProjectURL, project_url) && - detect_cookie_firefox_3(strCookieServer, strCookieCreationTime, creation_time) - ){ - detect_cookie_firefox_3(strCookieServer, strCookieAuthenticator, authenticator); - goto END; - } - if ( detect_cookie_firefox_2(strCookieServer, strCookieAction, action) && - detect_cookie_firefox_2(strCookieServer, strCookieProjectName, project_name) && - detect_cookie_firefox_2(strCookieServer, strCookieProjectURL, project_url) && - detect_cookie_firefox_2(strCookieServer, strCookieCreationTime, creation_time) - ){ - detect_cookie_firefox_2(strCookieServer, strCookieAuthenticator, authenticator); - goto END; - } - -END: - if (!action.empty() && !project_name.empty() && !project_url.empty() && !creation_time.empty()) { - retval = true; - } - - return retval; -} - - // // walk through the various browsers looking up the // project cookies until the projects 'Setup' cookie is found. @@ -1335,6 +1262,80 @@ END: } +// +// walk through the various browsers looking up the +// various cookies that make up the simple account creation scheme. +// +// give preference to the default platform specific browers first before going +// to the platform independant browsers since most people don't switch from +// the default. +// +bool detect_simple_account_credentials( + std::string& project_name, std::string& project_url, std::string& authenticator, + std::string& project_institution, std::string& project_description +) { + bool retval = false; + std::string strCookieServer("http://boinc.berkeley.edu/"); + std::string strCookieProjectName("attach_project_name"); + std::string strCookieProjectURL("attach_master_url"); + std::string strCookieAuthenticator("attach_auth"); + std::string strCookieProjectInstitution("attach_project_inst"); + std::string strCookieProjectDescription("attach_project_desc"); + +#ifdef _WIN32 + if ( detect_cookie_ie(strCookieServer, strCookieProjectName, project_name) && + detect_cookie_ie(strCookieServer, strCookieProjectURL, project_url) + ){ + detect_cookie_ie(strCookieServer, strCookieAuthenticator, authenticator); + detect_cookie_ie(strCookieServer, strCookieProjectInstitution, project_institution); + detect_cookie_ie(strCookieServer, strCookieProjectDescription, project_description); + goto END; + } +#endif +#ifdef __APPLE__ + if ( detect_cookie_safari(strCookieServer, strCookieProjectName, project_name) && + detect_cookie_safari(strCookieServer, strCookieProjectURL, project_url) + ){ + detect_cookie_safari(strCookieServer, strCookieAuthenticator, authenticator); + detect_cookie_safari(strCookieServer, strCookieProjectInstitution, project_institution); + detect_cookie_safari(strCookieServer, strCookieProjectDescription, project_description); + goto END; + } +#endif + if ( detect_cookie_chrome(strCookieServer, strCookieProjectName, project_name) && + detect_cookie_chrome(strCookieServer, strCookieProjectURL, project_url) + ){ + detect_cookie_chrome(strCookieServer, strCookieAuthenticator, authenticator); + detect_cookie_chrome(strCookieServer, strCookieProjectInstitution, project_institution); + detect_cookie_chrome(strCookieServer, strCookieProjectDescription, project_description); + goto END; + } + if ( detect_cookie_firefox_3(strCookieServer, strCookieProjectName, project_name) && + detect_cookie_firefox_3(strCookieServer, strCookieProjectURL, project_url) + ){ + detect_cookie_firefox_3(strCookieServer, strCookieAuthenticator, authenticator); + detect_cookie_firefox_3(strCookieServer, strCookieProjectInstitution, project_institution); + detect_cookie_firefox_3(strCookieServer, strCookieProjectDescription, project_description); + goto END; + } + if ( detect_cookie_firefox_2(strCookieServer, strCookieProjectName, project_name) && + detect_cookie_firefox_2(strCookieServer, strCookieProjectURL, project_url) + ){ + detect_cookie_firefox_2(strCookieServer, strCookieAuthenticator, authenticator); + detect_cookie_firefox_2(strCookieServer, strCookieProjectInstitution, project_institution); + detect_cookie_firefox_2(strCookieServer, strCookieProjectDescription, project_description); + goto END; + } + +END: + if (!project_name.empty() && !project_url.empty()) { + retval = true; + } + + return retval; +} + + // // walk through the various browsers looking up the // account manager cookies until the account manager's 'Login' and 'Password_Hash' diff --git a/clientgui/browser.h b/clientgui/browser.h index 3427b9abfb..1658754b24 100644 --- a/clientgui/browser.h +++ b/clientgui/browser.h @@ -24,12 +24,17 @@ // cookie. // +bool detect_setup_authenticator(std::string& project_url, std::string& authenticator); + bool detect_simple_account_credentials( - std::string& action, std::string& project_name, std::string& project_url, std::string& authenticator, std::string& creation_time + std::string& project_name, std::string& project_url, std::string& authenticator, + std::string& project_institution, std::string& project_description ); -bool detect_setup_authenticator(std::string& project_url, std::string& authenticator); -bool detect_account_manager_credentials(std::string& project_url, std::string& login, std::string& password_hash, std::string& return_url); +bool detect_account_manager_credentials( + std::string& project_url, std::string& login, std::string& password_hash, + std::string& return_url +); bool is_authenticator_valid(const std::string authenticator); diff --git a/doc/concierge.php b/doc/concierge.php index b075a32418..75061854b3 100644 --- a/doc/concierge.php +++ b/doc/concierge.php @@ -66,7 +66,7 @@ function url_to_download() { } } else if (strstr($client_info, 'Linux') && strstr($client_info, 'Android')) { // Check for Android before Linux, - // since Android contains the Linux kernel and the + // since Android contains the Linux kernel and the // web browser user agent string list Linux too. return get_download_url('androidarm'); } else if (strstr($client_info, 'Linux')) {