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
79778d6a
Commit
79778d6a
authored
10 years ago
by
Thomas Müller
Committed by
Lukas Reschke
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
code cleanup during review
parent
233c49f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/setup/controller.php
+8
-8
8 additions, 8 deletions
core/setup/controller.php
lib/private/setup.php
+17
-17
17 additions, 17 deletions
lib/private/setup.php
with
25 additions
and
25 deletions
core/setup/controller.php
+
8
−
8
View file @
79778d6a
...
@@ -103,7 +103,7 @@ class Controller {
...
@@ -103,7 +103,7 @@ class Controller {
$setup
=
new
\OC_Setup
(
$this
->
config
);
$setup
=
new
\OC_Setup
(
$this
->
config
);
$databases
=
$setup
->
getSupportedDatabases
();
$databases
=
$setup
->
getSupportedDatabases
();
$data
d
ir
=
$this
->
config
->
getSystemValue
(
'datadirectory'
,
\OC
::
$SERVERROOT
.
'/data'
);
$data
D
ir
=
$this
->
config
->
getSystemValue
(
'datadirectory'
,
\OC
::
$SERVERROOT
.
'/data'
);
$vulnerableToNullByte
=
false
;
$vulnerableToNullByte
=
false
;
if
(
@
file_exists
(
__FILE__
.
"
\0
Nullbyte"
))
{
// Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
if
(
@
file_exists
(
__FILE__
.
"
\0
Nullbyte"
))
{
// Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
$vulnerableToNullByte
=
true
;
$vulnerableToNullByte
=
true
;
...
@@ -114,25 +114,25 @@ class Controller {
...
@@ -114,25 +114,25 @@ class Controller {
// Create data directory to test whether the .htaccess works
// Create data directory to test whether the .htaccess works
// Notice that this is not necessarily the same data directory as the one
// Notice that this is not necessarily the same data directory as the one
// that will effectively be used.
// that will effectively be used.
@
mkdir
(
$datadir
);
@
mkdir
(
$dataDir
);
if
(
is_dir
(
$datadir
)
&&
is_writable
(
$datadir
))
{
$htAccessWorking
=
true
;
if
(
is_dir
(
$dataDir
)
&&
is_writable
(
$dataDir
))
{
// Protect data directory here, so we can test if the protection is working
// Protect data directory here, so we can test if the protection is working
\OC_Setup
::
protectDataDirectory
();
\OC_Setup
::
protectDataDirectory
();
try
{
try
{
$ht
a
ccessWorking
=
\OC_Util
::
isHtaccessWorking
();
$ht
A
ccessWorking
=
\OC_Util
::
isHtaccessWorking
();
}
catch
(
\OC\HintException
$e
)
{
}
catch
(
\OC\HintException
$e
)
{
$errors
[]
=
array
(
$errors
[]
=
array
(
'error'
=>
$e
->
getMessage
(),
'error'
=>
$e
->
getMessage
(),
'hint'
=>
$e
->
getHint
()
'hint'
=>
$e
->
getHint
()
);
);
$ht
a
ccessWorking
=
false
;
$ht
A
ccessWorking
=
false
;
}
}
}
}
if
(
\OC_Util
::
runningOnMac
())
{
if
(
\OC_Util
::
runningOnMac
())
{
$l10n
=
\OC
::
$server
->
getL10N
(
'core'
);
$l10n
=
\OC
::
$server
->
getL10N
(
'core'
);
$themeName
=
\OC_Util
::
getTheme
();
$theme
=
new
\OC_Defaults
();
$theme
=
new
\OC_Defaults
();
$errors
[]
=
array
(
$errors
[]
=
array
(
'error'
=>
$l10n
->
t
(
'error'
=>
$l10n
->
t
(
...
@@ -151,8 +151,8 @@ class Controller {
...
@@ -151,8 +151,8 @@ class Controller {
'hasOracle'
=>
isset
(
$databases
[
'oci'
]),
'hasOracle'
=>
isset
(
$databases
[
'oci'
]),
'hasMSSQL'
=>
isset
(
$databases
[
'mssql'
]),
'hasMSSQL'
=>
isset
(
$databases
[
'mssql'
]),
'databases'
=>
$databases
,
'databases'
=>
$databases
,
'directory'
=>
$data
d
ir
,
'directory'
=>
$data
D
ir
,
'htaccessWorking'
=>
$ht
a
ccessWorking
,
'htaccessWorking'
=>
$ht
A
ccessWorking
,
'vulnerableToNullByte'
=>
$vulnerableToNullByte
,
'vulnerableToNullByte'
=>
$vulnerableToNullByte
,
'errors'
=>
$errors
,
'errors'
=>
$errors
,
);
);
...
...
This diff is collapsed.
Click to expand it.
lib/private/setup.php
+
17
−
17
View file @
79778d6a
...
@@ -90,7 +90,8 @@ class OC_Setup {
...
@@ -90,7 +90,8 @@ class OC_Setup {
'name'
=>
'MS SQL'
'name'
=>
'MS SQL'
)
)
);
);
$configuredDatabases
=
$this
->
config
->
getSystemValue
(
'supportedDatabases'
,
array
(
'sqlite'
,
'mysql'
,
'pgsql'
,
'oci'
,
'mssql'
));
$configuredDatabases
=
$this
->
config
->
getSystemValue
(
'supportedDatabases'
,
array
(
'sqlite'
,
'mysql'
,
'pgsql'
,
'oci'
,
'mssql'
));
if
(
!
is_array
(
$configuredDatabases
))
{
if
(
!
is_array
(
$configuredDatabases
))
{
throw
new
Exception
(
'Supported databases are not properly configured.'
);
throw
new
Exception
(
'Supported databases are not properly configured.'
);
}
}
...
@@ -122,7 +123,7 @@ class OC_Setup {
...
@@ -122,7 +123,7 @@ class OC_Setup {
$l
=
self
::
getTrans
();
$l
=
self
::
getTrans
();
$error
=
array
();
$error
=
array
();
$db
t
ype
=
$options
[
'dbtype'
];
$db
T
ype
=
$options
[
'dbtype'
];
if
(
empty
(
$options
[
'adminlogin'
]))
{
if
(
empty
(
$options
[
'adminlogin'
]))
{
$error
[]
=
$l
->
t
(
'Set an admin username.'
);
$error
[]
=
$l
->
t
(
'Set an admin username.'
);
...
@@ -134,25 +135,25 @@ class OC_Setup {
...
@@ -134,25 +135,25 @@ class OC_Setup {
$options
[
'directory'
]
=
OC
::
$SERVERROOT
.
"/data"
;
$options
[
'directory'
]
=
OC
::
$SERVERROOT
.
"/data"
;
}
}
if
(
!
isset
(
self
::
$dbSetupClasses
[
$db
t
ype
]))
{
if
(
!
isset
(
self
::
$dbSetupClasses
[
$db
T
ype
]))
{
$db
t
ype
=
'sqlite'
;
$db
T
ype
=
'sqlite'
;
}
}
$username
=
htmlspecialchars_decode
(
$options
[
'adminlogin'
]);
$username
=
htmlspecialchars_decode
(
$options
[
'adminlogin'
]);
$password
=
htmlspecialchars_decode
(
$options
[
'adminpass'
]);
$password
=
htmlspecialchars_decode
(
$options
[
'adminpass'
]);
$data
d
ir
=
htmlspecialchars_decode
(
$options
[
'directory'
]);
$data
D
ir
=
htmlspecialchars_decode
(
$options
[
'directory'
]);
$class
=
self
::
$dbSetupClasses
[
$db
t
ype
];
$class
=
self
::
$dbSetupClasses
[
$db
T
ype
];
/** @var \OC\Setup\AbstractDatabase $dbSetup */
/** @var \OC\Setup\AbstractDatabase $dbSetup */
$dbSetup
=
new
$class
(
self
::
getTrans
(),
'db_structure.xml'
);
$dbSetup
=
new
$class
(
self
::
getTrans
(),
'db_structure.xml'
);
$error
=
array_merge
(
$error
,
$dbSetup
->
validate
(
$options
));
$error
=
array_merge
(
$error
,
$dbSetup
->
validate
(
$options
));
// validate the data directory
// validate the data directory
if
(
if
(
(
!
is_dir
(
$data
d
ir
)
and
!
mkdir
(
$data
d
ir
))
or
(
!
is_dir
(
$data
D
ir
)
and
!
mkdir
(
$data
D
ir
))
or
!
is_writable
(
$data
d
ir
)
!
is_writable
(
$data
D
ir
)
)
{
)
{
$error
[]
=
$l
->
t
(
"Can't create or write into the data directory %s"
,
array
(
$data
d
ir
));
$error
[]
=
$l
->
t
(
"Can't create or write into the data directory %s"
,
array
(
$data
D
ir
));
}
}
if
(
count
(
$error
)
!=
0
)
{
if
(
count
(
$error
)
!=
0
)
{
...
@@ -168,12 +169,12 @@ class OC_Setup {
...
@@ -168,12 +169,12 @@ class OC_Setup {
}
}
if
(
OC_Util
::
runningOnWindows
())
{
if
(
OC_Util
::
runningOnWindows
())
{
$data
d
ir
=
rtrim
(
realpath
(
$data
d
ir
),
'\\'
);
$data
D
ir
=
rtrim
(
realpath
(
$data
D
ir
),
'\\'
);
}
}
//use sqlite3 when available, otherise sqlite2 will be used.
//use sqlite3 when available, other
w
ise sqlite2 will be used.
if
(
$db
t
ype
==
'sqlite'
and
class_exists
(
'SQLite3'
))
{
if
(
$db
T
ype
==
'sqlite'
and
class_exists
(
'SQLite3'
))
{
$db
t
ype
=
'sqlite3'
;
$db
T
ype
=
'sqlite3'
;
}
}
//generate a random salt that is used to salt the local user passwords
//generate a random salt that is used to salt the local user passwords
...
@@ -186,9 +187,9 @@ class OC_Setup {
...
@@ -186,9 +187,9 @@ class OC_Setup {
//write the config file
//write the config file
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'trusted_domains'
,
$trustedDomains
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'trusted_domains'
,
$trustedDomains
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'datadirectory'
,
$data
d
ir
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'datadirectory'
,
$data
D
ir
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'overwrite.cli.url'
,
\OC_Request
::
serverProtocol
()
.
'://'
.
\OC_Request
::
serverHost
()
.
OC
::
$WEBROOT
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'overwrite.cli.url'
,
\OC_Request
::
serverProtocol
()
.
'://'
.
\OC_Request
::
serverHost
()
.
OC
::
$WEBROOT
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'dbtype'
,
$db
t
ype
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'dbtype'
,
$db
T
ype
);
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'version'
,
implode
(
'.'
,
OC_Util
::
getVersion
()));
\OC
::
$server
->
getConfig
()
->
setSystemValue
(
'version'
,
implode
(
'.'
,
OC_Util
::
getVersion
()));
try
{
try
{
...
@@ -211,8 +212,7 @@ class OC_Setup {
...
@@ -211,8 +212,7 @@ class OC_Setup {
//create the user and group
//create the user and group
try
{
try
{
OC_User
::
createUser
(
$username
,
$password
);
OC_User
::
createUser
(
$username
,
$password
);
}
}
catch
(
Exception
$exception
)
{
catch
(
Exception
$exception
)
{
$error
[]
=
$exception
->
getMessage
();
$error
[]
=
$exception
->
getMessage
();
}
}
...
...
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