Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
fe44ac26
Commit
fe44ac26
authored
11 years ago
by
Lukas Reschke
Committed by
Bjoern Schiessle
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add overwritehost config on setup and upgrade
parent
92560c5b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/config.sample.php
+3
-0
3 additions, 0 deletions
config/config.sample.php
lib/private/request.php
+31
-15
31 additions, 15 deletions
lib/private/request.php
lib/private/setup.php
+1
-0
1 addition, 0 deletions
lib/private/setup.php
lib/private/updater.php
+15
-0
15 additions, 0 deletions
lib/private/updater.php
with
50 additions
and
15 deletions
config/config.sample.php
+
3
−
0
View file @
fe44ac26
...
...
@@ -53,6 +53,9 @@ $CONFIG = array(
/* The optional authentication for the proxy to use to connect to the internet. The format is: [username]:[password] */
"proxyuserpwd"
=>
""
,
/* List of trusted domains, to prevent host header poisoning ownCloud is only using these Host headers */
'trusted_domains'
=>
array
(
'demo.owncloud.org'
),
/* Theme to use for ownCloud */
"theme"
=>
""
,
...
...
This diff is collapsed.
Click to expand it.
lib/private/request.php
+
31
−
15
View file @
fe44ac26
...
...
@@ -24,6 +24,16 @@ class OC_Request {
or
(
$type
!==
'protocol'
and
OC_Config
::
getValue
(
'forcessl'
,
false
));
}
/**
* @brief Checks whether a domain is considered as trusted. This is used to prevent Host Header Poisoning.
* @param string $host
* @return bool
*/
public
static
function
isTrustedDomain
(
$domain
)
{
$trustedList
=
\OC_Config
::
getValue
(
'trusted_domains'
,
array
(
''
));
return
in_array
(
$domain
,
$trustedList
);
}
/**
* @brief Returns the server host
* @returns string the server host
...
...
@@ -45,19 +55,25 @@ class OC_Request {
else
{
$host
=
$_SERVER
[
'HTTP_X_FORWARDED_HOST'
];
}
}
else
{
}
else
{
if
(
isset
(
$_SERVER
[
'HTTP_HOST'
]))
{
return
$_SERVER
[
'HTTP_HOST'
];
$host
=
$_SERVER
[
'HTTP_HOST'
];
}
if
(
isset
(
$_SERVER
[
'SERVER_NAME'
]))
{
return
$_SERVER
[
'SERVER_NAME'
];
$host
=
$_SERVER
[
'SERVER_NAME'
];
}
return
'localhost'
;
}
// Verify that the host is a trusted domain if the trusted domains
// are defined
// If no trusted domain is provided the first trusted domain is returned
if
(
self
::
isTrustedDomain
(
$host
)
||
\OC_Config
::
getValue
(
'trusted_domains'
,
""
)
===
""
)
{
return
$host
;
}
else
{
$trustedList
=
\OC_Config
::
getValue
(
'trusted_domains'
,
array
(
''
));
return
$trustedList
[
0
];
}
}
/**
* @brief Returns the server protocol
...
...
@@ -71,14 +87,14 @@ class OC_Request {
}
if
(
isset
(
$_SERVER
[
'HTTP_X_FORWARDED_PROTO'
]))
{
$proto
=
strtolower
(
$_SERVER
[
'HTTP_X_FORWARDED_PROTO'
]);
}
else
{
if
(
isset
(
$_SERVER
[
'HTTPS'
])
and
!
empty
(
$_SERVER
[
'HTTPS'
])
and
(
$_SERVER
[
'HTTPS'
]
!=
'off'
))
{
$proto
=
'https'
;
}
else
{
$proto
=
'http'
;
// Verify that the protocol is always HTTP or HTTPS
// default to http if an invalid value is provided
return
$proto
===
'https'
?
'https'
:
'http'
;
}
if
(
isset
(
$_SERVER
[
'HTTPS'
])
&&
!
empty
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]
!==
'off'
)
{
return
'https'
;
}
return
$proto
;
return
'http'
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
lib/private/setup.php
+
1
−
0
View file @
fe44ac26
...
...
@@ -65,6 +65,7 @@ class OC_Setup {
OC_Config
::
setValue
(
'passwordsalt'
,
$salt
);
//write the config file
OC_Config
::
setValue
(
'trusted_domains'
,
array
(
OC_Request
::
serverHost
()));
OC_Config
::
setValue
(
'datadirectory'
,
$datadir
);
OC_Config
::
setValue
(
'dbtype'
,
$dbtype
);
OC_Config
::
setValue
(
'version'
,
implode
(
'.'
,
OC_Util
::
getVersion
()));
...
...
This diff is collapsed.
Click to expand it.
lib/private/updater.php
+
15
−
0
View file @
fe44ac26
...
...
@@ -102,6 +102,20 @@ class Updater extends BasicEmitter {
$this
->
log
->
debug
(
'starting upgrade from '
.
$installedVersion
.
' to '
.
$currentVersion
,
array
(
'app'
=>
'core'
));
}
$this
->
emit
(
'\OC\Updater'
,
'maintenanceStart'
);
/*
* START CONFIG CHANGES FOR OLDER VERSIONS
*/
if
(
version_compare
(
$currentVersion
,
'6.90.1'
,
'<'
))
{
// Add the overwriteHost config if it is not existant
// This is added to prevent host header poisoning
\OC_Config
::
setValue
(
'trusted_domains'
,
\OC_Config
::
getValue
(
'trusted_domains'
,
array
(
\OC_Request
::
serverHost
())));
}
/*
* STOP CONFIG CHANGES FOR OLDER VERSIONS
*/
try
{
\OC_DB
::
updateDbFromStructure
(
\OC
::
$SERVERROOT
.
'/db_structure.xml'
);
$this
->
emit
(
'\OC\Updater'
,
'dbUpgrade'
);
...
...
@@ -162,3 +176,4 @@ class Updater extends BasicEmitter {
$this
->
emit
(
'\OC\Updater'
,
'filecacheDone'
);
}
}
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