@@ -289,6 +289,23 @@ function update($event_name,$data) {
289289 $ app ->log ('Websites cannot be owned by the root user or group. ' ,LOGLEVEL_WARN );
290290 return 0 ;
291291 }
292+
293+ // Create group and user, if not exist
294+ $ app ->uses ('system ' );
295+
296+ $ groupname = escapeshellcmd ($ data ['new ' ]['system_group ' ]);
297+ if ($ data ['new ' ]['system_group ' ] != '' && !$ app ->system ->is_group ($ data ['new ' ]['system_group ' ])) {
298+ exec ('groupadd ' .$ groupname );
299+ if ($ apache_chrooted ) $ this ->_exec ('chroot ' .escapeshellcmd ($ web_config ['website_basedir ' ]).' groupadd ' .$ groupname );
300+ $ app ->log ('Adding the group: ' .$ groupname ,LOGLEVEL_DEBUG );
301+ }
302+
303+ $ username = escapeshellcmd ($ data ['new ' ]['system_user ' ]);
304+ if ($ data ['new ' ]['system_user ' ] != '' && !$ app ->system ->is_user ($ data ['new ' ]['system_user ' ])) {
305+ exec ('useradd -d ' .escapeshellcmd ($ data ['new ' ]['document_root ' ])." -g $ groupname -G sshusers $ username -s /bin/false " );
306+ if ($ apache_chrooted ) $ this ->_exec ('chroot ' .escapeshellcmd ($ web_config ['website_basedir ' ]).' useradd -d ' .escapeshellcmd ($ data ['new ' ]['document_root ' ])." -g $ groupname -G sshusers $ username -s /bin/false " );
307+ $ app ->log ('Adding the user: ' .$ username ,LOGLEVEL_DEBUG );
308+ }
292309
293310 //* If the client of the site has been changed, we have a change of the document root
294311 if ($ this ->action == 'update ' && $ data ['new ' ]['document_root ' ] != $ data ['old ' ]['document_root ' ]) {
@@ -511,23 +528,6 @@ function update($event_name,$data) {
511528 exec ('chown -R ' .$ data ['new ' ]['system_user ' ].': ' .$ data ['new ' ]['system_group ' ].' ' .$ error_page_path );
512529 } // end copy error docs
513530
514- // Create group and user, if not exist
515- $ app ->uses ('system ' );
516-
517- $ groupname = escapeshellcmd ($ data ['new ' ]['system_group ' ]);
518- if ($ data ['new ' ]['system_group ' ] != '' && !$ app ->system ->is_group ($ data ['new ' ]['system_group ' ])) {
519- exec ('groupadd ' .$ groupname );
520- if ($ apache_chrooted ) $ this ->_exec ('chroot ' .escapeshellcmd ($ web_config ['website_basedir ' ]).' groupadd ' .$ groupname );
521- $ app ->log ('Adding the group: ' .$ groupname ,LOGLEVEL_DEBUG );
522- }
523-
524- $ username = escapeshellcmd ($ data ['new ' ]['system_user ' ]);
525- if ($ data ['new ' ]['system_user ' ] != '' && !$ app ->system ->is_user ($ data ['new ' ]['system_user ' ])) {
526- exec ('useradd -d ' .escapeshellcmd ($ data ['new ' ]['document_root ' ])." -g $ groupname -G sshusers $ username -s /bin/false " );
527- if ($ apache_chrooted ) $ this ->_exec ('chroot ' .escapeshellcmd ($ web_config ['website_basedir ' ]).' useradd -d ' .escapeshellcmd ($ data ['new ' ]['document_root ' ])." -g $ groupname -G sshusers $ username -s /bin/false " );
528- $ app ->log ('Adding the user: ' .$ username ,LOGLEVEL_DEBUG );
529- }
530-
531531 // Set the quota for the user
532532 if ($ username != '' && $ app ->system ->is_user ($ username )) {
533533 if ($ data ['new ' ]['hd_quota ' ] > 0 ) {
0 commit comments