From 5c933779ee5c53cf063a33c4d6a10ba2b644a26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 27 Mar 2017 15:27:53 +0200 Subject: [PATCH 1/2] No longer show the version number in the public --- config/config.sample.php | 6 ++++++ lib/private/OCS/CoreCapabilities.php | 2 ++ lib/public/Util.php | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index 026d5ab97cce..3cc4c02ee6b6 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -79,6 +79,12 @@ */ 'version' => '', +/** + * While hardening an ownCloud instance hiding the version information in status.php + * can be a legitimate step. Please consult the documentation before enabling this. + */ +'version.hide' => false, + /** * Identifies the database used with this installation. See also config option * ``supportedDatabases`` diff --git a/lib/private/OCS/CoreCapabilities.php b/lib/private/OCS/CoreCapabilities.php index 474e099046cc..75ddf8ece7dd 100644 --- a/lib/private/OCS/CoreCapabilities.php +++ b/lib/private/OCS/CoreCapabilities.php @@ -24,6 +24,7 @@ use OCP\Capabilities\ICapability; use OCP\IConfig; +use OCP\Util; /** * Class Capabilities @@ -52,6 +53,7 @@ public function getCapabilities() { 'core' => [ 'pollinterval' => $this->config->getSystemValue('pollinterval', 60), 'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'), + 'status' => Util::getStatusInfo(), ] ]; } diff --git a/lib/public/Util.php b/lib/public/Util.php index 22430dab5e48..92d4a84bad7f 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -722,10 +722,18 @@ public static function getStatusInfo() { 'installed'=> $installed ? 'true' : 'false', 'maintenance' => $maintenance ? 'true' : 'false', 'needsDbUpgrade' => self::needUpgrade() ? 'true' : 'false', - 'version' => implode('.', self::getVersion()), - 'versionstring' => \OC_Util::getVersionString(), - 'edition' => \OC_Util::getEditionString(), - 'productname' => $defaults->getName()]; + 'version' => '', + 'versionstring' => '', + 'edition' => '', + 'productname' => '']; + + if ((bool) $systemConfig->getValue('version.hide', false) === false) { + $values['version'] = implode('.', self::getVersion()); + $values['versionstring'] = \OC_Util::getVersionString(); + $values['edition'] = \OC_Util::getEditionString(); + $values['productname'] = $defaults->getName(); + } + return $values; } } From 4abd357e80cdd9dc848d27279888a1da69a9064e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 12 Apr 2017 16:01:21 +0200 Subject: [PATCH 2/2] fix print out of version in capabilities --- lib/private/OCS/CoreCapabilities.php | 2 +- lib/public/Util.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/private/OCS/CoreCapabilities.php b/lib/private/OCS/CoreCapabilities.php index 75ddf8ece7dd..dcfe13b73a57 100644 --- a/lib/private/OCS/CoreCapabilities.php +++ b/lib/private/OCS/CoreCapabilities.php @@ -53,7 +53,7 @@ public function getCapabilities() { 'core' => [ 'pollinterval' => $this->config->getSystemValue('pollinterval', 60), 'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'), - 'status' => Util::getStatusInfo(), + 'status' => Util::getStatusInfo(true), ] ]; } diff --git a/lib/public/Util.php b/lib/public/Util.php index 92d4a84bad7f..6d29e274901a 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -707,10 +707,11 @@ public static function needUpgrade() { /** * Collects all status infos. * - * @return array + * @param bool $includeVersion + * @return array * @since 10.0 */ - public static function getStatusInfo() { + public static function getStatusInfo($includeVersion = false) { $systemConfig = \OC::$server->getSystemConfig(); $installed = (bool) $systemConfig->getValue('installed', false); @@ -727,7 +728,7 @@ public static function getStatusInfo() { 'edition' => '', 'productname' => '']; - if ((bool) $systemConfig->getValue('version.hide', false) === false) { + if ($includeVersion || (bool) $systemConfig->getValue('version.hide', false) === false) { $values['version'] = implode('.', self::getVersion()); $values['versionstring'] = \OC_Util::getVersionString(); $values['edition'] = \OC_Util::getEditionString();