]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove unneeded checks if it runs on a Windows machine
authorMorris Jobke <hey@morrisjobke.de>
Fri, 8 Jul 2016 13:55:17 +0000 (15:55 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Fri, 8 Jul 2016 13:55:17 +0000 (15:55 +0200)
* the setup check is still there

21 files changed:
apps/files_external/lib/AppInfo/Application.php
console.php
cron.php
lib/private/Files/Storage/Common.php
lib/private/PreviewManager.php
lib/private/Setup.php
lib/private/legacy/helper.php
lib/private/legacy/util.php
settings/admin.php
settings/templates/admin.php
tests/lib/Archive/TARTest.php
tests/lib/Archive/ZIPTest.php
tests/lib/Files/FilesystemTest.php
tests/lib/Files/Storage/LocalTest.php
tests/lib/Files/Type/DetectionTest.php
tests/lib/Files/ViewTest.php
tests/lib/ImageTest.php
tests/lib/LargeFileHelperGetFileSizeTest.php
tests/lib/TempManagerTest.php
tests/lib/UtilCheckServerTest.php
tests/lib/UtilTest.php

index 0ee4e9b3d5c34933c85702641f445bb2862e8251..c3c1b764c5adccc46e9a1e118286b0234b106f12 100644 (file)
@@ -90,13 +90,10 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
                        $container->query('OCA\Files_External\Lib\Backend\Google'),
                        $container->query('OCA\Files_External\Lib\Backend\Swift'),
                        $container->query('OCA\Files_External\Lib\Backend\SFTP_Key'),
+                       $container->query('OCA\Files_External\Lib\Backend\SMB'),
+                       $container->query('OCA\Files_External\Lib\Backend\SMB_OC'),
                ];
 
-               if (!\OC_Util::runningOnWindows()) {
-                       $backends[] = $container->query('OCA\Files_External\Lib\Backend\SMB');
-                       $backends[] = $container->query('OCA\Files_External\Lib\Backend\SMB_OC');
-               }
-
                return $backends;
        }
 
index ed19d41d4846ba7f71ef66aa393a34e3ed3d0cb4..4576cce885cb82b32fe2dd51c7616757c1ba96b2 100644 (file)
@@ -59,20 +59,18 @@ try {
 
        set_exception_handler('exceptionHandler');
 
-       if (!OC_Util::runningOnWindows())  {
-               if (!function_exists('posix_getuid')) {
-                       echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
-                       exit(0);
-               }
-               $user = posix_getpwuid(posix_getuid());
-               $configUser = posix_getpwuid(fileowner(OC::$configDir . 'config.php'));
-               if ($user['name'] !== $configUser['name']) {
-                       echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
-                       echo "Current user: " . $user['name'] . PHP_EOL;
-                       echo "Owner of config.php: " . $configUser['name'] . PHP_EOL;
-                       echo "Try adding 'sudo -u " . $configUser['name'] . " ' to the beginning of the command (without the single quotes)" . PHP_EOL;  
-                       exit(0);
-               }
+       if (!function_exists('posix_getuid')) {
+               echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
+               exit(0);
+       }
+       $user = posix_getpwuid(posix_getuid());
+       $configUser = posix_getpwuid(fileowner(OC::$configDir . 'config.php'));
+       if ($user['name'] !== $configUser['name']) {
+               echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
+               echo "Current user: " . $user['name'] . PHP_EOL;
+               echo "Owner of config.php: " . $configUser['name'] . PHP_EOL;
+               echo "Try adding 'sudo -u " . $configUser['name'] . " ' to the beginning of the command (without the single quotes)" . PHP_EOL;  
+               exit(0);
        }
 
        $oldWorkingDir = getcwd();
index bf258932a01342515b09e7f27cf3c01733d99fc9..5be52a302a5afac1f925d60e28999e694136acbe 100644 (file)
--- a/cron.php
+++ b/cron.php
@@ -84,19 +84,17 @@ try {
                set_time_limit(0);
 
                // the cron job must be executed with the right user
-               if (!OC_Util::runningOnWindows())  {
-                       if (!function_exists('posix_getuid')) {
-                               echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
-                               exit(0);
-                       }
-                       $user = posix_getpwuid(posix_getuid());
-                       $configUser = posix_getpwuid(fileowner(OC::$SERVERROOT . '/config/config.php'));
-                       if ($user['name'] !== $configUser['name']) {
-                               echo "Console has to be executed with the same user as the web server is operated" . PHP_EOL;
-                               echo "Current user: " . $user['name'] . PHP_EOL;
-                               echo "Web server user: " . $configUser['name'] . PHP_EOL;
-                               exit(0);
-                       }
+               if (!function_exists('posix_getuid')) {
+                       echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
+                       exit(0);
+               }
+               $user = posix_getpwuid(posix_getuid());
+               $configUser = posix_getpwuid(fileowner(OC::$SERVERROOT . '/config/config.php'));
+               if ($user['name'] !== $configUser['name']) {
+                       echo "Console has to be executed with the same user as the web server is operated" . PHP_EOL;
+                       echo "Current user: " . $user['name'] . PHP_EOL;
+                       echo "Web server user: " . $configUser['name'] . PHP_EOL;
+                       exit(0);
                }
 
                // We call ownCloud from the CLI (aka cron)
index 0c1b69108d40c2997f4e5444a220f4c0be838de5..6c4013d2acb8df0764b6c9c4b2c91edc576d1eab 100644 (file)
@@ -489,25 +489,7 @@ abstract class Common implements Storage, ILockingStorage {
                }
 
                // NOTE: $path will remain unverified for now
-               if (\OC_Util::runningOnWindows()) {
-                       $this->verifyWindowsPath($fileName);
-               } else {
-                       $this->verifyPosixPath($fileName);
-               }
-       }
-
-       /**
-        * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
-        * @param string $fileName
-        * @throws InvalidPathException
-        */
-       protected function verifyWindowsPath($fileName) {
-               $fileName = trim($fileName);
-               $this->scanForInvalidCharacters($fileName, "\\/<>:\"|?*");
-               $reservedNames = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9'];
-               if (in_array(strtoupper($fileName), $reservedNames)) {
-                       throw new ReservedWordException();
-               }
+               $this->verifyPosixPath($fileName);
        }
 
        /**
index f3c7a4de0d0da5142411ba563f4187fc1a46ffc8..43c414ccb631896bf22101d431cf1cba4efb7b5a 100644 (file)
@@ -299,8 +299,7 @@ class PreviewManager implements IPreview {
                        }
 
                        if (count($checkImagick->queryFormats('PDF')) === 1) {
-                               // Office previews are currently not supported on Windows
-                               if (!\OC_Util::runningOnWindows() && \OC_Helper::is_function_enabled('shell_exec')) {
+                               if (\OC_Helper::is_function_enabled('shell_exec')) {
                                        $officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null));
 
                                        if (!$officeFound) {
@@ -324,9 +323,8 @@ class PreviewManager implements IPreview {
                        }
                }
 
-               // Video requires avconv or ffmpeg and is therefor
-               // currently not supported on Windows.
-               if (in_array('OC\Preview\Movie', $this->getEnabledDefaultProvider()) && !\OC_Util::runningOnWindows()) {
+               // Video requires avconv or ffmpeg
+               if (in_array('OC\Preview\Movie', $this->getEnabledDefaultProvider())) {
                        $avconvBinary = \OC_Helper::findBinaryPath('avconv');
                        $ffmpegBinary = ($avconvBinary) ? null : \OC_Helper::findBinaryPath('ffmpeg');
 
index 46969f50fa0e15f65e8e5b33a6241ff84b033a78..f1454805a088e61f2886b1f43b5a71f52223329d 100644 (file)
@@ -305,10 +305,6 @@ class Setup {
                        $trustedDomains = [$request->getInsecureServerHost()];
                }
 
-               if (\OC_Util::runningOnWindows()) {
-                       $dataDir = rtrim(realpath($dataDir), '\\');
-               }
-
                //use sqlite3 when available, otherwise sqlite2 will be used.
                if($dbType=='sqlite' and class_exists('SQLite3')) {
                        $dbType='sqlite3';
index 21fb3cbc5abdaf96a82bc1ff1e37be2e003b31dd..06cffe80837c27a9101941537ce235666db54bde 100644 (file)
@@ -534,7 +534,7 @@ class OC_Helper {
                        return $memcache->get($program);
                }
                $result = null;
-               if (!\OC_Util::runningOnWindows() && self::is_function_enabled('exec')) {
+               if (self::is_function_enabled('exec')) {
                        $exeSniffer = new ExecutableFinder();
                        // Returns null if nothing is found
                        $result = $exeSniffer->find($program);
index 3c56008a48b5d73a3753e75c612dda7a72121226..2a876eda4d041920729c3b0a59de12fc84e4de61 100644 (file)
@@ -902,22 +902,18 @@ class OC_Util {
        public static function checkDataDirectoryPermissions($dataDirectory) {
                $l = \OC::$server->getL10N('lib');
                $errors = array();
-               if (self::runningOnWindows()) {
-                       //TODO: permissions checks for windows hosts
-               } else {
-                       $permissionsModHint = $l->t('Please change the permissions to 0770 so that the directory'
-                               . ' cannot be listed by other users.');
+               $permissionsModHint = $l->t('Please change the permissions to 0770 so that the directory'
+                       . ' cannot be listed by other users.');
+               $perms = substr(decoct(@fileperms($dataDirectory)), -3);
+               if (substr($perms, -1) != '0') {
+                       chmod($dataDirectory, 0770);
+                       clearstatcache();
                        $perms = substr(decoct(@fileperms($dataDirectory)), -3);
-                       if (substr($perms, -1) != '0') {
-                               chmod($dataDirectory, 0770);
-                               clearstatcache();
-                               $perms = substr(decoct(@fileperms($dataDirectory)), -3);
-                               if (substr($perms, 2, 1) != '0') {
-                                       $errors[] = array(
-                                               'error' => $l->t('Data directory (%s) is readable by other users', array($dataDirectory)),
-                                               'hint' => $permissionsModHint
-                                       );
-                               }
+                       if (substr($perms, 2, 1) != '0') {
+                               $errors[] = array(
+                                       'error' => $l->t('Data directory (%s) is readable by other users', array($dataDirectory)),
+                                       'hint' => $permissionsModHint
+                               );
                        }
                }
                return $errors;
@@ -933,7 +929,7 @@ class OC_Util {
        public static function checkDataDirectoryValidity($dataDirectory) {
                $l = \OC::$server->getL10N('lib');
                $errors = [];
-               if (!self::runningOnWindows() && $dataDirectory[0] !== '/') {
+               if ($dataDirectory[0] !== '/') {
                        $errors[] = [
                                'error' => $l->t('Data directory (%s) must be an absolute path', [$dataDirectory]),
                                'hint' => $l->t('Check the value of "datadirectory" in your configuration')
@@ -1203,11 +1199,6 @@ class OC_Util {
         * @return bool
         */
        public static function isSetLocaleWorking() {
-               // setlocale test is pointless on Windows
-               if (OC_Util::runningOnWindows()) {
-                       return true;
-               }
-
                \Patchwork\Utf8\Bootup::initLocale();
                if ('' === basename('§')) {
                        return false;
index 3ae7455b2ea607797a646a1364b53bbdfc187876..81267ddef10dae8a0e09254f75acab2829f18323 100644 (file)
@@ -154,9 +154,6 @@ $template->assign('cronErrors', $appConfig->getValue('core', 'cronErrors'));
 $path = getenv('PATH');
 $template->assign('getenvServerNotWorking', empty($path));
 
-// warn if Windows is used
-$template->assign('WindowsWarning', OC_Util::runningOnWindows());
-
 // warn if outdated version of a memcache module is used
 $caches = [
        'apcu'  => ['name' => $l->t('APCu'), 'version' => '4.0.6'],
index f41c0d3c1010d64c0ae85b9ea0cd39c58359e76f..93c9dca7153b0b11ee79451880b77e45a5c00e24 100644 (file)
@@ -106,15 +106,6 @@ if ($_['invalidTransactionIsolationLevel']) {
 <?php
 }
 
-// Windows Warning
-if ($_['WindowsWarning']) {
-       ?>
-       <li>
-               <?php p($l->t('Your server is running on Microsoft Windows. We highly recommend Linux for optimal user experience.')); ?>
-       </li>
-<?php
-}
-
 // Warning if memcache is outdated
 foreach ($_['OutdatedCacheWarning'] as $php_module => $data) {
        ?>
index 998ce201e72bc77835f1b2ed10502db469c28016..7575f6c51763d5064590b66c64bd675c0a447de0 100644 (file)
@@ -12,14 +12,6 @@ namespace Test\Archive;
 use OC\Archive\TAR;
 
 class TARTest extends TestBase {
-       protected function setUp() {
-               parent::setUp();
-
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] tar archives are not supported on Windows');
-               }
-       }
-
        protected function getExisting() {
                $dir = \OC::$SERVERROOT . '/tests/data';
                return new TAR($dir . '/data.tar.gz');
index 8d639e0d686aaa8cc8ef7055185727e1196a6b95..ff0155f3d0156d3f8e11e1b2b30fea5bdc0cba29 100644 (file)
@@ -12,14 +12,6 @@ namespace Test\Archive;
 use OC\Archive\ZIP;
 
 class ZIPTest extends TestBase {
-       protected function setUp() {
-               parent::setUp();
-
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] ');
-               }
-       }
-
        protected function getExisting() {
                $dir = \OC::$SERVERROOT . '/tests/data';
                return new ZIP($dir . '/data.zip');
index 76e3f4716335c54c27f27abd600f6f51d8847ac8..210ce4edc69cac077c45e3edbafa2cc824129b59 100644 (file)
@@ -272,28 +272,6 @@ class FilesystemTest extends \Test\TestCase {
                $this->assertSame($expected, \OC\Files\Filesystem::isFileBlacklisted($path));
        }
 
-       public function normalizePathWindowsAbsolutePathData() {
-               return array(
-                       array('C:/', 'C:\\'),
-                       array('C:/', 'C:\\', false),
-                       array('C:/tests', 'C:\\tests'),
-                       array('C:/tests', 'C:\\tests', false),
-                       array('C:/tests', 'C:\\tests\\'),
-                       array('C:/tests/', 'C:\\tests\\', false),
-               );
-       }
-
-       /**
-        * @dataProvider normalizePathWindowsAbsolutePathData
-        */
-       public function testNormalizePathWindowsAbsolutePath($expected, $path, $stripTrailingSlash = true) {
-               if (!\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('This test is Windows only');
-               }
-
-               $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash, true));
-       }
-
        public function testNormalizePathUTF8() {
                if (!class_exists('Patchwork\PHP\Shim\Normalizer')) {
                        $this->markTestSkipped('UTF8 normalizer Patchwork was not found');
index cca4d6a66764c045accbf05e90938de1f9afe373..89dd2f0786fd7da69ba3940839d2dea45f83c98c 100644 (file)
@@ -48,10 +48,6 @@ class LocalTest extends Storage {
        }
 
        public function testStableEtag() {
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] On Windows platform we have no stable etag generation - yet');
-               }
-
                $this->instance->file_put_contents('test.txt', 'foobar');
                $etag1 = $this->instance->getETag('test.txt');
                $etag2 = $this->instance->getETag('test.txt');
@@ -59,10 +55,6 @@ class LocalTest extends Storage {
        }
 
        public function testEtagChange() {
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] On Windows platform we have no stable etag generation - yet');
-               }
-
                $this->instance->file_put_contents('test.txt', 'foo');
                $this->instance->touch('test.txt', time() - 2);
                $etag1 = $this->instance->getETag('test.txt');
index 5800f4eb8e3a3ec046278975b8e88edb00729888..7b9dc1b3e4d47e6b7aff89ef39ec3903cb886b4b 100644 (file)
@@ -80,10 +80,6 @@ class DetectionTest extends \Test\TestCase {
        }
 
        public function testDetectString() {
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows');
-               }
-
                $result = $this->detection->detectString("/data/data.tar.gz");
                $expected = 'text/plain; charset=us-ascii';
                $this->assertEquals($expected, $result);
index 87feb63888d0da1b12b82a8ba5d2830cfd6b5d96..72a91614100af6cdd57616847fac0b3cadf20796 100644 (file)
@@ -104,7 +104,7 @@ class ViewTest extends \Test\TestCase {
                        $cache->clear();
                }
 
-               if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
+               if ($this->tempStorage) {
                        system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
                }
 
@@ -761,14 +761,10 @@ class ViewTest extends \Test\TestCase {
                /*
                 * 4096 is the maximum path length in file_cache.path in *nix
                 * 1024 is the max path length in mac
-                * 228 is the max path length in windows
                 */
                $folderName = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789';
                $tmpdirLength = strlen(\OC::$server->getTempManager()->getTemporaryFolder());
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] ');
-                       $depth = ((260 - $tmpdirLength) / 57);
-               } elseif (\OC_Util::runningOnMac()) {
+               if (\OC_Util::runningOnMac()) {
                        $depth = ((1024 - $tmpdirLength) / 57);
                } else {
                        $depth = ((4000 - $tmpdirLength) / 57);
index 9dba7e3739b597a8fdc088f64adc46344063b018..9176b8cf6c9299cd5ae334795a4cef0130800773 100644 (file)
@@ -75,10 +75,6 @@ class ImageTest extends \Test\TestCase {
                $img = new \OC_Image(null);
                $this->assertEquals('', $img->mimeType());
 
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] Images created with imagecreate() are pngs on windows');
-               }
-
                $img = new \OC_Image(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
                $this->assertEquals('image/jpeg', $img->mimeType());
 
index ac81a31819f5ce60028919c5b29b1b2b6ab4545f..0c3a11e971a81a961f28fe23aea52f821abb388a 100644 (file)
@@ -28,12 +28,10 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
        public function dataFileNameProvider() {
                $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
 
-               $filePaths = array(array($path . 'lorem.txt', 446));
-               if (!\OC_Util::runningOnWindows()) {
-                       $filePaths[] = array($path . 'strängé filename (duplicate #2).txt', 446);
-               }
-
-               return $filePaths;
+               return [
+                       [ $path . 'lorem.txt', 446 ],
+                       [ $path . 'strängé filename (duplicate #2).txt', 446 ],
+               ];
        }
 
        /**
index c4b88469b89380423f8e1d07357d6c0d13756911..d3f6ee1dc4738ffad1b31bd6e2fee56b0b82ee46 100644 (file)
@@ -138,9 +138,6 @@ class TempManagerTest extends \Test\TestCase {
        }
 
        public function testLogCantCreateFile() {
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] chmod() does not work as intended on Windows.');
-               }
                $this->markTestSkipped('TODO: Disable because fails on drone');
 
                $logger = $this->getMock('\Test\NullLogger');
@@ -153,9 +150,6 @@ class TempManagerTest extends \Test\TestCase {
        }
 
        public function testLogCantCreateFolder() {
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] chmod() does not work as intended on Windows.');
-               }
                $this->markTestSkipped('TODO: Disable because fails on drone');
 
                $logger = $this->getMock('\Test\NullLogger');
index 6465f8dd42b8d86aad805e44e7882f18a3680598..b1152e97256ebb3a93d12d5dd1ac485726441d3f 100644 (file)
@@ -145,9 +145,6 @@ class UtilCheckServerTest extends \Test\TestCase {
         * Tests an error is given when the datadir is not writable
         */
        public function testDataDirNotWritable() {
-               if (\OC_Util::runningOnWindows()) {
-                       $this->markTestSkipped('[Windows] chmod() does not work as intended on Windows.');
-               }
                $this->markTestSkipped('TODO: Disable because fails on drone');
 
                chmod($this->datadir, 0300);
index 7da7db0291ca3f5a5481c03e9e777f5354021e22..c68f8d00a40ca9d3ef310e65abc2ebcb2f915123 100644 (file)
@@ -396,10 +396,8 @@ class UtilTest extends \Test\TestCase {
                $this->assertNotEmpty($errors);
                \OCP\Files::rmdirr($dataDir);
 
-               if (!\OC_Util::runningOnWindows()) {
-                       $errors = \OC_Util::checkDataDirectoryValidity('relative/path');
-                       $this->assertNotEmpty($errors);
-               }
+               $errors = \OC_Util::checkDataDirectoryValidity('relative/path');
+               $this->assertNotEmpty($errors);
        }
 
        protected function setUp() {