From 3000fc29c373f7fcc59f4de443f209f377dbd4f6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 13 Dec 2012 18:16:34 +0100 Subject: s3-nmbd: Check if we created the directories correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by Coverity. Signed-off-by: Andreas Schneider Reviewed-by: Günther Deschner --- source3/nmbd/nmbd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index d4df2020d5..49f0cdf457 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -788,6 +788,7 @@ static bool open_sockets(bool isdaemon, int port) }; TALLOC_CTX *frame; NTSTATUS status; + bool ok; /* * Do this before any other talloc operation @@ -945,12 +946,18 @@ static bool open_sockets(bool isdaemon, int port) } #endif - if (!directory_exist(lp_lockdir())) { - mkdir(lp_lockdir(), 0755); + ok = directory_create_or_exist(lp_lockdir(), geteuid(), 0755); + if (!ok) { + DEBUG(0, ("Failed to create directory %s for lock files - %s\n", + lp_lockdir(), strerror(errno))); + exit(1); } - if (!directory_exist(lp_piddir())) { - mkdir(lp_piddir(), 0755); + ok = directory_create_or_exist(lp_piddir(), geteuid(), 0755); + if (!ok) { + DEBUG(0, ("Failed to create directory %s for pid files - %s\n", + lp_piddir(), strerror(errno))); + exit(1); } pidfile_create(lp_piddir(), "nmbd"); -- cgit