Use rand rather than mkstemp for session
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 1 Aug 2011 11:05:13 +0000 (13:05 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 1 Aug 2011 11:05:13 +0000 (13:05 +0200)
Problem is that the generated URL is not case sensitive so we need
a temporary file name without case mix.

src/filter_zoom.cpp

index 17065a0..1c2ff9a 100644 (file)
@@ -17,6 +17,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 #include "config.hpp"
 */
 
 #include "config.hpp"
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
 #include "filter_zoom.hpp"
 #include <yaz/zoom.h>
 #include <yaz/yaz-version.h>
 #include "filter_zoom.hpp"
 #include <yaz/zoom.h>
 #include <yaz/yaz-version.h>
@@ -365,6 +369,8 @@ yf::Zoom::Impl::Impl() :
     apdu_log(false), element_transform("pz2") , element_raw("raw")
 {
     bibset = ccl_qual_mk();
     apdu_log(false), element_transform("pz2") , element_raw("raw")
 {
     bibset = ccl_qual_mk();
+
+    srand(time(0));
 }
 
 yf::Zoom::Impl::~Impl()
 }
 
 yf::Zoom::Impl::~Impl()
@@ -843,7 +849,11 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases(
             xx = fname + strlen(fname);
             strcat(fname, "XXXXXX");
         }
             xx = fname + strlen(fname);
             strcat(fname, "XXXXXX");
         }
-        int fd = mkstemps(fname, suffixlen);
+        char tmp_char = xx[6];
+        sprintf(xx, "%06d", ((unsigned) rand()) % 1000000);
+        xx[6] = tmp_char;
+
+        int fd = creat(fname, 0666);
         if (fd == -1)
         {
             yaz_log(YLOG_WARN|YLOG_ERRNO, "create %s", fname);
         if (fd == -1)
         {
             yaz_log(YLOG_WARN|YLOG_ERRNO, "create %s", fname);