Skip to content

Commit a713050

Browse files
author
Marius Burkard
committed
- Merged some foreign fixes
1 parent ee60c95 commit a713050

File tree

6 files changed

+57
-21
lines changed

6 files changed

+57
-21
lines changed

interface/web/client/form/reseller.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
'errmsg'=> 'email_error_empty'),
336336
),
337337
'validators' => array ( 0 => array ( 'type' => 'REGEX',
338-
'regex' => '/^\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}$/i',
338+
'regex' => '/^\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-zA-Z0-9\-]{2,30}$/i',
339339
'errmsg'=> 'email_error_isemail'),
340340
),
341341
'default' => '',

interface/web/sites/shell_user_edit.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ function onShowEnd() {
9595
} else {
9696
$app->tpl->setVar("edit_disabled", 0);
9797
}
98+
99+
if($this->dataRecord['chroot'] == 'jailkit'){
100+
$app->tpl->setVar("is_jailkit", true);
101+
} else {
102+
$app->tpl->setVar("is_jailkit", false);
103+
}
98104

99105
parent::onShowEnd();
100106
}
@@ -164,7 +170,11 @@ function onAfterInsert() {
164170
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]);
165171

166172
$server_id = $app->functions->intval($web["server_id"]);
167-
$dir = $web["document_root"];
173+
if($this->dataRecord['chroot'] == 'jailkit'){
174+
$dir = $app->db->quote($web["document_root"]);
175+
} else {
176+
$dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
177+
}
168178
$uid = $web["system_user"];
169179
$gid = $web["system_group"];
170180

@@ -218,7 +228,18 @@ function onBeforeUpdate() {
218228
function onAfterUpdate() {
219229
global $app, $conf;
220230

231+
if(isset($this->dataRecord['chroot'])){
232+
$shell_user = $app->db->queryOneRecord("SELECT * FROM shell_user WHERE shell_user_id = ".$this->id);
233+
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
234+
$dir = $shell_user['dir'];
235+
if($this->dataRecord['chroot'] == 'jailkit'){
236+
$dir = $app->db->quote($web["document_root"]);
237+
} else {
238+
if($this->oldDataRecord['chroot'] == 'jailkit') $dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
239+
}
221240

241+
if($dir != $shell_user['dir']) $app->db->query("UPDATE shell_user SET dir = '$dir' WHERE shell_user_id = ".$this->id);
242+
}
222243
}
223244

224245
}

interface/web/sites/templates/shell_user_advanced.htm

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ <h1><tmpl_var name="list_head_txt"></h1>
33
</div>
44
<p><tmpl_var name="list_desc_txt"></p>
55

6-
7-
8-
<div class="form-group">
9-
<label for="puser" class="col-sm-3 control-label">{tmpl_var name='puser_txt'}</label>
10-
<div class="col-sm-9"><input type="text" name="puser" id="puser" value="{tmpl_var name='puser'}" class="form-control" /></div></div>
11-
<div class="form-group">
12-
<label for="pgroup" class="col-sm-3 control-label">{tmpl_var name='pgroup_txt'}</label>
13-
<div class="col-sm-9"><input type="text" name="pgroup" id="pgroup" value="{tmpl_var name='pgroup'}" class="form-control" /></div></div>
14-
<div class="form-group">
15-
<label for="shell" class="col-sm-3 control-label">{tmpl_var name='shell_txt'}</label>
16-
<div class="col-sm-9"><input type="text" name="shell" id="shell" value="{tmpl_var name='shell'}" class="form-control" /></div></div>
17-
<div class="form-group">
18-
<label for="dir" class="col-sm-3 control-label">{tmpl_var name='dir_txt'}</label>
19-
<div class="col-sm-9"><input type="text" name="dir" id="dir" value="{tmpl_var name='dir'}" class="form-control" /></div></div>
20-
6+
<div class="form-group">
7+
<label for="puser" class="col-sm-3 control-label">{tmpl_var name='puser_txt'}</label>
8+
<div class="col-sm-9"><input type="text" name="puser" id="puser" value="{tmpl_var name='puser'}" class="form-control" /></div>
9+
</div>
10+
<div class="form-group">
11+
<label for="pgroup" class="col-sm-3 control-label">{tmpl_var name='pgroup_txt'}</label>
12+
<div class="col-sm-9"><input type="text" name="pgroup" id="pgroup" value="{tmpl_var name='pgroup'}" class="form-control" /></div>
13+
</div>
14+
<div class="form-group">
15+
<label for="shell" class="col-sm-3 control-label">{tmpl_var name='shell_txt'}</label>
16+
<div class="col-sm-9"><input type="text" name="shell" id="shell" value="{tmpl_var name='shell'}" class="form-control" /></div>
17+
</div>
18+
<tmpl_if name="is_jailkit">
19+
<input type="hidden" name="dir" id="dir" value="{tmpl_var name='dir'}">
20+
</tmpl_else>
21+
<div class="form-group">
22+
<label for="dir" class="col-sm-3 control-label">{tmpl_var name='dir_txt'}</label>
23+
<div class="col-sm-9"><input type="text" name="dir" id="dir" value="{tmpl_var name='dir'}" class="form-control" /></div>
24+
</div>
25+
</tmpl_if>
26+
2127

2228
<input type="hidden" name="id" value="{tmpl_var name='id'}">
2329

server/plugins-available/nginx_plugin.inc.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,13 +2985,15 @@ private function nginx_merge_locations($vhost_conf){
29852985
} else {
29862986

29872987
if($islocation){
2988-
if(strpos($l, '{') !== false){
2988+
$openingbracketpos = strrpos($l, '{');
2989+
if($openingbracketpos !== false){
29892990
$level += 1;
29902991
}
2991-
if(strpos($l, '}') !== false && $level > 0){
2992+
$closingbracketpos = strrpos($l, '}');
2993+
if($closingbracketpos !== false && $level > 0 && $closingbracketpos >= intval($openingbracketpos)){
29922994
$level -= 1;
29932995
$locations[$location]['location'] .= $lines[$i]."\n";
2994-
} elseif(strpos($l, '}') !== false && $level == 0){
2996+
} elseif($closingbracketpos !== false && $level == 0 && $closingbracketpos >= intval($openingbracketpos)){
29952997
$islocation = false;
29962998
} else {
29972999
$locations[$location]['location'] .= $lines[$i]."\n";

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ function insert($event_name, $data) {
136136
exec($command);
137137
$app->log("Executed command: ".$command, LOGLEVEL_DEBUG);
138138
$app->log("Added shelluser: ".$data['new']['username'], LOGLEVEL_DEBUG);
139+
140+
$app->system->chown(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['username']));
141+
$app->system->chgrp(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['pgroup']));
142+
139143

140144
// call the ssh-rsa update function
141145
$app->uses("getconf");

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,10 @@ function _add_jailkit_user()
386386
}
387387
}*/
388388

389-
$app->system->usermod($this->data['new']['username'], 0, 0, $this->data['new']['dir'].'/.'.$jailkit_chroot_userhome, '/usr/sbin/jk_chrootsh');
389+
$shell = '/usr/sbin/jk_chrootsh';
390+
if($this->data['new']['active'] != 'y') $shell = '/bin/false';
391+
392+
$app->system->usermod($this->data['new']['username'], 0, 0, $this->data['new']['dir'].'/.'.$jailkit_chroot_userhome, $shell);
390393
$app->system->usermod($this->data['new']['puser'], 0, 0, $this->data['new']['dir'].'/.'.$jailkit_chroot_userhome, '/usr/sbin/jk_chrootsh');
391394

392395
$this->app->log("Added jailkit user to chroot with command: ".$command, LOGLEVEL_DEBUG);

0 commit comments

Comments
 (0)