From 19b5e01da02aa2115ee802cf2e43a7f3e58f4eac Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Wed, 13 Aug 2014 13:28:03 -0400
Subject: [PATCH] Added function "is_superadmin" in auth library and improved other functions.

---
 server/lib/classes/system.inc.php |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php
index 049eb61..af42e5e 100644
--- a/server/lib/classes/system.inc.php
+++ b/server/lib/classes/system.inc.php
@@ -1821,7 +1821,11 @@
 	public function is_allowed_user($username, $check_id = true, $restrict_names = false) {
 		global $app;
 		
-		if($username == 'root') return false;
+		$name_blacklist = array('root','ispconfig','vmail','getmail');
+		if(in_array($username,$name_blacklist)) return false;
+		
+		if(preg_match('/^[a-zA-Z0-9\.\-_]{1,32}$/', $username) == false) return false;
+		
 		if($check_id && intval($this->getuid($username)) < $this->min_uid) return false;
 		
 		if($restrict_names == true && preg_match('/^web\d+$/', $username) == false) return false;
@@ -1829,11 +1833,15 @@
 		return true;
 	}
 	
-	public function is_allowed_group($groupname, $restrict_names = false) {
+	public function is_allowed_group($groupname, $check_id = true, $restrict_names = false) {
 		global $app;
 		
-		if($groupname == 'root') return false;
-		if(intval($this->getgid($groupname)) < $this->min_gid) return false;
+		$name_blacklist = array('root','ispconfig','vmail','getmail');
+		if(in_array($groupname,$name_blacklist)) return false;
+		
+		if(preg_match('/^[a-zA-Z0-9\.\-_]{1,32}$/', $groupname) == false) return false;
+		
+		if($check_id && intval($this->getgid($groupname)) < $this->min_gid) return false;
 		
 		if($restrict_names == true && preg_match('/^client\d+$/', $groupname) == false) return false;
 		

--
Gitblit v1.9.1