@@ -443,7 +443,7 @@ function update($event_name,$data) {
443443
444444 $ username = escapeshellcmd ($ data ["new " ]["system_user " ]);
445445 if ($ data ["new " ]["system_user " ] != '' && !$ app ->system ->is_user ($ data ["new " ]["system_user " ])) {
446- exec ("useradd -d " .escapeshellcmd ($ data ["new " ]["document_root " ])." -g $ groupname $ username -s /bin/false " );
446+ exec ("useradd -d " .escapeshellcmd ($ data ["new " ]["document_root " ])." -g $ groupname -G sshusers $ username -s /bin/false " );
447447 $ app ->log ("Adding the user: $ username " ,LOGLEVEL_DEBUG );
448448 }
449449
@@ -459,7 +459,6 @@ function update($event_name,$data) {
459459 exec ("setquota -T -u $ username 604800 604800 -a &> /dev/null " );
460460 }
461461
462-
463462 if ($ this ->action == 'insert ' ) {
464463 // Chown and chmod the directories below the document root
465464 exec ("chown -R $ username: $ groupname " .escapeshellcmd ($ data ["new " ]["document_root " ]));
@@ -468,8 +467,40 @@ function update($event_name,$data) {
468467 exec ("chown root:root " .escapeshellcmd ($ data ["new " ]["document_root " ]));
469468 }
470469
471- // make temp direcory writable for the apache user and the website user
472- exec ("chmod 777 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/tmp " ));
470+
471+
472+ // If the security level is set to high
473+ if ($ web_config ['security_level ' ] == 20 ) {
474+
475+ exec ("chmod 711 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/ " ));
476+ exec ("chmod 711 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/* " ));
477+ exec ("chmod 710 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/web " ));
478+
479+ //* Change the home directory and group of the website user
480+ $ command = 'usermod ' ;
481+ $ command .= ' --groups sshusers, ' .escapeshellcmd ($ web_config ['group ' ]);
482+ $ command .= ' ' .escapeshellcmd ($ data ["new " ]["system_user " ]);
483+ exec ($ command );
484+ $ app ->log ("Modifying user: $ command " ,LOGLEVEL_DEBUG );
485+
486+ // make temp direcory writable for the apache user and the website user
487+ // exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
488+ // If the security Level is set to medium
489+ } else {
490+
491+ exec ("chmod 755 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/ " ));
492+ exec ("chmod 755 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/* " ));
493+
494+ //* Change the home directory and group of the website user
495+ $ command = 'usermod ' ;
496+ $ command .= ' --groups sshusers ' ;
497+ $ command .= ' ' .escapeshellcmd ($ data ["new " ]["system_user " ]);
498+ exec ($ command );
499+ $ app ->log ("Modifying user: $ command " ,LOGLEVEL_DEBUG );
500+
501+ // make temp direcory writable for the apache user and the website user
502+ exec ("chmod 777 " .escapeshellcmd ($ data ["new " ]["document_root " ]."/tmp " ));
503+ }
473504
474505
475506 // Create the vhost config file
@@ -482,6 +513,7 @@ function update($event_name,$data) {
482513 $ vhost_data ["web_document_root " ] = $ data ["new " ]["document_root " ]."/web " ;
483514 $ vhost_data ["web_document_root_www " ] = $ web_config ["website_basedir " ]."/ " .$ data ["new " ]["domain " ]."/web " ;
484515 $ vhost_data ["web_basedir " ] = $ web_config ["website_basedir " ];
516+ $ vhost_data ["security_level " ] = $ web_config ["security_level " ];
485517
486518 // Check if a SSL cert exists
487519 $ ssl_dir = $ data ["new " ]["document_root " ]."/ssl " ;
0 commit comments