@@ -85,6 +85,8 @@ function insert($event_name,$data) {
8585 return 0 ;
8686 }
8787
88+ $ this ->parent_domain = $ parent_domain ;
89+
8890 $ app ->uses ('system ' );
8991
9092 if ($ app ->system ->is_user ($ parent_domain ['system_user ' ])) {
@@ -95,6 +97,7 @@ function insert($event_name,$data) {
9597 if ($ data ['new ' ]['type ' ] == "chrooted " )
9698 {
9799 // load the server configuration options
100+ /*
98101 $app->uses("getconf");
99102 $this->data = $data;
100103 $this->app = $app;
@@ -107,6 +110,22 @@ function insert($event_name,$data) {
107110 //exec($command);
108111
109112 $this->_add_jailkit_user();
113+ */
114+ $ app ->uses ("getconf " );
115+ $ this ->data = $ data ;
116+ $ this ->app = $ app ;
117+ $ this ->jailkit_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'jailkit ' );
118+
119+ $ this ->_update_website_security_level ();
120+
121+ $ this ->_setup_jailkit_chroot ();
122+
123+ $ this ->_add_jailkit_user ();
124+
125+ $ command .= 'usermod -U ' .escapeshellcmd ($ parent_domain ["system_user " ]);
126+ exec ($ command );
127+
128+ $ this ->_update_website_security_level ();
110129 }
111130
112131 $ app ->log ("Jailkit Plugin (Cron) -> insert username: " .$ parent_domain ['system_user ' ],LOGLEVEL_DEBUG );
@@ -127,7 +146,6 @@ function update($event_name,$data) {
127146 }
128147 //* get data from web
129148 $ parent_domain = $ app ->db ->queryOneRecord ("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `domain` FROM `web_domain` WHERE `domain_id` = " .intval ($ data ["new " ]["parent_domain_id " ]));
130-
131149 if (!$ parent_domain ["domain_id " ]) {
132150 $ app ->log ("Parent domain not found " ,LOGLEVEL_WARN );
133151 return 0 ;
@@ -138,6 +156,8 @@ function update($event_name,$data) {
138156
139157 $ app ->uses ('system ' );
140158
159+ $ this ->parent_domain = $ parent_domain ;
160+
141161 if ($ app ->system ->is_user ($ parent_domain ['system_user ' ])) {
142162
143163 /**
@@ -147,6 +167,7 @@ function update($event_name,$data) {
147167 {
148168 $ app ->log ("Jailkit Plugin (Cron) -> setting up jail " , LOGLEVEL_DEBUG );
149169 // load the server configuration options
170+ /*
150171 $app->uses("getconf");
151172 $this->data = $data;
152173 $this->app = $app;
@@ -155,6 +176,18 @@ function update($event_name,$data) {
155176
156177 $this->_setup_jailkit_chroot();
157178 $this->_add_jailkit_user();
179+ */
180+ $ app ->uses ("getconf " );
181+ $ this ->data = $ data ;
182+ $ this ->app = $ app ;
183+ $ this ->jailkit_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'jailkit ' );
184+
185+ $ this ->_update_website_security_level ();
186+
187+ $ this ->_setup_jailkit_chroot ();
188+ $ this ->_add_jailkit_user ();
189+
190+ $ this ->_update_website_security_level ();
158191 }
159192
160193 $ app ->log ("Jailkit Plugin (Cron) -> update username: " .$ parent_domain ['system_user ' ],LOGLEVEL_DEBUG );
@@ -264,6 +297,29 @@ function _get_home_dir($username)
264297 {
265298 return str_replace ("[username] " ,escapeshellcmd ($ username ),$ this ->jailkit_config ["jailkit_chroot_home " ]);
266299 }
300+
301+ //* Update the website root directory permissions depending on the security level
302+ function _update_website_security_level () {
303+ global $ app ,$ conf ;
304+
305+ // load the server configuration options
306+ $ app ->uses ("getconf " );
307+ $ web_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'web ' );
308+
309+ //* If the security level is set to high
310+ if ($ web_config ['security_level ' ] == 20 ) {
311+ $ this ->_exec ("chmod 755 " .escapeshellcmd ($ this ->parent_domain ['document_root ' ]));
312+ $ this ->_exec ("chown root:root " .escapeshellcmd ($ this ->parent_domain ['document_root ' ]));
313+ }
314+
315+ }
316+
317+ //* Wrapper for exec function for easier debugging
318+ private function _exec ($ command ) {
319+ global $ app ;
320+ $ app ->log ("exec: " .$ command ,LOGLEVEL_DEBUG );
321+ exec ($ command );
322+ }
267323
268324
269325
0 commit comments