| | |
| | | /* |
| | | Register for the events |
| | | */ |
| | | |
| | | |
| | | $app->plugins->registerEvent('shell_user_insert', $this->plugin_name, 'insert'); |
| | | $app->plugins->registerEvent('shell_user_update', $this->plugin_name, 'update'); |
| | | $app->plugins->registerEvent('shell_user_delete', $this->plugin_name, 'delete'); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | function insert($event_name, $data) { |
| | | global $app, $conf; |
| | | |
| | | $app->uses('system'); |
| | | $app->uses('system,getconf'); |
| | | |
| | | $security_config = $app->getconf->get_security_config('permissions'); |
| | | if($security_config['allow_shell_user'] != 'yes') { |
| | | $app->log('Shell user plugin disabled by security settings.',LOGLEVEL_WARN); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['new']['parent_domain_id']); |
| | | |
| | | if(!$app->system->is_allowed_user($data['new']['username'], false, false) |
| | | || !$app->system->is_allowed_user($data['new']['puser'], true, true) |
| | | || !$app->system->is_allowed_group($data['new']['pgroup'], true, true)) { |
| | | $app->log('Shell user must not be root or in group root.',LOGLEVEL_WARN); |
| | | return false; |
| | | } |
| | | |
| | | if($app->system->is_user($data['new']['puser'])) { |
| | | // Get the UID of the parent user |
| | |
| | | function update($event_name, $data) { |
| | | global $app, $conf; |
| | | |
| | | $app->uses('system'); |
| | | $app->uses('system,getconf'); |
| | | |
| | | $security_config = $app->getconf->get_security_config('permissions'); |
| | | if($security_config['allow_shell_user'] != 'yes') { |
| | | $app->log('Shell user plugin disabled by security settings.',LOGLEVEL_WARN); |
| | | return false; |
| | | } |
| | | |
| | | $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['new']['parent_domain_id']); |
| | | |
| | | if(!$app->system->is_allowed_user($data['new']['username'], false, false) |
| | | || !$app->system->is_allowed_user($data['new']['puser'], true, true) |
| | | || !$app->system->is_allowed_group($data['new']['pgroup'], true, true)) { |
| | | $app->log('Shell user must not be root or in group root.',LOGLEVEL_WARN); |
| | | return false; |
| | | } |
| | | |
| | | if($app->system->is_user($data['new']['puser'])) { |
| | | // Get the UID of the parent user |
| | |
| | | function delete($event_name, $data) { |
| | | global $app, $conf; |
| | | |
| | | $app->uses('system'); |
| | | $app->uses('system,getconf'); |
| | | |
| | | $security_config = $app->getconf->get_security_config('permissions'); |
| | | if($security_config['allow_shell_user'] != 'yes') { |
| | | $app->log('Shell user plugin disabled by security settings.',LOGLEVEL_WARN); |
| | | return false; |
| | | } |
| | | |
| | | $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['old']['parent_domain_id']); |
| | | |
| | |
| | | $app->system->web_folder_protection($web['document_root'], false); |
| | | |
| | | if(@is_dir($data['old']['dir'].$jailkit_chroot_userhome)) { |
| | | $command = 'userdel -f'; |
| | | $command = 'killall -u '.escapeshellcmd($data['old']['username']).' ; userdel -f'; |
| | | $command .= ' '.escapeshellcmd($data['old']['username']).' &> /dev/null'; |
| | | exec($command); |
| | | $app->log("Jailkit Plugin -> delete chroot home:".$data['old']['dir'].$jailkit_chroot_userhome, LOGLEVEL_DEBUG); |