From 4132c6b6a32adb508144532dcfa5e650f144bf53 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Tue, 23 Oct 2007 15:02:19 -0400 Subject: [PATCH] Improved ssh user and apache plugin. --- interface/web/sites/templates/web_domain_ssl.htm | 6 +- server/plugins-enabled/apache2_plugin.inc.php | 46 ++++++++-------------- interface/web/sites/templates/shell_user_advanced.htm | 8 ++-- server/plugins-enabled/shelluser_plugin.inc.php | 12 +++--- server/mods-enabled/web_module.inc.php | 1 interface/web/sites/form/web_domain.tform.php | 4 +- 6 files changed, 33 insertions(+), 44 deletions(-) diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php index 0ab593b..6f713d9 100644 --- a/interface/web/sites/form/web_domain.tform.php +++ b/interface/web/sites/form/web_domain.tform.php @@ -257,8 +257,8 @@ 'formtype' => 'TEXT', 'default' => '', 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'width' => '2', + 'maxlength' => '2' ), 'ssl_request' => array ( 'datatype' => 'TEXT', diff --git a/interface/web/sites/templates/shell_user_advanced.htm b/interface/web/sites/templates/shell_user_advanced.htm index 3ae6d4f..b7ebc54 100644 --- a/interface/web/sites/templates/shell_user_advanced.htm +++ b/interface/web/sites/templates/shell_user_advanced.htm @@ -1,11 +1,11 @@ <table width="500" border="0" cellspacing="0" cellpadding="2"> <tr> <td class="frmText11">{tmpl_var name='uid_txt'}:</td> - <td class="frmText11"><input name="uid" type="text" class="text" value="{tmpl_var name='uid'}" size="30" maxlength="255"></td> + <td class="frmText11"><input name="puser" type="text" class="text" value="{tmpl_var name='puser'}" size="30" maxlength="255"></td> </tr> <tr> <td class="frmText11">{tmpl_var name='gid_txt'}:</td> - <td class="frmText11"><input name="gid" type="text" class="text" value="{tmpl_var name='gid'}" size="30" maxlength="255"></td> + <td class="frmText11"><input name="pgroup" type="text" class="text" value="{tmpl_var name='pgroup'}" size="30" maxlength="255"></td> </tr> <tr> <td class="frmText11">{tmpl_var name='shell_txt'}:</td> @@ -23,6 +23,6 @@ <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','sites/shell_user_edit.php');"><div class="buttonEnding"></div> <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('sites/shell_user_list.php');"><div class="buttonEnding"></div> </td> - </tr> -</table> + </tr> +</table> <input type="hidden" name="id" value="{tmpl_var name='id'}"> \ No newline at end of file diff --git a/interface/web/sites/templates/web_domain_ssl.htm b/interface/web/sites/templates/web_domain_ssl.htm index eb22310..c3f2b45 100644 --- a/interface/web/sites/templates/web_domain_ssl.htm +++ b/interface/web/sites/templates/web_domain_ssl.htm @@ -17,7 +17,7 @@ </tr> <tr> <td class="frmText11">{tmpl_var name='ssl_country_txt'}:</td> - <td class="frmText11"><input name="ssl_country" type="text" class="text" value="{tmpl_var name='ssl_country'}" size="30" maxlength="255"></td> + <td class="frmText11"><input name="ssl_country" type="text" class="text" value="{tmpl_var name='ssl_country'}" size="2" maxlength="2"></td> </tr> <tr> <td class="frmText11">{tmpl_var name='ssl_request_txt'}:</td> @@ -47,6 +47,6 @@ <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','sites/web_domain_edit.php');"><div class="buttonEnding"></div> <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('sites/web_domain_list.php');"><div class="buttonEnding"></div> </td> - </tr> -</table> + </tr> +</table> <input type="hidden" name="id" value="{tmpl_var name='id'}"> \ No newline at end of file diff --git a/server/mods-enabled/web_module.inc.php b/server/mods-enabled/web_module.inc.php index 1b4c8b8..7ebed3a 100644 --- a/server/mods-enabled/web_module.inc.php +++ b/server/mods-enabled/web_module.inc.php @@ -67,6 +67,7 @@ */ $app->modules->registerTableHook('web_domain','web_module','process'); + $app->modules->registerTableHook('shell_user','web_module','process'); // Register service $app->services->registerService('httpd','web_module','restartHttpd'); diff --git a/server/plugins-enabled/apache2_plugin.inc.php b/server/plugins-enabled/apache2_plugin.inc.php index d593fc7..a167014 100644 --- a/server/plugins-enabled/apache2_plugin.inc.php +++ b/server/plugins-enabled/apache2_plugin.inc.php @@ -98,19 +98,19 @@ output_password = $ssl_password [ req_distinguished_name ] - C = $data[new][ssl_country] - ST = $data[new][ssl_state] - L = $data[new][ssl_locality] - O = $data[new][ssl_organisation] - OU = $data[new][ssl_organisation_unit] + C = ".$data['new']['ssl_country']." + ST = ".$data['new']['ssl_state']." + L = ".$data['new']['ssl_locality']." + O = ".$data['new']['ssl_organisation']." + OU = ".$data['new']['ssl_organisation_unit']." CN = $domain - emailAddress = webmatser@$data[new][domain] + emailAddress = webmatser@".$data['new']['domain']." [ req_attributes ] challengePassword = A challenge password"; $ssl_cnf_file = $ssl_dir."/openssl.conf"; - file_get_contents($ssl_cnf_file,$ssl_cnf); + file_put_contents($ssl_cnf_file,$ssl_cnf); $rand_file = escapeshellcmd($rand_file); $key_file = escapeshellcmd($key_file); @@ -118,34 +118,20 @@ $ssl_days = 3650; $csr_file = escapeshellcmd($csr_file); $config_file = escapeshellcmd($ssl_cnf_file); - $crt_file escapeshellcmd($crt_file); + $crt_file = escapeshellcmd($crt_file); if(is_file($ssl_cnf_file)){ - exec("openssl genrsa -des3 -rand $rand_file \ - -passout pass:$ssl_password \ - -out $key_file 1024 \ - && openssl req -new -passin pass:$ssl_password \ - -passout pass:$ssl_password -key $key_file \ - -out $csr_file -days $ssl_days \ - -config $config_file \ - && openssl req -x509 -passin pass:$ssl_password \ - -passout pass:$ssl_password \ - -key $key_file -in $csr_file \ - -out $crt_file -days $ssl_days \ - -config $config_file \ - && openssl rsa -passin pass:$ssl_password \ - -in $key_file \ - -out $key_file2"); - + exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 1024 && openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file && openssl req -x509 -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -in $csr_file -out $crt_file -days $ssl_days -config $config_file && openssl rsa -passin pass:$ssl_password -in $key_file -out $key_file2"); $app->log("Creating SSL Cert for: $domain",LOGLEVEL_DEBUG); } exec("chmod 400 $key_file2"); - unlink($config_file); - unlink($rand_file); + @unlink($config_file); + @unlink($rand_file); $ssl_request = file_get_contents($csr_file); $ssl_cert = file_get_contents($crt_file); - $mod->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'"); + $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); } //* Save a SSL certificate to disk @@ -158,6 +144,7 @@ file_put_contents($csr_file,$data["new"]["ssl_request"]); file_put_contents($crt_file,$data["new"]["ssl_cert"]); if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($bundle_file,$data["new"]["ssl_bundle"]); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); $app->log("Saving SSL Cert for: $domain",LOGLEVEL_DEBUG); } @@ -171,6 +158,7 @@ unlink($csr_file); unlink($crt_file); unlink($bundle_file); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); $app->log("Deleting SSL Cert for: $domain",LOGLEVEL_DEBUG); } @@ -298,7 +286,7 @@ $crt_file = $ssl_dir.'/'.$domain.".crt"; $bundle_file = $ssl_dir.'/'.$domain.".bundle"; - if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file) { + if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file)) { $vhost_data["ssl_enabled"] = 1; $app->log("Enable SSL for: $domain",LOGLEVEL_DEBUG); } else { @@ -398,7 +386,7 @@ if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); // create the symlinks, if not exist if(is_link($tmp_symlink)) { - unlink($tmp_symlink)); + unlink($tmp_symlink); $app->log("Removing symlink: ".$tmp_symlink,LOGLEVEL_DEBUG); } } diff --git a/server/plugins-enabled/shelluser_plugin.inc.php b/server/plugins-enabled/shelluser_plugin.inc.php index b4967f8..9fa34aa 100644 --- a/server/plugins-enabled/shelluser_plugin.inc.php +++ b/server/plugins-enabled/shelluser_plugin.inc.php @@ -28,10 +28,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -class apache2_plugin { +class shelluser_plugin { - var $plugin_name = 'apache2_plugin'; - var $class_name = 'apache2_plugin'; + var $plugin_name = 'shelluser_plugin'; + var $class_name = 'shelluser_plugin'; /* @@ -45,9 +45,9 @@ Register for the events */ - $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); - $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); - $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); + $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'); } -- Gitblit v1.9.1