Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Massimiliano
ISPConfig 3
Commits
a7e4ec0c
Commit
a7e4ec0c
authored
Aug 14, 2014
by
Till Brehm
Browse files
Added new directory delete procedure in jailkit plugin.
parent
a13af292
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/plugins-available/shelluser_base_plugin.inc.php
View file @
a7e4ec0c
...
...
@@ -254,6 +254,11 @@ class shelluser_base_plugin {
// check if we have to delete the dir
$check
=
$app
->
db
->
queryOneRecord
(
'SELECT shell_user_id FROM `shell_user` WHERE `dir` = \''
.
$app
->
db
->
quote
(
$data
[
'old'
][
'dir'
])
.
'\''
);
if
(
!
$check
&&
is_dir
(
$data
[
'old'
][
'dir'
]))
{
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT * FROM web_domain WHERE domain_id = "
.
intval
(
$data
[
'old'
][
'parent_domain_id'
]));
$app
->
system
->
web_folder_protection
(
$web
[
'document_root'
],
false
);
// delete dir
$homedir
=
$data
[
'old'
][
'dir'
];
if
(
substr
(
$homedir
,
-
1
)
!==
'/'
)
$homedir
.
=
'/'
;
...
...
@@ -281,6 +286,8 @@ class shelluser_base_plugin {
}
unset
(
$files
);
unset
(
$dirs
);
$app
->
system
->
web_folder_protection
(
$web
[
'document_root'
],
true
);
}
// We delete only non jailkit users, jailkit users will be deleted by the jailkit plugin.
...
...
server/plugins-available/shelluser_jailkit_plugin.inc.php
View file @
a7e4ec0c
...
...
@@ -247,9 +247,13 @@ class shelluser_jailkit_plugin {
$app
->
system
->
web_folder_protection
(
$web
[
'document_root'
],
false
);
if
(
@
is_dir
(
$data
[
'old'
][
'dir'
]
.
$jailkit_chroot_userhome
))
{
$userid
=
intval
(
$app
->
system
->
getuid
(
$data
[
'old'
][
'username'
]));
$command
=
'killall -u '
.
escapeshellcmd
(
$data
[
'old'
][
'username'
])
.
' ; userdel -f'
;
$command
.
=
' '
.
escapeshellcmd
(
$data
[
'old'
][
'username'
])
.
' &> /dev/null'
;
exec
(
$command
);
$this
->
_delete_homedir
(
$data
[
'old'
][
'dir'
]
.
$jailkit_chroot_userhome
,
$userid
,
$data
[
'old'
][
'parent_domain_id'
]);
$app
->
log
(
"Jailkit Plugin -> delete chroot home:"
.
$data
[
'old'
][
'dir'
]
.
$jailkit_chroot_userhome
,
LOGLEVEL_DEBUG
);
}
...
...
@@ -523,6 +527,48 @@ class shelluser_jailkit_plugin {
exec
(
"chmod 600 '
$sshkeys
'"
);
}
private
function
_delete_homedir
(
$homedir
,
$userid
,
$parent_domain_id
)
{
global
$app
,
$conf
;
// check if we have to delete the dir
$check
=
$app
->
db
->
queryOneRecord
(
'SELECT shell_user_id FROM `shell_user` WHERE `dir` = \''
.
$app
->
db
->
quote
(
$homedir
)
.
'\''
);
if
(
!
$check
&&
is_dir
(
$homedir
))
{
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT * FROM web_domain WHERE domain_id = "
.
intval
(
$parent_domain_id
));
$app
->
system
->
web_folder_protection
(
$web
[
'document_root'
],
false
);
// delete dir
if
(
substr
(
$homedir
,
-
1
)
!==
'/'
)
$homedir
.
=
'/'
;
$files
=
array
(
'.bash_logout'
,
'.bash_history'
,
'.bashrc'
,
'.profile'
);
$dirs
=
array
(
'.ssh'
);
foreach
(
$files
as
$delfile
)
{
if
(
is_file
(
$homedir
.
$delfile
)
&&
fileowner
(
$homedir
.
$delfile
)
==
$userid
)
unlink
(
$homedir
.
$delfile
);
}
foreach
(
$dirs
as
$deldir
)
{
if
(
is_dir
(
$homedir
.
$deldir
)
&&
fileowner
(
$homedir
.
$deldir
)
==
$userid
)
exec
(
'rm -rf '
.
escapeshellarg
(
$homedir
.
$deldir
));
}
$empty
=
true
;
$dirres
=
opendir
(
$homedir
);
if
(
$dirres
)
{
while
((
$entry
=
readdir
(
$dirres
))
!==
false
)
{
if
(
$entry
!=
'.'
&&
$entry
!=
'..'
)
{
$empty
=
false
;
break
;
}
}
closedir
(
$dirres
);
}
if
(
$empty
==
true
)
{
rmdir
(
$homedir
);
}
unset
(
$files
);
unset
(
$dirs
);
$app
->
system
->
web_folder_protection
(
$web
[
'document_root'
],
true
);
}
}
}
// end class
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment