Skip to content
Snippets Groups Projects
Commit 8216c5ee authored by Till Brehm's avatar Till Brehm
Browse files

Fixed: Issue #3820 v3.1 Shell user wrong default Base Dir in GUI results to...

Fixed: Issue #3820 v3.1 Shell user wrong default Base Dir in GUI results to corrupt shell user home directory creation.
parent c92a4ee4
No related branches found
No related tags found
No related merge requests found
......@@ -95,12 +95,6 @@ class page_action extends tform_actions {
} else {
$app->tpl->setVar("edit_disabled", 0);
}
if($this->dataRecord['chroot'] == 'jailkit'){
$app->tpl->setVar("is_jailkit", true);
} else {
$app->tpl->setVar("is_jailkit", false);
}
parent::onShowEnd();
}
......@@ -170,11 +164,7 @@ class page_action extends tform_actions {
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]);
$server_id = $app->functions->intval($web["server_id"]);
if($this->dataRecord['chroot'] == 'jailkit'){
$dir = $app->db->quote($web["document_root"]);
} else {
$dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
}
$dir = $web["document_root"];
$uid = $web["system_user"];
$gid = $web["system_group"];
......@@ -228,18 +218,7 @@ class page_action extends tform_actions {
function onAfterUpdate() {
global $app, $conf;
if(isset($this->dataRecord['chroot'])){
$shell_user = $app->db->queryOneRecord("SELECT * FROM shell_user WHERE shell_user_id = ".$this->id);
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
$dir = $shell_user['dir'];
if($this->dataRecord['chroot'] == 'jailkit'){
$dir = $app->db->quote($web["document_root"]);
} else {
if($this->oldDataRecord['chroot'] == 'jailkit') $dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
}
if($dir != $shell_user['dir']) $app->db->query("UPDATE shell_user SET dir = '$dir' WHERE shell_user_id = ".$this->id);
}
}
}
......
......@@ -113,16 +113,20 @@ class shelluser_base_plugin {
$homedir = $data['new']['dir'].'/home/'.$data['new']['username'];
}
// Create home base directory if it does not exist
if(!is_dir($data['new']['dir'].'/home')){
$app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0750');
$app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['puser']));
$app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['pgroup']));
$app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0755');
}
// Change ownership of home base dir to root user
$app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),'root');
$app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),'root');
$app->system->chmod(escapeshellcmd($data['new']['dir'].'/home'),0755);
if(!is_dir($homedir)){
$app->file->mkdirs(escapeshellcmd($homedir), '0750');
$app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['puser']));
$app->system->chgrp(escapeshellcmd($homedir),escapeshellcmd($data['new']['pgroup']));
$app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['puser']),false);
$app->system->chgrp(escapeshellcmd($homedir),escapeshellcmd($data['new']['pgroup']),false);
}
$command = 'useradd';
$command .= ' -d '.escapeshellcmd($homedir);
......@@ -137,8 +141,8 @@ class shelluser_base_plugin {
$app->log("Executed command: ".$command, LOGLEVEL_DEBUG);
$app->log("Added shelluser: ".$data['new']['username'], LOGLEVEL_DEBUG);
$app->system->chown(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['username']));
$app->system->chgrp(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['pgroup']));
$app->system->chown(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['username']),false);
$app->system->chgrp(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['pgroup']),false);
// call the ssh-rsa update function
......@@ -149,7 +153,7 @@ class shelluser_base_plugin {
//* Create .bash_history file
$app->system->touch(escapeshellcmd($homedir).'/.bash_history');
$app->system->chmod(escapeshellcmd($homedir).'/.bash_history', 0755);
$app->system->chmod(escapeshellcmd($homedir).'/.bash_history', 0750);
$app->system->chown(escapeshellcmd($homedir).'/.bash_history', $data['new']['username']);
$app->system->chgrp(escapeshellcmd($homedir).'/.bash_history', $data['new']['pgroup']);
......@@ -249,17 +253,17 @@ class shelluser_base_plugin {
$app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['puser']));
$app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['pgroup']));
}
$app->file->mkdirs(escapeshellcmd($homedir), '0750');
$app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['puser']));
$app->system->chgrp(escapeshellcmd($homedir),escapeshellcmd($data['new']['pgroup']));
$app->file->mkdirs(escapeshellcmd($homedir), '0755');
$app->system->chown(escapeshellcmd($homedir),'root');
$app->system->chgrp(escapeshellcmd($homedir),'root');
$app->system->web_folder_protection($web['document_root'], true);
} else {
if(!is_dir($homedir)){
$app->system->web_folder_protection($web['document_root'], false);
if(!is_dir($data['new']['dir'].'/home')){
$app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0750');
$app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['puser']));
$app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['pgroup']));
$app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0755');
$app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),'root');
$app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),'root');
}
$app->file->mkdirs(escapeshellcmd($homedir), '0750');
$app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['puser']));
......@@ -279,7 +283,7 @@ class shelluser_base_plugin {
//* Create .bash_history file
if(!is_file($data['new']['dir']).'/.bash_history') {
$app->system->touch(escapeshellcmd($homedir).'/.bash_history');
$app->system->chmod(escapeshellcmd($homedir).'/.bash_history', 0755);
$app->system->chmod(escapeshellcmd($homedir).'/.bash_history', 0750);
$app->system->chown(escapeshellcmd($homedir).'/.bash_history', escapeshellcmd($data['new']['username']));
$app->system->chgrp(escapeshellcmd($homedir).'/.bash_history', escapeshellcmd($data['new']['pgroup']));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment