From 1adcc5fd23004cd7253c87134c30d853e1b3b8b8 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Tue, 5 Feb 2013 23:33:44 +0100 Subject: basic WebDAV test in place now --- lib/base.php | 23 +++++++++++++++++++++++ lib/util.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/lib/base.php b/lib/base.php index 90e64f13af6..6dab980dd0e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -546,6 +546,29 @@ class OC { require_once 'core/setup.php'; exit(); } + + // post installation checks + if (!OC_Config::getValue("post-installation-checked", false)) { + // setup was successful -> webdav testing now + $request = OC_Request::getPathInfo(); + if(substr($request, -4) !== '.css' and substr($request, -3) !== '.js' and substr($request, -5) !== '.json') { + if (OC_Util::isWebDAVWorking()) { + OC_Config::setValue("post-installation-checked", true); + } else { + $l=OC_L10N::get('lib'); + + $error = $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); + $hint = $l->t('Please double check the installation guides.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); + + $tmpl = new OC_Template('', 'error', 'guest'); + $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false); + $tmpl->printPage(); + exit(); + } + } + } + + $request = OC_Request::getPathInfo(); if(substr($request, -3) !== '.js'){// we need these files during the upgrade self::checkMaintenanceMode(); diff --git a/lib/util.php b/lib/util.php index 4932be2d6cc..ae0900d7e84 100755 --- a/lib/util.php +++ b/lib/util.php @@ -514,6 +514,36 @@ class OC_Util { } } + /** + * we test if webDAV is working properly + * + * The basic assumption is that if the server returns 401/Not Authenticated for an unauthenticated PROPFIND + * the web server it self is setup properly. + * + * Why not an authenticated PROFIND and other verbs? + * - We don't have the password available + * - We have no idea about other auth methods implemented (e.g. OAuth with Bearer header) + * + */ + public static function isWebDAVWorking() { + $settings = array( + 'baseUri' => OC_Helper::linkToRemote('webdav'), + ); + + $client = new \Sabre_DAV_Client($settings); + + $return = true; + try { + // test PROPFIND + $client->propfind('', array('{DAV:}resourcetype')); + } catch(\Sabre_DAV_Exception_NotAuthenticated $e) { + $return = true; + } catch(\Exception $e) { + $return = false; + } + + return $return; + } /** * Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server. -- cgit v1.2.3 From 3582f7bd09f81e1aadb583ab0d36fb0cbc695514 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 6 Feb 2013 17:54:20 +0100 Subject: Execute the post setup check after finishing the setup --- core/routes.php | 4 ++++ core/setup.php | 2 +- lib/base.php | 22 ---------------------- lib/setup.php | 20 ++++++++++++++++++++ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/core/routes.php b/core/routes.php index 7408858b107..2527816b662 100644 --- a/core/routes.php +++ b/core/routes.php @@ -6,6 +6,10 @@ * See the COPYING-README file. */ +// Post installation check +$this->create('post_setup_check', '/post-setup-check') + ->action('OC_Setup', 'postSetupCheck'); + // Core ajax actions // Search $this->create('search_ajax_search', '/search/ajax/search.php') diff --git a/core/setup.php b/core/setup.php index 66b8cf378bd..f16385466cb 100644 --- a/core/setup.php +++ b/core/setup.php @@ -43,7 +43,7 @@ if(isset($_POST['install']) AND $_POST['install']=='true') { OC_Template::printGuestPage("", "installation", $options); } else { - header("Location: ".OC::$WEBROOT.'/'); + header( 'Location: '.OC_Helper::linkToRoute( 'post_setup_check' )); exit(); } } diff --git a/lib/base.php b/lib/base.php index 6dab980dd0e..e195d305d5c 100644 --- a/lib/base.php +++ b/lib/base.php @@ -547,28 +547,6 @@ class OC { exit(); } - // post installation checks - if (!OC_Config::getValue("post-installation-checked", false)) { - // setup was successful -> webdav testing now - $request = OC_Request::getPathInfo(); - if(substr($request, -4) !== '.css' and substr($request, -3) !== '.js' and substr($request, -5) !== '.json') { - if (OC_Util::isWebDAVWorking()) { - OC_Config::setValue("post-installation-checked", true); - } else { - $l=OC_L10N::get('lib'); - - $error = $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); - $hint = $l->t('Please double check the installation guides.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); - - $tmpl = new OC_Template('', 'error', 'guest'); - $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false); - $tmpl->printPage(); - exit(); - } - } - } - - $request = OC_Request::getPathInfo(); if(substr($request, -3) !== '.js'){// we need these files during the upgrade self::checkMaintenanceMode(); diff --git a/lib/setup.php b/lib/setup.php index 4dd190b99fb..f342142c957 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -610,4 +610,24 @@ class OC_Setup { file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content); file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/index.html', ''); } + + /** + * @brief Post installation checks + */ + public static function postSetupCheck($params) { + // setup was successful -> webdav testing now + if (OC_Util::isWebDAVWorking()) { + header("Location: ".OC::$WEBROOT.'/'); + } else { + $l=OC_L10N::get('lib'); + + $error = $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); + $hint = $l->t('Please double check the installation guides.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); + + $tmpl = new OC_Template('', 'error', 'guest'); + $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false); + $tmpl->printPage(); + exit(); + } + } } -- cgit v1.2.3 From 84f3c8b6cc1060203d807ee65545478ce34f93c4 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 7 Feb 2013 00:49:39 +0100 Subject: show webdav test results in admin section as well --- settings/admin.php | 1 + settings/templates/admin.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/settings/admin.php b/settings/admin.php index 4d9685ab920..e256c5fe357 100755 --- a/settings/admin.php +++ b/settings/admin.php @@ -31,6 +31,7 @@ $tmpl->assign('entriesremain', $entriesremain); $tmpl->assign('htaccessworking', $htaccessworking); $tmpl->assign('internetconnectionworking', OC_Util::isinternetconnectionworking()); $tmpl->assign('islocaleworking', OC_Util::issetlocaleworking()); +$tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking()); $tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax')); $tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes')); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 0097489743f..8c2b6148a66 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -22,6 +22,21 @@ if (!$_['htaccessworking']) { +
+ t('Setup Warning');?> + + + t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); ?> + t('Please double check the installation guides.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); ?> + + +
+ -- cgit v1.2.3 From ea42014ba4e7ad44a290f968b1a1439f78c1117c Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 8 Feb 2013 15:23:26 +0100 Subject: in case curl is not present we cannot test --- lib/util.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/util.php b/lib/util.php index 5f796e7565f..7e183041d54 100755 --- a/lib/util.php +++ b/lib/util.php @@ -528,6 +528,10 @@ class OC_Util { * */ public static function isWebDAVWorking() { + if (!function_exists('curl_init')) { + return; + } + $settings = array( 'baseUri' => OC_Helper::linkToRemote('webdav'), ); -- cgit v1.2.3