From 9a10fb40f7e294e0ddf0386445d6e245ab816dea Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Tue, 28 Jan 2025 17:32:00 +0000
Subject: [PATCH] :sparkles: Feat(posix) - remove byHost wildcard

Removes wildcard when byHost is selected with one entry.
---
 posix/personal/posix/class_posixAccount.inc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/posix/personal/posix/class_posixAccount.inc b/posix/personal/posix/class_posixAccount.inc
index 491178ff5d..184363724e 100644
--- a/posix/personal/posix/class_posixAccount.inc
+++ b/posix/personal/posix/class_posixAccount.inc
@@ -199,6 +199,7 @@ class posixAccount extends simplePlugin
         ]
       ]
     );
+
     if ((count($this->host) == 1) && ($this->host[0] == '*')) {
       $this->trustMode = 'fullaccess';
     } elseif (count($this->host) > 0) {
@@ -402,6 +403,13 @@ class posixAccount extends simplePlugin
   {
     global $config;
 
+    // Remove the '*' entry from the host array if multiple elements exist
+    if (in_array('*', $this->host) && count($this->host) > 1) {
+      $this->host = array_filter($this->host, function($item) {
+        return $item !== '*';
+      });
+    }
+
     /* Fill gecos */
     if (isset($this->parent) && $this->parent !== NULL) {
       $this->gecos = rewrite($this->parent->getBaseObject()->cn);
-- 
GitLab