From 09ad4d47f875bb3b273902f78e9882e5c4ee259f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 21 Apr 2011 10:04:06 -0400 Subject: [PATCH] lib-util: Make create_unlink_tmp argument optional Use tmpdir() if no dir is provided. Signed-off-by: Andreas Schneider --- lib/util/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/util/util.c b/lib/util/util.c index 4dd79266aff..2d1d83036d3 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -3,7 +3,7 @@ Samba utility functions Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Jeremy Allison 2001-2002 - Copyright (C) Simo Sorce 2001 + Copyright (C) Simo Sorce 2001-2011 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. Copyright (C) James J Myers 2003 Copyright (C) Volker Lendecke 2010 @@ -63,6 +63,7 @@ _PUBLIC_ const char *tmpdir(void) /** Create a tmp file, open it and immediately unlink it. + If dir is NULL uses tmpdir() Returns the file descriptor or -1 on error. **/ int create_unlink_tmp(const char *dir) @@ -70,6 +71,10 @@ int create_unlink_tmp(const char *dir) char *fname; int fd; + if (!dir) { + dir = tmpdir(); + } + fname = talloc_asprintf(talloc_tos(), "%s/listenerlock_XXXXXX", dir); if (fname == NULL) { errno = ENOMEM; -- 2.11.4.GIT