Skip to content

Commit 8eafcef

Browse files
committed
- Fixed moving of site when the client is changed.
- FS#501 - disable shell account untill jailkit is finished
1 parent a89eb2f commit 8eafcef

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

interface/lib/classes/tform_actions.inc.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ function onSubmit() {
8080

8181
// Calling the action functions
8282
if($this->id > 0) {
83-
$this->onUpdate();
83+
$app->tform->action == 'EDIT';
84+
$this->onUpdate();
8485
} else {
85-
$this->onInsert();
86+
$app->tform->action == 'NEW';
87+
$this->onInsert();
8688
}
8789
}
8890

interface/lib/classes/validate_client.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class validate_client {
3636
function username_unique($field_name, $field_value, $validator) {
3737
global $app;
3838

39-
if($app->tform->action == 'NEW') {
39+
if($app->tform->primary_id == 0) {
4040
$num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."'");
4141
if($num_rec["number"] > 0) {
4242
$errmsg = $validator['errmsg'];

server/plugins-available/apache2_plugin.inc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,15 @@ function update($event_name,$data) {
233233
return 0;
234234
}
235235

236+
//* If the client of the site has been changed, we have a change of the document root
236237
if($this->action == 'update' && $data["new"]["document_root"] != $data["old"]["document_root"]) {
237238

238-
// Get the old client ID
239+
//* Get the old client ID
239240
$old_client = $app->dbmaster->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["old"]["sys_groupid"]));
240241
$old_client_id = intval($old_client["client_id"]);
241242
unset($old_client);
242243

243-
// Remove the old symlinks
244+
//* Remove the old symlinks
244245
$tmp_symlinks_array = explode(':',$web_config["website_symlinks"]);
245246
if(is_array($tmp_symlinks_array)) {
246247
foreach($tmp_symlinks_array as $tmp_symlink) {
@@ -256,6 +257,7 @@ function update($event_name,$data) {
256257
}
257258
}
258259

260+
//* Move the site data
259261
$tmp_docroot = explode('/',$data["new"]["document_root"]);
260262
unset($tmp_docroot[count($tmp_docroot)-1]);
261263
$new_dir = implode('/',$tmp_docroot);
@@ -269,8 +271,10 @@ function update($event_name,$data) {
269271
exec('mv '.$data["old"]["document_root"].' '.$new_dir);
270272
$app->log("Moving site to new document root: ".'mv '.$data["old"]["document_root"].' '.$new_dir,LOGLEVEL_DEBUG);
271273

274+
//* Change the home directory and group of the website user
272275
$command = 'usermod';
273276
$command .= ' --home '.escapeshellcmd($data["new"]["document_root"]);
277+
$command .= ' --gid '.escapeshellcmd($data['new']['system_group']);
274278
$command .= ' '.escapeshellcmd($data["new"]["system_user"]);
275279
exec($command);
276280

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ function insert($event_name,$data) {
8787

8888
exec($command);
8989
$app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG);
90+
91+
//* Disable shell user temporarily if we use jailkit
92+
if($data['new']['chroot'] == 'jailkit') {
93+
$command = 'usermod --lock '.escapeshellcmd($data['new']['username']);
94+
exec($command);
95+
$app->log("Disabling shelluser temporarily: ".$data['new']['username'],LOGLEVEL_DEBUG);
96+
}
9097

9198
} else {
9299
$app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR);

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ function insert($event_name,$data) {
8686
$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
8787

8888
$this->_setup_jailkit_chroot();
89+
90+
$command .= 'usermod --unlock '.escapeshellcmd($data['new']['username']);
91+
exec($command);
92+
8993
$this->_add_jailkit_user();
9094
}
9195

0 commit comments

Comments
 (0)