summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2014-10-09 21:42:15 +0000
committerSteve Huston <shuston@riverace.com>2014-10-09 21:42:15 +0000
commitb6310d7aceb1652b4223a0c7b3ea0b82acec96fe (patch)
treeb1775bdbd82b1845b6c5b67e9c45e105f81a2ec0
parent8fb3fa969b6a4c0aa29a9415d01ea0d86a5e441e (diff)
downloadATCD-b6310d7aceb1652b4223a0c7b3ea0b82acec96fe.tar.gz
ChangeLogTag:Thu Oct 9 16:21:38 UTC 2014 Steve Huston <shuston@riverace.com>
-rw-r--r--ACE/ChangeLog38
-rw-r--r--ACE/ace/FILE_Addr.cpp13
-rw-r--r--ACE/ace/MMAP_Memory_Pool.cpp9
-rw-r--r--ACE/ace/OS_NS_stdio.h6
-rw-r--r--ACE/ace/OS_NS_stdio.inl2
-rw-r--r--ACE/ace/OS_NS_stdlib.cpp4
-rw-r--r--ACE/ace/OS_NS_stdlib.h12
-rw-r--r--ACE/ace/OS_NS_stdlib.inl21
-rw-r--r--ACE/ace/README4
-rw-r--r--ACE/apps/drwho/File_Manager.cpp5
-rw-r--r--ACE/apps/mkcsregdb/mkcsregdb.cpp26
-rw-r--r--ACE/examples/OS/Process/imore.cpp21
-rw-r--r--ACE/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp5
-rw-r--r--ACE/tests/MM_Shared_Memory_Test.cpp6
-rw-r--r--ACE/tests/Naming_Test.cpp17
-rw-r--r--ACE/tests/Svc_Handler_Test.cpp16
16 files changed, 157 insertions, 48 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 51fad58486e..78f5da9c075 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,41 @@
+Thu Oct 9 16:21:38 UTC 2014 Steve Huston <shuston@riverace.com>
+
+ * ace/OS_NS_stdlib.{h inl cpp}:
+ * ace/OS_NS_stdio.{h inl}:
+ * ace/README:
+ Added new feature config macros ACE_DISABLE_MKTEMP and
+ ACE_DISABLE_TEMPNAM. These disable the ACE wrappers for
+ mktemp() and tempnam(), respectively. Those functions are
+ considered insecure and better replaced by the use of mkstemp().
+
+ * ace/FILE_Addr.cpp (set): Call to set(const ACE_FILE_Addr&) using
+ the default "any" address will now fail if ACE_DISABLE_MKTEMP is
+ set.
+
+ * ace/FILE_Connector.cpp (connect): Specifying 'any' for the
+ address now uses ACE_OS::mkstemp(). Contrast this with setting a
+ ACE_FILE_Addr with 'any', above.
+
+ * ace/MMAP_Memory_Pool.cpp (constructor): Using the 'unique' option
+ will no longer work if ACE_DISABLE_MKTEMP is set.
+
+ * tests/MM_Shared_Memory_Test.cpp:
+ Will not work if ACE_DISABLE_MKTEMP is set.
+
+ * tests/Naming_Test.cpp:
+ Changed to avoid use of ACE_OS::tempnam.
+
+ * tests/Svc_Handler_Test.cpp: Modified to work with or without
+ ACE_DISABLE_MKTEMP.
+
+ * apps/mkcsregdb/mkcsregdb.cpp:
+ * apps/drwho/File_Manager.cpp:
+ Use ACE_OS::mkstemp.
+
+ * examples/OS/Process/imore.cpp:
+ * examples/Service_Configurator/IPC-tests/client/local_dgram_client.cpp:
+ Won't work if ACE_DISABLE_TEMPNAM is set.
+
Tue Aug 5 21:49:12 UTC 2014 Steve Huston <shuston@riverace.com>
* ace/Process.cpp (setenv): Use the correct format string for
diff --git a/ACE/ace/FILE_Addr.cpp b/ACE/ace/FILE_Addr.cpp
index c501f0ee615..60c783caaa5 100644
--- a/ACE/ace/FILE_Addr.cpp
+++ b/ACE/ace/FILE_Addr.cpp
@@ -28,11 +28,17 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa)
{
if (sa.get_type () == AF_ANY)
{
-#if defined (ACE_DEFAULT_TEMP_FILE)
+#if defined (ACE_DISABLE_MKTEMP)
+ // Built without mktemp support; punt back to caller.
+ errno = ENOTSUP;
+ return -1;
+#else
+
+# if defined (ACE_DEFAULT_TEMP_FILE)
// Create a temporary file.
ACE_OS::strcpy (this->filename_,
ACE_DEFAULT_TEMP_FILE);
-#else /* ACE_DEFAULT_TEMP_FILE */
+# else /* ACE_DEFAULT_TEMP_FILE */
if (ACE::get_temp_dir (this->filename_, MAXPATHLEN - 15) == -1)
// -15 for ace-file-XXXXXX
{
@@ -45,12 +51,13 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa)
// Add the filename to the end
ACE_OS::strcat (this->filename_, ACE_TEXT ("ace-fileXXXXXX"));
-#endif /* ACE_DEFAULT_TEMP_FILE */
+# endif /* ACE_DEFAULT_TEMP_FILE */
if (ACE_OS::mktemp (this->filename_) == 0)
return -1;
this->base_set (AF_FILE,
static_cast<int> (ACE_OS::strlen (this->filename_) + 1));
+#endif /* ACE_DISABLE_MKTEMP */
}
else
{
diff --git a/ACE/ace/MMAP_Memory_Pool.cpp b/ACE/ace/MMAP_Memory_Pool.cpp
index e5eb2a4be1a..385ec9513b7 100644
--- a/ACE/ace/MMAP_Memory_Pool.cpp
+++ b/ACE/ace/MMAP_Memory_Pool.cpp
@@ -180,7 +180,16 @@ ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool (
// If requested an unique filename, use mktemp to get a random file.
if (options && options->unique_)
+# if defined (ACE_DISABLE_MKTEMP)
+ {
+ ACELIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("mktemp disabled; ")
+ ACE_TEXT ("can't generate unique name")));
+ this->backing_store_name_[0] = 0;
+ }
+# else
ACE_OS::mktemp(this->backing_store_name_);
+# endif /* ACE_DISABLE_MKTEMP */
#endif /* ACE_DEFAULT_BACKING_STORE */
}
else
diff --git a/ACE/ace/OS_NS_stdio.h b/ACE/ace/OS_NS_stdio.h
index 761db883356..a95d12ee20e 100644
--- a/ACE/ace/OS_NS_stdio.h
+++ b/ACE/ace/OS_NS_stdio.h
@@ -489,15 +489,17 @@ namespace ACE_OS {
int sprintf (wchar_t *buf, const wchar_t *format, ...);
# endif /* ACE_HAS_WCHAR */
+# if !defined (ACE_DISABLE_TEMPNAM)
ACE_NAMESPACE_INLINE_FUNCTION
char *tempnam (const char *dir = 0,
const char *pfx = 0);
-#if defined (ACE_HAS_WCHAR)
+# if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t *tempnam (const wchar_t *dir,
const wchar_t *pfx = 0);
-#endif /* ACE_HAS_WCHAR */
+# endif /* ACE_HAS_WCHAR */
+# endif /* !ACE_DISABLE_TEMPNAM */
ACE_NAMESPACE_INLINE_FUNCTION
int vasprintf (char **bufp, const char *format, va_list argptr)
diff --git a/ACE/ace/OS_NS_stdio.inl b/ACE/ace/OS_NS_stdio.inl
index 8e44c5a8f64..53fcc65784f 100644
--- a/ACE/ace/OS_NS_stdio.inl
+++ b/ACE/ace/OS_NS_stdio.inl
@@ -873,6 +873,7 @@ ACE_OS::rewind (FILE *fp)
#endif /* ACE_HAS_WINCE */
}
+#if !defined (ACE_DISABLE_TEMPNAM)
ACE_INLINE char *
ACE_OS::tempnam (const char *dir, const char *pfx)
{
@@ -924,6 +925,7 @@ ACE_OS::tempnam (const wchar_t *dir, const wchar_t *pfx)
#endif /* ACE_LACKS_TEMPNAM */
}
#endif /* ACE_HAS_WCHAR */
+#endif /* !ACE_DISABLE_TEMPNAM */
ACE_INLINE int
ACE_OS::vasprintf (char **bufp, const char* format, va_list argptr)
diff --git a/ACE/ace/OS_NS_stdlib.cpp b/ACE/ace/OS_NS_stdlib.cpp
index 9f13021519a..cd47f1d63ab 100644
--- a/ACE/ace/OS_NS_stdlib.cpp
+++ b/ACE/ace/OS_NS_stdlib.cpp
@@ -277,7 +277,7 @@ ACE_OS::malloc (size_t nbytes)
return ACE_MALLOC_FUNC (nbytes);
}
-#if defined (ACE_LACKS_MKTEMP)
+#if defined (ACE_LACKS_MKTEMP) && !defined (ACE_DISBALE_MKTEMP)
ACE_TCHAR *
ACE_OS::mktemp (ACE_TCHAR *s)
{
@@ -325,7 +325,7 @@ ACE_OS::mktemp (ACE_TCHAR *s)
return s;
}
}
-#endif /* ACE_LACKS_MKTEMP */
+#endif /* ACE_LACKS_MKTEMP &7 !ACE_DISABLE_MKTEMP */
void *
ACE_OS::realloc (void *ptr, size_t nbytes)
diff --git a/ACE/ace/OS_NS_stdlib.h b/ACE/ace/OS_NS_stdlib.h
index fb9f9c18161..e4f18ea5e8b 100644
--- a/ACE/ace/OS_NS_stdlib.h
+++ b/ACE/ace/OS_NS_stdlib.h
@@ -231,18 +231,20 @@ namespace ACE_OS {
ACE_HANDLE mkstemp_emulation (ACE_TCHAR * s);
#endif /* ACE_LACKS_MKSTEMP */
-#if !defined (ACE_LACKS_MKTEMP)
+#if !defined (ACE_DISABLE_MKTEMP)
+# if !defined (ACE_LACKS_MKTEMP)
ACE_NAMESPACE_INLINE_FUNCTION
char *mktemp (char *s);
-# if defined (ACE_HAS_WCHAR)
+# if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t *mktemp (wchar_t *s);
-# endif /* ACE_HAS_WCHAR */
-#else
+# endif /* ACE_HAS_WCHAR */
+# else
extern ACE_Export
ACE_TCHAR *mktemp (ACE_TCHAR *s);
-#endif /* !ACE_LACKS_MKTEMP */
+# endif /* !ACE_LACKS_MKTEMP */
+#endif /* !ACE_DISABLE_MKTEMP */
ACE_NAMESPACE_INLINE_FUNCTION
int putenv (const char *string);
diff --git a/ACE/ace/OS_NS_stdlib.inl b/ACE/ace/OS_NS_stdlib.inl
index 1281440caab..ce40934ac31 100644
--- a/ACE/ace/OS_NS_stdlib.inl
+++ b/ACE/ace/OS_NS_stdlib.inl
@@ -267,24 +267,26 @@ ACE_OS::mkstemp (wchar_t *s)
}
#endif /* ACE_HAS_WCHAR */
-#if !defined (ACE_LACKS_MKTEMP)
+#if !defined (ACE_DISABLE_MKTEMP)
+
+# if !defined (ACE_LACKS_MKTEMP)
ACE_INLINE char *
ACE_OS::mktemp (char *s)
{
-# if defined (ACE_WIN32)
+# if defined (ACE_WIN32)
return ::_mktemp (s);
-# else /* ACE_WIN32 */
+# else /* ACE_WIN32 */
return ::mktemp (s);
-# endif /* ACE_WIN32 */
+# endif /* ACE_WIN32 */
}
-# if defined (ACE_HAS_WCHAR)
+# if defined (ACE_HAS_WCHAR)
ACE_INLINE wchar_t *
ACE_OS::mktemp (wchar_t *s)
{
-# if defined (ACE_WIN32)
+# if defined (ACE_WIN32)
return ::_wmktemp (s);
-# else
+# else
// For narrow-char filesystems, we must convert the wide-char input to
// a narrow-char string for mktemp (), then convert the name back to
// wide-char for the caller.
@@ -294,11 +296,12 @@ ACE_OS::mktemp (wchar_t *s)
ACE_Ascii_To_Wide wide_s (narrow_s.char_rep ());
ACE_OS::strcpy (s, wide_s.wchar_rep ());
return s;
-# endif
+# endif
}
# endif /* ACE_HAS_WCHAR */
-#endif /* !ACE_LACKS_MKTEMP */
+# endif /* !ACE_LACKS_MKTEMP */
+#endif /* !ACE_DISABLE_MKTEMP */
ACE_INLINE int
ACE_OS::putenv (const char *string)
diff --git a/ACE/ace/README b/ACE/ace/README
index 4a5b989f807..9b13064a46b 100644
--- a/ACE/ace/README
+++ b/ACE/ace/README
@@ -32,6 +32,10 @@ ACE_DEFINES_DEFAULT_WIN32_SECURITY_ATTRIBUTES
ACE_OS::default_win32_security_attributes
as the default security
object.
+ACE_DISABLE_MKTEMP Disable availability of
+ ACE_OS::mktemp().
+ACE_DISABLE_TEMPNAM Disable availability of
+ ACE_OS::tempnam().
ACE_DISABLE_DEBUG_DLL_CHECK Define this if you don't want
debug version ACE search for
debug version DLLs first
diff --git a/ACE/apps/drwho/File_Manager.cpp b/ACE/apps/drwho/File_Manager.cpp
index 30df49cf8d7..8acb846f5a2 100644
--- a/ACE/apps/drwho/File_Manager.cpp
+++ b/ACE/apps/drwho/File_Manager.cpp
@@ -73,8 +73,9 @@ File_Manager::get_login_and_real_name (const char *&login_name, const char *&rea
int
File_Manager::open_passwd_file (void)
{
- const char *filename = ACE_OS::tempnam ();
- FILE *fp = ACE_OS::fopen (filename, "w");
+ char *filename = "passwd-XXXXXX";
+ ACE_HANDLE f = ACE_OS::mkstemp (filename);
+ FILE *fp = ACE_OS::fdopen (f, "w");
if (fp == 0)
return -1;
diff --git a/ACE/apps/mkcsregdb/mkcsregdb.cpp b/ACE/apps/mkcsregdb/mkcsregdb.cpp
index bdb112c14b8..7b3ff7fffa7 100644
--- a/ACE/apps/mkcsregdb/mkcsregdb.cpp
+++ b/ACE/apps/mkcsregdb/mkcsregdb.cpp
@@ -42,7 +42,7 @@ private:
char *line_data_;
ifstream *inf_;
FILE *outf_;
- char *tempfilename_;
+ char tempfilename_[MAXPATHLEN];
char *ace_src_;
};
@@ -68,6 +68,7 @@ csdb_generator::csdb_generator ()
outf_ (0)
{
ace_src_ = ACE_OS::getenv("ACE_ROOT");
+ tempfilename_[0] = '\0';
}
void
@@ -227,10 +228,25 @@ csdb_generator::init_output (const char *srcfile)
ACE_ERROR_RETURN ((LM_ERROR,"You must first set $ACE_ROOT\n"),-1);
time_t now = ACE_OS::time();
- tempfilename_ = ACE_OS::tempnam (ace_src_,"csdb");
- outf_ = ACE_OS::fopen (tempfilename_,"w");
- if (outf_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR, "Unable to open output file, %s\n",tempfilename_),-1);
+ if (ACE_OS::strlen(ace_src_) > 0)
+ {
+ ACE_OS::sprintf (tempfilename_,
+ "%s%s%s",
+ ace_src_,
+ ACE_DIRECTORY_SEPARATOR_STR,
+ "csdbXXXXXX");
+ }
+ else
+ {
+ ACE_OS::strcpy (tempfilename_, "csdbXXXXXX");
+ }
+ int fd = ACE_OS::mkstemp (tempfilename_);
+ if (fd == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to open output file, %p\n",
+ tempfilename_),
+ -1);
+ outf_ = ACE_OS::fdopen (fd, "w");
ACE_OS::fprintf (outf_,"// $ID: $\n");
ACE_OS::fprintf (outf_,"/*\n * Codeset registry DB, generated %s * source: %s\n",
diff --git a/ACE/examples/OS/Process/imore.cpp b/ACE/examples/OS/Process/imore.cpp
index 98bac0ba53a..ae3cf491fe1 100644
--- a/ACE/examples/OS/Process/imore.cpp
+++ b/ACE/examples/OS/Process/imore.cpp
@@ -89,7 +89,7 @@ parse_args (int argc, ACE_TCHAR **argv)
return 0;
}
-#if !defined (ACE_WIN32)
+#if !defined (ACE_WIN32) && !defined (ACE_DISABLE_TEMPNAM)
static int
setup_named_pipes (ACE_Process_Options &opt)
{
@@ -227,9 +227,22 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
#if !defined (ACE_WIN32)
ACE_Process_Options options;
- if ((use_named_pipe ? ::setup_named_pipes :
- ::setup_unnamed_pipe) (options) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "Error, bailing out!\n"), -1);
+ if (use_named_pipe)
+ {
+# if defined (ACE_DISABLE_TEMPNAM)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "ACE_DISABLE_TEMPNAM set; can't use named pipes\n"),
+ -1);
+# else
+ if (::setup_named_pipes (options) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "Error, bailing out!\n"), -1);
+# endif /* ACE_DISABLE_TEMPNAM */
+ }
+ else
+ {
+ if (::setup_unnamed_pipe (options) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "Error, bailing out!\n"), -1);
+ }
options.command_line (executable);
if (new_process.spawn (options) == -1)
diff --git a/ACE/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp b/ACE/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp
index 616f6bc40ee..f7e6cc6111f 100644
--- a/ACE/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp
+++ b/ACE/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp
@@ -13,7 +13,8 @@
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_fcntl.h"
-#if defined (ACE_HAS_MSG) && !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+#if defined (ACE_HAS_MSG) && !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) && \
+ !defined (ACE_DISABLE_TEMPNAM)
// Name of the program.
static ACE_TCHAR *program_name;
@@ -113,7 +114,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
int ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("your platform must support sendmsg/recvmsg to run this test\n")),
+ ACE_TEXT ("your platform must support sendmsg/recvmsg and tempnam to run this test\n")),
-1);
}
#endif /* ACE_HAS_MSG */
diff --git a/ACE/tests/MM_Shared_Memory_Test.cpp b/ACE/tests/MM_Shared_Memory_Test.cpp
index c320d8a6a96..1dcb13c65cb 100644
--- a/ACE/tests/MM_Shared_Memory_Test.cpp
+++ b/ACE/tests/MM_Shared_Memory_Test.cpp
@@ -194,7 +194,7 @@ run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("MM_Shared_Memory_Test"));
-#if !defined (ACE_LACKS_MMAP)
+#if !defined (ACE_LACKS_MMAP) && !defined (ACE_DISABLE_MKTEMP)
ACE_TCHAR temp_file[MAXPATHLEN + 1];
// Get the temporary directory,
@@ -219,8 +219,8 @@ run_main (int, ACE_TCHAR *[])
#else /* !ACE_LACKS_MMAP */
ACE_ERROR ((LM_INFO,
- ACE_TEXT ("mmap ")
- ACE_TEXT ("is not supported on this platform\n")));
+ ACE_TEXT ("mmap and mktemp")
+ ACE_TEXT ("are required for this test\n")));
#endif /* !ACE_LACKS_MMAP */
ACE_END_TEST;
diff --git a/ACE/tests/Naming_Test.cpp b/ACE/tests/Naming_Test.cpp
index a6a01c95442..e48866e7c18 100644
--- a/ACE/tests/Naming_Test.cpp
+++ b/ACE/tests/Naming_Test.cpp
@@ -244,8 +244,7 @@ run_main (int argc, ACE_TCHAR *argv[])
// for Tru64 when the current directory is NFS mounted from a
// system that does not properly support locking.
ACE_TCHAR temp_dir [MAXPATHLEN];
- if (ACE::get_temp_dir (temp_dir, MAXPATHLEN - 15) == -1)
- // -15 for ace-file-XXXXXX
+ if (ACE::get_temp_dir (temp_dir, MAXPATHLEN) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Temporary path too long, ")
@@ -256,11 +255,17 @@ run_main (int argc, ACE_TCHAR *argv[])
{
ACE_OS::chdir (temp_dir);
}
- ACE_OS::strcpy (temp_file, pname);
- ACE_OS::strcat (temp_file, ACE_TEXT ("XXXXXX"));
+ // Set the database name using the pid. mktemp isn't always available.
+ ACE_OS::snprintf(temp_file, BUFSIZ,
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_TEXT ("%ls%d"),
+#else
+ ACE_TEXT ("%s%d"),
+#endif
+ pname,
+ ACE_OS::getpid ());
- // Set the database name using mktemp to generate a unique file name
- name_options->database (ACE_OS::mktemp (temp_file));
+ name_options->database (temp_file);
}
if (ns_context->open (ACE_Naming_Context::PROC_LOCAL, 1) == -1)
{
diff --git a/ACE/tests/Svc_Handler_Test.cpp b/ACE/tests/Svc_Handler_Test.cpp
index 7c7358c3e45..cfe2f2f5561 100644
--- a/ACE/tests/Svc_Handler_Test.cpp
+++ b/ACE/tests/Svc_Handler_Test.cpp
@@ -87,13 +87,19 @@ run_main (int argc, ACE_TCHAR *argv[])
ACE_FILE_Connector connector;
ACE_FILE_IO file_io;
// Create a temporary filename.
- ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &));
- // Open up the temp file.
- if (connector.connect (file_io, file) == -1)
+ // Open up a temp file.
+ if (connector.connect (file_io, ACE_sap_any_cast (ACE_FILE_Addr &)) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("connect failed for %p\n"),
- file.get_path_name ()),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("connect")),
+ 1);
+ // Find the name of the temp file
+ ACE_FILE_Addr file;
+ if (file_io.get_local_addr (file) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("get_local_addr")),
1);
// Create the service handler and assign it <file_io> as its data