1524bc
From c50d91d16292a13d29b1125c0aa85c7a7963de5f Mon Sep 17 00:00:00 2001
1524bc
From: Andreas Schneider <asn@samba.org>
1524bc
Date: Mon, 27 Jan 2020 14:58:10 +0100
1524bc
Subject: [PATCH] lib:util: Log mkdir error on correct debug levels
1524bc
MIME-Version: 1.0
1524bc
Content-Type: text/plain; charset=UTF-8
1524bc
Content-Transfer-Encoding: 8bit
1524bc
1524bc
For smbd we want an error and for smbclient we only want it in NOTICE
1524bc
debug level.
1524bc
The default log level of smbclient is log level 1 so we need notice to
1524bc
not spam the user.
1524bc
1524bc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14253
1524bc
1524bc
Signed-off-by: Andreas Schneider <asn@samba.org>
1524bc
Reviewed-by: Guenther Deschner <gd@samba.org>
1524bc
1524bc
Autobuild-User(master): Günther Deschner <gd@samba.org>
1524bc
Autobuild-Date(master): Mon Jan 27 15:55:24 UTC 2020 on sn-devel-184
1524bc
1524bc
(cherry picked from commit 0ad6a243b259d284064c0c5abcc7d430d55be7e1)
1524bc
---
1524bc
 lib/util/util.c | 7 +++++--
1524bc
 1 file changed, 5 insertions(+), 2 deletions(-)
1524bc
1524bc
diff --git a/lib/util/util.c b/lib/util/util.c
1524bc
index 3bdeded5c1b..0d9ffe5cb7b 100644
1524bc
--- a/lib/util/util.c
1524bc
+++ b/lib/util/util.c
1524bc
@@ -353,9 +353,12 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname,
1524bc
 	old_umask = umask(0);
1524bc
 	ret = mkdir(dname, dir_perms);
1524bc
 	if (ret == -1 && errno != EEXIST) {
1524bc
-		DBG_WARNING("mkdir failed on directory %s: %s\n",
1524bc
+		int dbg_level = geteuid() == 0 ? DBGLVL_ERR : DBGLVL_NOTICE;
1524bc
+
1524bc
+		DBG_PREFIX(dbg_level,
1524bc
+			   ("mkdir failed on directory %s: %s\n",
1524bc
 			    dname,
1524bc
-			    strerror(errno));
1524bc
+			    strerror(errno)));
1524bc
 		umask(old_umask);
1524bc
 		return false;
1524bc
 	}
1524bc
-- 
1524bc
2.25.0
1524bc