From 56a9084dd2f9a5726a74e1e789773558fade8b44 Mon Sep 17 00:00:00 2001
From: Christoph Wurst <christoph@winzerhof-wurst.at>
Date: Tue, 9 May 2017 08:45:36 +0200
Subject: [PATCH] Do not list system users in contacts menu if sharing
 autocompletion is disabled

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
---
 apps/dav/appinfo/app.php | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/apps/dav/appinfo/app.php b/apps/dav/appinfo/app.php
index 0d417fd3fed..963073c4413 100644
--- a/apps/dav/appinfo/app.php
+++ b/apps/dav/appinfo/app.php
@@ -50,7 +50,13 @@ $eventDispatcher->addListener('OCP\Federation\TrustedServerEvent::remove',
 $cm = \OC::$server->getContactsManager();
 $cm->register(function() use ($cm, $app) {
 	$user = \OC::$server->getUserSession()->getUser();
-	if (!is_null($user)) {
-		$app->setupContactsProvider($cm, $user->getUID());
+	if (is_null($user)) {
+		return;
 	}
+	if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes') {
+		// Don't include system users
+		// This prevents user enumeration in the contacts menu and the mail app
+		return;
+	}
+	$app->setupContactsProvider($cm, $user->getUID());
 });
-- 
GitLab