Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
23dd7cb5
Commit
23dd7cb5
authored
10 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Don't complain about non-writable datadirs before we're installed
parent
6fa3280c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/util.php
+19
-17
19 additions, 17 deletions
lib/private/util.php
tests/lib/utilcheckserver.php
+37
-0
37 additions, 0 deletions
tests/lib/utilcheckserver.php
with
56 additions
and
17 deletions
lib/private/util.php
+
19
−
17
View file @
23dd7cb5
...
@@ -463,26 +463,28 @@ class OC_Util {
...
@@ -463,26 +463,28 @@ class OC_Util {
);
);
}
}
}
}
// Create root dir.
if
(
!
is_dir
(
$CONFIG_DATADIRECTORY
))
{
if
(
$config
->
getSystemValue
(
'installed'
,
false
))
{
$success
=
@
mkdir
(
$CONFIG_DATADIRECTORY
);
if
(
!
is_dir
(
$CONFIG_DATADIRECTORY
))
{
if
(
$success
)
{
$success
=
@
mkdir
(
$CONFIG_DATADIRECTORY
);
$errors
=
array_merge
(
$errors
,
self
::
checkDataDirectoryPermissions
(
$CONFIG_DATADIRECTORY
));
if
(
$success
)
{
}
else
{
$errors
=
array_merge
(
$errors
,
self
::
checkDataDirectoryPermissions
(
$CONFIG_DATADIRECTORY
));
}
else
{
$errors
[]
=
array
(
'error'
=>
$l
->
t
(
'Cannot create "data" directory (%s)'
,
array
(
$CONFIG_DATADIRECTORY
)),
'hint'
=>
$l
->
t
(
'This can usually be fixed by '
.
'<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.'
,
array
(
OC_Helper
::
linkToDocs
(
'admin-dir_permissions'
)))
);
}
}
else
if
(
!
is_writable
(
$CONFIG_DATADIRECTORY
)
or
!
is_readable
(
$CONFIG_DATADIRECTORY
))
{
$errors
[]
=
array
(
$errors
[]
=
array
(
'error'
=>
$l
->
t
(
'Cannot create "data" directory (%s)'
,
array
(
$CONFIG_DATADIRECTORY
)),
'error'
=>
'Data directory ('
.
$CONFIG_DATADIRECTORY
.
') not writable by ownCloud'
,
'hint'
=>
$l
->
t
(
'This can usually be fixed by '
'hint'
=>
$permissionsHint
.
'<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.'
,
array
(
OC_Helper
::
linkToDocs
(
'admin-dir_permissions'
)))
);
);
}
else
{
$errors
=
array_merge
(
$errors
,
self
::
checkDataDirectoryPermissions
(
$CONFIG_DATADIRECTORY
));
}
}
}
else
if
(
!
is_writable
(
$CONFIG_DATADIRECTORY
)
or
!
is_readable
(
$CONFIG_DATADIRECTORY
))
{
$errors
[]
=
array
(
'error'
=>
'Data directory ('
.
$CONFIG_DATADIRECTORY
.
') not writable by ownCloud'
,
'hint'
=>
$permissionsHint
);
}
else
{
$errors
=
array_merge
(
$errors
,
self
::
checkDataDirectoryPermissions
(
$CONFIG_DATADIRECTORY
));
}
}
if
(
!
OC_Util
::
isSetLocaleWorking
())
{
if
(
!
OC_Util
::
isSetLocaleWorking
())
{
...
...
This diff is collapsed.
Click to expand it.
tests/lib/utilcheckserver.php
+
37
−
0
View file @
23dd7cb5
...
@@ -19,6 +19,7 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
...
@@ -19,6 +19,7 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
*/
*/
protected
function
getConfig
(
$systemOptions
)
{
protected
function
getConfig
(
$systemOptions
)
{
$systemOptions
[
'datadirectory'
]
=
$this
->
datadir
;
$systemOptions
[
'datadirectory'
]
=
$this
->
datadir
;
$systemOptions
[
'appstoreenabled'
]
=
false
;
//it's likely that there is no app folder we can write in
$config
=
$this
->
getMockBuilder
(
'\OCP\IConfig'
)
$config
=
$this
->
getMockBuilder
(
'\OCP\IConfig'
)
->
disableOriginalConstructor
()
->
disableOriginalConstructor
()
->
getMock
();
->
getMock
();
...
@@ -35,6 +36,7 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
...
@@ -35,6 +36,7 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
$this
->
datadir
=
\OC_Helper
::
tmpFolder
();
$this
->
datadir
=
\OC_Helper
::
tmpFolder
();
file_put_contents
(
$this
->
datadir
.
'/.ocdata'
,
''
);
file_put_contents
(
$this
->
datadir
.
'/.ocdata'
,
''
);
\OC
::
$server
->
getSession
()
->
set
(
'checkServer_succeeded'
,
false
);
}
}
public
function
tearDown
()
{
public
function
tearDown
()
{
...
@@ -121,4 +123,39 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
...
@@ -121,4 +123,39 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
$this
->
assertCount
(
1
,
$result
);
$this
->
assertCount
(
1
,
$result
);
}
}
/**
* Tests that no error is given when the datadir is writable
*/
public
function
testDataDirWritable
()
{
$result
=
\OC_Util
::
checkServer
(
$this
->
getConfig
(
array
(
'installed'
=>
true
,
'version'
=>
implode
(
'.'
,
OC_Util
::
getVersion
())
)));
$this
->
assertEmpty
(
$result
);
}
/**
* Tests an error is given when the datadir is not writable
*/
public
function
testDataDirNotWritable
()
{
chmod
(
$this
->
datadir
,
0300
);
$result
=
\OC_Util
::
checkServer
(
$this
->
getConfig
(
array
(
'installed'
=>
true
,
'version'
=>
implode
(
'.'
,
OC_Util
::
getVersion
())
)));
$this
->
assertCount
(
1
,
$result
);
}
/**
* Tests no error is given when the datadir is not writable during setup
*/
public
function
testDataDirNotWritableSetup
()
{
chmod
(
$this
->
datadir
,
0300
);
$result
=
\OC_Util
::
checkServer
(
$this
->
getConfig
(
array
(
'installed'
=>
false
,
'version'
=>
implode
(
'.'
,
OC_Util
::
getVersion
())
)));
chmod
(
$this
->
datadir
,
0700
);
//needed for cleanup
$this
->
assertEmpty
(
$result
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment