From 74ba4e9af03b0c2995039aaf8b4470872d38daeb Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 16 Dec 2008 11:45:54 -0500
Subject: [PATCH] Updated shell user scripts to be more fault tolerant.
---
server/plugins-available/shelluser_jailkit_plugin.inc.php | 78 ++++++++++++++++++++++++---------------
1 files changed, 48 insertions(+), 30 deletions(-)
diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
index db98da9..e1ca813 100755
--- a/server/plugins-available/shelluser_jailkit_plugin.inc.php
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -70,22 +70,30 @@
function insert($event_name,$data) {
global $app, $conf;
- /**
- * Setup Jailkit Chroot System If Enabled
- */
- if ($data['new']['chroot'] == "jailkit")
- {
- // load the server configuration options
- $app->uses("getconf");
- $this->data = $data;
- $this->app = $app;
- $this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
-
- $this->_setup_jailkit_chroot();
- $this->_add_jailkit_user();
- }
+ $app->uses('system');
- $app->log("Jalikit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
+ if($app->system->is_user($data['new']['username'])) {
+
+ /**
+ * Setup Jailkit Chroot System If Enabled
+ */
+ if ($data['new']['chroot'] == "jailkit")
+ {
+ // load the server configuration options
+ $app->uses("getconf");
+ $this->data = $data;
+ $this->app = $app;
+ $this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+
+ $this->_setup_jailkit_chroot();
+ $this->_add_jailkit_user();
+ }
+
+ $app->log("Jalikit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
+
+ } else {
+ $app->log("Jalikit Plugin -> insert username:".$data['new']['username']." skipped, the user does not exist.",LOGLEVEL_WARN);
+ }
}
@@ -93,22 +101,30 @@
function update($event_name,$data) {
global $app, $conf;
- /**
- * Setup Jailkit Chroot System If Enabled
- */
- if ($data['new']['chroot'] == "jailkit")
- {
- // load the server configuration options
- $app->uses("getconf");
- $this->data = $data;
- $this->app = $app;
- $this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
-
- $this->_setup_jailkit_chroot();
- $this->_add_jailkit_user();
- }
+ $app->uses('system');
- $app->log("Jalikit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
+ if($app->system->is_user($data['new']['username'])) {
+
+ /**
+ * Setup Jailkit Chroot System If Enabled
+ */
+ if ($data['new']['chroot'] == "jailkit")
+ {
+ // load the server configuration options
+ $app->uses("getconf");
+ $this->data = $data;
+ $this->app = $app;
+ $this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+
+ $this->_setup_jailkit_chroot();
+ $this->_add_jailkit_user();
+ }
+
+ $app->log("Jalikit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
+
+ } else {
+ $app->log("Jalikit Plugin -> update username:".$data['new']['username']." skipped, the user does not exist.",LOGLEVEL_WARN);
+ }
}
@@ -119,6 +135,8 @@
function delete($event_name,$data) {
global $app, $conf;
+ $app->uses('system');
+
if ($data['old']['chroot'] == "jailkit")
{
$app->uses("getconf");
--
Gitblit v1.9.1