Commit 4132c6b6 authored by tbrehm's avatar tbrehm
Browse files

Improved ssh user and apache plugin.

parent 026b48f8
......@@ -257,8 +257,8 @@ $form["tabs"]['ssl'] = array (
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
'width' => '2',
'maxlength' => '2'
),
'ssl_request' => array (
'datatype' => 'TEXT',
......
<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>&nbsp;
<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
......@@ -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>&nbsp;
<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
......@@ -67,6 +67,7 @@ class web_module {
*/
$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');
......
......@@ -98,19 +98,19 @@ class apache2_plugin {
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 @@ class apache2_plugin {
$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 @@ class apache2_plugin {
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 @@ class apache2_plugin {
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 @@ class apache2_plugin {
$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 @@ class apache2_plugin {
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);
}
}
......
......@@ -28,10 +28,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
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 @@ class apache2_plugin {
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');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment