Skip to content

Commit 4132c6b

Browse files
committed
Improved ssh user and apache plugin.
1 parent 026b48f commit 4132c6b

File tree

6 files changed

+33
-44
lines changed

6 files changed

+33
-44
lines changed

interface/web/sites/form/web_domain.tform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@
257257
'formtype' => 'TEXT',
258258
'default' => '',
259259
'value' => '',
260-
'width' => '30',
261-
'maxlength' => '255'
260+
'width' => '2',
261+
'maxlength' => '2'
262262
),
263263
'ssl_request' => array (
264264
'datatype' => 'TEXT',

interface/web/sites/templates/shell_user_advanced.htm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<table width="500" border="0" cellspacing="0" cellpadding="2">
22
<tr>
33
<td class="frmText11">{tmpl_var name='uid_txt'}:</td>
4-
<td class="frmText11"><input name="uid" type="text" class="text" value="{tmpl_var name='uid'}" size="30" maxlength="255"></td>
4+
<td class="frmText11"><input name="puser" type="text" class="text" value="{tmpl_var name='puser'}" size="30" maxlength="255"></td>
55
</tr>
66
<tr>
77
<td class="frmText11">{tmpl_var name='gid_txt'}:</td>
8-
<td class="frmText11"><input name="gid" type="text" class="text" value="{tmpl_var name='gid'}" size="30" maxlength="255"></td>
8+
<td class="frmText11"><input name="pgroup" type="text" class="text" value="{tmpl_var name='pgroup'}" size="30" maxlength="255"></td>
99
</tr>
1010
<tr>
1111
<td class="frmText11">{tmpl_var name='shell_txt'}:</td>
@@ -23,6 +23,6 @@
2323
<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;
2424
<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>
2525
</td>
26-
</tr>
27-
</table>
26+
</tr>
27+
</table>
2828
<input type="hidden" name="id" value="{tmpl_var name='id'}">

interface/web/sites/templates/web_domain_ssl.htm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</tr>
1818
<tr>
1919
<td class="frmText11">{tmpl_var name='ssl_country_txt'}:</td>
20-
<td class="frmText11"><input name="ssl_country" type="text" class="text" value="{tmpl_var name='ssl_country'}" size="30" maxlength="255"></td>
20+
<td class="frmText11"><input name="ssl_country" type="text" class="text" value="{tmpl_var name='ssl_country'}" size="2" maxlength="2"></td>
2121
</tr>
2222
<tr>
2323
<td class="frmText11">{tmpl_var name='ssl_request_txt'}:</td>
@@ -47,6 +47,6 @@
4747
<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;
4848
<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>
4949
</td>
50-
</tr>
51-
</table>
50+
</tr>
51+
</table>
5252
<input type="hidden" name="id" value="{tmpl_var name='id'}">

server/mods-enabled/web_module.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class that contains the function functionname.
6767
*/
6868

6969
$app->modules->registerTableHook('web_domain','web_module','process');
70+
$app->modules->registerTableHook('shell_user','web_module','process');
7071

7172
// Register service
7273
$app->services->registerService('httpd','web_module','restartHttpd');

server/plugins-enabled/apache2_plugin.inc.php

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,54 +98,40 @@ function ssl($event_name,$data) {
9898
output_password = $ssl_password
9999
100100
[ req_distinguished_name ]
101-
C = $data[new][ssl_country]
102-
ST = $data[new][ssl_state]
103-
L = $data[new][ssl_locality]
104-
O = $data[new][ssl_organisation]
105-
OU = $data[new][ssl_organisation_unit]
101+
C = ".$data['new']['ssl_country']."
102+
ST = ".$data['new']['ssl_state']."
103+
L = ".$data['new']['ssl_locality']."
104+
O = ".$data['new']['ssl_organisation']."
105+
OU = ".$data['new']['ssl_organisation_unit']."
106106
CN = $domain
107-
emailAddress = webmatser@$data[new][domain]
107+
emailAddress = webmatser@".$data['new']['domain']."
108108
109109
[ req_attributes ]
110110
challengePassword = A challenge password";
111111

112112
$ssl_cnf_file = $ssl_dir."/openssl.conf";
113-
file_get_contents($ssl_cnf_file,$ssl_cnf);
113+
file_put_contents($ssl_cnf_file,$ssl_cnf);
114114

115115
$rand_file = escapeshellcmd($rand_file);
116116
$key_file = escapeshellcmd($key_file);
117117
$key_file2 = escapeshellcmd($key_file2);
118118
$ssl_days = 3650;
119119
$csr_file = escapeshellcmd($csr_file);
120120
$config_file = escapeshellcmd($ssl_cnf_file);
121-
$crt_file escapeshellcmd($crt_file);
121+
$crt_file = escapeshellcmd($crt_file);
122122

123123
if(is_file($ssl_cnf_file)){
124-
exec("openssl genrsa -des3 -rand $rand_file \
125-
-passout pass:$ssl_password \
126-
-out $key_file 1024 \
127-
&& openssl req -new -passin pass:$ssl_password \
128-
-passout pass:$ssl_password -key $key_file \
129-
-out $csr_file -days $ssl_days \
130-
-config $config_file \
131-
&& openssl req -x509 -passin pass:$ssl_password \
132-
-passout pass:$ssl_password \
133-
-key $key_file -in $csr_file \
134-
-out $crt_file -days $ssl_days \
135-
-config $config_file \
136-
&& openssl rsa -passin pass:$ssl_password \
137-
-in $key_file \
138-
-out $key_file2");
139-
124+
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");
140125
$app->log("Creating SSL Cert for: $domain",LOGLEVEL_DEBUG);
141126
}
142127

143128
exec("chmod 400 $key_file2");
144-
unlink($config_file);
145-
unlink($rand_file);
129+
@unlink($config_file);
130+
@unlink($rand_file);
146131
$ssl_request = file_get_contents($csr_file);
147132
$ssl_cert = file_get_contents($crt_file);
148-
$mod->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'");
133+
$app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'");
134+
$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'");
149135
}
150136

151137
//* Save a SSL certificate to disk
@@ -158,6 +144,7 @@ function ssl($event_name,$data) {
158144
file_put_contents($csr_file,$data["new"]["ssl_request"]);
159145
file_put_contents($crt_file,$data["new"]["ssl_cert"]);
160146
if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($bundle_file,$data["new"]["ssl_bundle"]);
147+
$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'");
161148
$app->log("Saving SSL Cert for: $domain",LOGLEVEL_DEBUG);
162149
}
163150

@@ -171,6 +158,7 @@ function ssl($event_name,$data) {
171158
unlink($csr_file);
172159
unlink($crt_file);
173160
unlink($bundle_file);
161+
$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'");
174162
$app->log("Deleting SSL Cert for: $domain",LOGLEVEL_DEBUG);
175163
}
176164

@@ -298,7 +286,7 @@ function update($event_name,$data) {
298286
$crt_file = $ssl_dir.'/'.$domain.".crt";
299287
$bundle_file = $ssl_dir.'/'.$domain.".bundle";
300288

301-
if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file) {
289+
if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file)) {
302290
$vhost_data["ssl_enabled"] = 1;
303291
$app->log("Enable SSL for: $domain",LOGLEVEL_DEBUG);
304292
} else {
@@ -398,7 +386,7 @@ function delete($event_name,$data) {
398386
if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
399387
// create the symlinks, if not exist
400388
if(is_link($tmp_symlink)) {
401-
unlink($tmp_symlink));
389+
unlink($tmp_symlink);
402390
$app->log("Removing symlink: ".$tmp_symlink,LOGLEVEL_DEBUG);
403391
}
404392
}

server/plugins-enabled/shelluser_plugin.inc.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
class apache2_plugin {
31+
class shelluser_plugin {
3232

33-
var $plugin_name = 'apache2_plugin';
34-
var $class_name = 'apache2_plugin';
33+
var $plugin_name = 'shelluser_plugin';
34+
var $class_name = 'shelluser_plugin';
3535

3636

3737
/*
@@ -45,9 +45,9 @@ function onLoad() {
4545
Register for the events
4646
*/
4747

48-
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
49-
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
50-
$app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete');
48+
$app->plugins->registerEvent('shell_user_insert',$this->plugin_name,'insert');
49+
$app->plugins->registerEvent('shell_user_update',$this->plugin_name,'update');
50+
$app->plugins->registerEvent('shell_user_delete',$this->plugin_name,'delete');
5151

5252

5353
}

0 commit comments

Comments
 (0)