Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ISPConfig 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Helmo
ISPConfig 3
Commits
c6943950
Commit
c6943950
authored
13 years ago
by
tbrehm
Browse files
Options
Downloads
Patches
Plain Diff
Some fixes in folder protection.
parent
2c273e99
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/mods-available/web_module.inc.php
+2
-0
2 additions, 0 deletions
server/mods-available/web_module.inc.php
server/plugins-available/apache2_plugin.inc.php
+18
-9
18 additions, 9 deletions
server/plugins-available/apache2_plugin.inc.php
with
20 additions
and
9 deletions
server/mods-available/web_module.inc.php
+
2
−
0
View file @
c6943950
...
@@ -92,6 +92,8 @@ class web_module {
...
@@ -92,6 +92,8 @@ class web_module {
$app
->
modules
->
registerTableHook
(
'ftp_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'ftp_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'shell_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'shell_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'webdav_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'webdav_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'web_folder'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'web_folder_user'
,
'web_module'
,
'process'
);
// Register service
// Register service
$app
->
services
->
registerService
(
'httpd'
,
'web_module'
,
'restartHttpd'
);
$app
->
services
->
registerService
(
'httpd'
,
'web_module'
,
'restartHttpd'
);
...
...
This diff is collapsed.
Click to expand it.
server/plugins-available/apache2_plugin.inc.php
+
18
−
9
View file @
c6943950
...
@@ -1195,7 +1195,7 @@ class apache2_plugin {
...
@@ -1195,7 +1195,7 @@ class apache2_plugin {
//* Create or update the .htaccess folder protection
//* Create or update the .htaccess folder protection
function
web_folder_user
(
$event_name
,
$data
)
{
function
web_folder_user
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
global
$app
,
$conf
;
$app
->
uses
(
'system'
);
$app
->
uses
(
'system'
);
if
(
$event_name
==
'web_folder_user_delete'
)
{
if
(
$event_name
==
'web_folder_user_delete'
)
{
...
@@ -1213,17 +1213,19 @@ class apache2_plugin {
...
@@ -1213,17 +1213,19 @@ class apache2_plugin {
}
}
//* Get the folder path.
//* Get the folder path.
$folder_path
=
realpath
(
$website
[
'document_root'
]
.
'/web/'
.
$folder
[
'path'
]);
if
(
substr
(
$folder
[
'path'
],
0
,
1
)
==
'/'
)
$folder
[
'path'
]
=
substr
(
$folder
[
'path'
],
1
);
if
(
substr
(
$folder
[
'path'
],
-
1
)
==
'/'
)
$folder
[
'path'
]
=
substr
(
$folder
[
'path'
],
0
,
-
1
);
$folder_path
=
escapeshellcmd
(
$website
[
'document_root'
]
.
'/web/'
.
$folder
[
'path'
]);
if
(
substr
(
$folder_path
,
-
1
!=
'/'
))
$folder_path
.
=
'/'
;
if
(
substr
(
$folder_path
,
-
1
!=
'/'
))
$folder_path
.
=
'/'
;
//* Check if the resulting path is inside the docroot
//* Check if the resulting path is inside the docroot
if
(
s
ub
str
(
$folder_path
,
0
,
strlen
(
$website
[
'document_root'
]))
!=
$website
[
'document_root'
]
)
{
if
(
s
tri
str
(
$folder_path
,
'..'
)
||
stristr
(
$folder_path
,
'./'
)
||
stristr
(
$folder_path
,
'\\'
)
)
{
$app
->
log
(
'Folder path
is outside of docroot
.'
,
LOGLEVEL_DEBUG
);
$app
->
log
(
'Folder path
"'
.
$folder_path
.
'" contains .. or ./
.'
,
LOGLEVEL_DEBUG
);
return
false
;
return
false
;
}
}
//* Create the folder path, if it does not exist
//* Create the folder path, if it does not exist
if
(
!
is_dir
(
$folder_path
))
exec
(
'mkdir -p '
.
escapehsellarg
(
$folder_path
)
)
;
if
(
!
is_dir
(
$folder_path
))
exec
(
'mkdir -p '
.
$folder_path
);
//* Create empty .htpasswd file, if it does not exist
//* Create empty .htpasswd file, if it does not exist
if
(
!
is_file
(
$folder_path
.
'.htpasswd'
))
{
if
(
!
is_file
(
$folder_path
.
'.htpasswd'
))
{
...
@@ -1232,13 +1234,20 @@ class apache2_plugin {
...
@@ -1232,13 +1234,20 @@ class apache2_plugin {
$app
->
log
(
'Created file'
.
$folder_path
.
'.htpasswd'
,
LOGLEVEL_DEBUG
);
$app
->
log
(
'Created file'
.
$folder_path
.
'.htpasswd'
,
LOGLEVEL_DEBUG
);
}
}
if
(
$data
[
'new'
][
'username'
]
!=
$data
[
'old'
][
'username'
]
||
$data
[
'new'
][
'active'
]
==
'n'
)
{
$app
->
system
->
removeLine
(
$folder_path
.
'.htpasswd'
,
$data
[
'old'
][
'username'
]
.
':'
);
$app
->
log
(
'Removed user: '
.
$data
[
'old'
][
'username'
],
LOGLEVEL_DEBUG
);
}
//* Add or remove the user from .htpasswd file
//* Add or remove the user from .htpasswd file
if
(
$event_name
==
'web_folder_user_delete'
)
{
if
(
$event_name
==
'web_folder_user_delete'
)
{
$app
->
system
->
removeLine
(
$folder_path
.
'.htpasswd'
,
$data
[
'
new
'
][
'username'
]
.
':'
);
$app
->
system
->
removeLine
(
$folder_path
.
'.htpasswd'
,
$data
[
'
old
'
][
'username'
]
.
':'
);
$app
->
log
(
'Removed user: '
.
$data
[
'
new
'
][
'username'
],
LOGLEVEL_DEBUG
);
$app
->
log
(
'Removed user: '
.
$data
[
'
old
'
][
'username'
],
LOGLEVEL_DEBUG
);
}
else
{
}
else
{
$app
->
system
->
replaceLine
(
$folder_path
.
'.htpasswd'
,
$data
[
'new'
][
'username'
]
.
':'
,
$data
[
'new'
][
'username'
]
.
':'
.
$data
[
'new'
][
'password'
],
0
,
1
);
if
(
$data
[
'new'
][
'active'
]
==
'y'
)
{
$app
->
log
(
'Added or updated user: '
.
$data
[
'new'
][
'username'
],
LOGLEVEL_DEBUG
);
$app
->
system
->
replaceLine
(
$folder_path
.
'.htpasswd'
,
$data
[
'new'
][
'username'
]
.
':'
,
$data
[
'new'
][
'username'
]
.
':'
.
$data
[
'new'
][
'password'
],
0
,
1
);
$app
->
log
(
'Added or updated user: '
.
$data
[
'new'
][
'username'
],
LOGLEVEL_DEBUG
);
}
}
}
//* Create the .htaccess file
//* Create the .htaccess file
...
...
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