summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-07-02 18:26:38 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-07-02 18:26:38 +0000
commit4a0e6dfed267100d120e9170eb502aa7d3070748 (patch)
tree58018c5fa23628b089a7a7416f8a53145060be6f
parent410c3fffc00e537eb46bce3c8822bd14de391086 (diff)
downloadATCD-4a0e6dfed267100d120e9170eb502aa7d3070748.tar.gz
ChangeLogTag: Fri Jul 2 13:20:46 2004 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog15
-rw-r--r--TAO/TAO_IDL/driver/drv_preproc.cpp83
-rw-r--r--TAO/TAO_IDL/tao_idl.cpp8
3 files changed, 91 insertions, 15 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 08a9623cb46..45ca3e0edc5 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,18 @@
+Fri Jul 2 13:20:46 2004 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/tao_idl.cpp:
+ * TAO_IDL/driver/drv_preproc.cpp:
+
+ Put back the code using mkstemp() (for platforms that support
+ it) to generate unique and secure temporary file names. This
+ code was removed in
+
+ Thu Jul 1 20:01:16 2004 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ For platforms that do not support mkstemp(), we now use ACE's
+ uuid generator to generate a suffix for the base names of the
+ needed temporary files.
+
Fri Jul 2 16:11:12 UTC 2004 Johnny Willemsen <jwillemsen@remedy.nl>
* orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.cpp:
diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp
index 599f5ebde36..3c91fa34aab 100644
--- a/TAO/TAO_IDL/driver/drv_preproc.cpp
+++ b/TAO/TAO_IDL/driver/drv_preproc.cpp
@@ -77,6 +77,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "ace/SString.h"
#include "ace/Env_Value_T.h"
#include "ace/ARGV.h"
+#include "ace/UUID.h"
// FUZZ: disable check_for_streams_include
#include "ace/streams.h"
@@ -664,12 +665,30 @@ void
DRV_pre_proc (const char *myfile)
{
const char* tmpdir = idl_global->temp_dir ();
+ static const char temp_file_extension[] = ".cpp";
+
+ // If ACE_LACKS_MKSTEMP is defined, we use ACE's uuid generator
+ // to create a unique id to append to tao_idl*_template to get
+ // unique temporary file names.
+ size_t uuid_len = 0;
+
+#ifdef ACE_LACKS_MKSTEMP
static const char tao_idlf_template[] = "tao-idlf_";
static const char tao_idli_template[] = "tao-idli_";
- static const char temp_file_extension[] = ".cpp";
+
+ // The generated string format has 32 characters and 4 dashes.
+ uuid_len = 36;
+
+#else
- const size_t tlen = ACE_OS::strlen (tmpdir) + sizeof (temp_file_extension);
+ static const char tao_idlf_template[] = "tao-idlf_XXXXXX";
+ static const char tao_idli_template[] = "tao-idli_XXXXXX";
+
+#endif /* ACE_LACKS_MKSTEMP */
+
+ size_t tlen =
+ ACE_OS::strlen (tmpdir) + sizeof (temp_file_extension) + uuid_len;
// Prevent a buffer overrun.
if (tlen + sizeof (tao_idlf_template) > sizeof (tmp_file)
@@ -686,22 +705,64 @@ DRV_pre_proc (const char *myfile)
ACE_OS::strcpy (tmp_file, tmpdir);
ACE_OS::strcpy (tmp_ifile, tmpdir);
+#ifdef ACE_LACKS_MKSTEMP
+
+ ACE_CString ftmpl (tao_idlf_template);
+ ACE_CString itmpl (tao_idli_template);
+
// Append temporary filename template to temporary directory.
- ACE_OS::strcat (tmp_file, tao_idlf_template);
- ACE_OS::strcat (tmp_ifile, tao_idli_template);
+ ACE_OS::strcat (tmp_file, ftmpl.substr (0, 9).c_str ());
+ ACE_OS::strcat (tmp_ifile, itmpl.substr (0, 9).c_str ());
- // Append 6 random digits to the end of the temporary filename
- // to ensure uniqueness.
- char digits[7];
- ACE_OS::sprintf (digits, "%6.6d", rand ());
- digits[6] = '\0';
+ ACE_Utils::UUID* uuid =
+ ACE_Utils::UUID_GENERATOR::instance ()->generateUUID ();
+
+ const char *suffix = uuid->to_string ()->c_str ();
+
+ ACE_OS::strcat (tmp_file, suffix);
+ ACE_OS::strcat (tmp_ifile, suffix);
- ACE_OS::strcat (tmp_file, digits);
- ACE_OS::strcat (tmp_ifile, digits);
+ delete uuid;
char * t_file = tmp_file;
char * t_ifile = tmp_ifile;
+#else
+
+ // Append temporary filename template to temporary directory.
+ ACE_OS::strcat (tmp_file, tao_idlf_template);
+ ACE_OS::strcat (tmp_ifile, tao_idli_template);
+
+ int tf_fd = ACE_OS::mkstemp (tmp_file);
+ int ti_fd = ACE_OS::mkstemp (tmp_ifile);
+
+ if (tf_fd == -1 || ti_fd == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%s: Unable to create temporary file: %m\n",
+ idl_global->prog_name ()));
+
+ return;
+ }
+
+ static char tmp_cpp_file [MAXPATHLEN + 1] = { 0 };
+ static char tmp_cpp_ifile[MAXPATHLEN + 1] = { 0 };
+
+ // Append C++ source file extension. Temporary files will be renamed
+ // to these filenames.
+ ACE_OS::strcpy (tmp_cpp_file, tmp_file);
+ ACE_OS::strcpy (tmp_cpp_ifile, tmp_ifile);
+ ACE_OS::strcat (tmp_cpp_file, temp_file_extension);
+ ACE_OS::strcat (tmp_cpp_ifile, temp_file_extension);
+
+ char * t_file = tmp_cpp_file;
+ char * t_ifile = tmp_cpp_ifile;
+
+#endif /* ACE_LACKS_MKSTEMP */
+
+ // Rename temporary files so that they have extensions accepted
+ // by the preprocessor.
+
UTL_String *tmp = 0;
FILE *file = ACE_OS::fopen (myfile, "r");
diff --git a/TAO/TAO_IDL/tao_idl.cpp b/TAO/TAO_IDL/tao_idl.cpp
index ed1e1ae18cc..6b7564337f2 100644
--- a/TAO/TAO_IDL/tao_idl.cpp
+++ b/TAO/TAO_IDL/tao_idl.cpp
@@ -74,6 +74,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "utl_identifier.h"
#include "drv_extern.h"
#include "../tao/Version.h"
+#include "ace/UUID.h"
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
// FUZZ: disable check_for_streams_include
@@ -338,10 +339,9 @@ main (int argc, char *argv[])
// For the IFR loader, it does nothing.
BE_post_init ();
- // Seed the random number generator used for creating unique
- // temporary filenames.
- srand ((unsigned int) time (0));
-
+ ///Initialise the UUID Generator
+ ACE_Utils::UUID_GENERATOR::instance ()->init ();
+
for (DRV_file_index = 0;
DRV_file_index < DRV_nfiles;
++DRV_file_index)