diff --git a/core/routes.php b/core/routes.php index 7408858b107cb79c8c705d02d81fd5bad59f6895..2527816b662c13e65baa950e2dde498162aaea28 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 66b8cf378bd18d28995ba4e8dc62046b4f053410..f16385466cb8fcc0bf4ddcc4c8a0c65fd2bea1cc 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 5bfdb0b7c0a568f893d864b3e31c51f0a0580733..84e9b0c2eebf5db4cf819979ec8831fe44265aa1 100644 --- a/lib/base.php +++ b/lib/base.php @@ -548,6 +548,7 @@ class OC { require_once 'core/setup.php'; 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 4dd190b99fb159b858c28e79f1b52d6fd8ca2897..f342142c95794f6085d1929598cb288fa3fe0f9e 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 <a href=\'%s\'>installation guides</a>.', '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(); + } + } } diff --git a/lib/util.php b/lib/util.php index 9ce974619bcee2a496e0785f63bd5cf9cc90020a..49d914e5fbd2a9f64e553df8ebf6174c308e76be 100755 --- a/lib/util.php +++ b/lib/util.php @@ -516,6 +516,40 @@ 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() { + if (!function_exists('curl_init')) { + return; + } + + $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. diff --git a/settings/admin.php b/settings/admin.php index 7cca716515390fc9cda2bccf151ed4329deca2e9..c7848803095e2e794a90a9e9c5822e9859996677 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('has_fileinfo', OC_Util::fileInfoLoaded()); $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 9a9a691dcbfa5569f6331d21910054bbc81eac9b..fac8a6898833826e61e70964b31fbf82f9805b22 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -22,6 +22,21 @@ if (!$_['htaccessworking']) { <?php } +// is WebDAV working ? +if (!$_['isWebDavWorking']) { + ?> +<fieldset class="personalblock"> + <legend><strong><?php echo $l->t('Setup Warning');?></strong></legend> + + <span class="securitywarning"> + <?php echo $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); ?> + <?php echo $l->t('Please double check the <a href=\'%s\'>installation guides</a>.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); ?> + </span> + +</fieldset> +<?php +} + // if module fileinfo available? if (!$_['has_fileinfo']) { ?> @@ -36,6 +51,7 @@ if (!$_['has_fileinfo']) { <?php } +// is locale working ? if (!$_['islocaleworking']) { ?> <fieldset class="personalblock">