Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()?

2014-09-28 Thread Gustaf Neumann

mktemp() is useful, but is in in the unix world general strongly
discouraged in favor of mkstemp(). The problem with mktemp()  + file-create
is, that in the time between the pathname is constructed and the file is 
created,

another process might have created a file with the same name. mkstemp() is
actually guaranteed to create a unique file.

For the time being, i've commited a small implementation of mkstemp() 
for windows,
that opens files with O_EXCL, which should be a first approximation. 
However,
it's not tested, please test it and don't be surprised, if it needs more 
tweaks

(maybe my flag settings are too restrictive).

all the best
-g

Am 27.09.14 16:11, schrieb Andrew Piskorski:

On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote:

Dear Andrew and Gustaf,
I believe this is the function you are looking for:

http://msdn.microsoft.com/en-us/library/ms235413.aspx

No, it is not.  mktemp and friends merely generate a file name, while
mkstemp also opens the file and returns a file handle.  So yes, you
could use mktemp as part of an implementation of mkstemp, but they do
are not replacements for each other.



--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()?

2014-09-28 Thread Maurizio Martignano
Perfect,

 

   You eventually landed on using _mktemp_s which is what
described in the first link I provided you with and is what I was hoping for
Windows.

 

Thanks a lot,

Maurizio

 

 

From: Gustaf Neumann [mailto:neum...@wu.ac.at] 
Sent: 28 September 2014 16:56
To: naviserver-devel@lists.sourceforge.net
Subject: Re: [naviserver-devel] no mkstemp() on Windows, use
TclpCreateTempFile()?

 

mktemp() is useful, but is in in the unix world general strongly 
discouraged in favor of mkstemp(). The problem with mktemp()  + file-create 
is, that in the time between the pathname is constructed and the file is
created,
another process might have created a file with the same name. mkstemp() is 
actually guaranteed to create a unique file. 

For the time being, i've commited a small implementation of mkstemp() for
windows,
that opens files with O_EXCL, which should be a first approximation.
However,
it's not tested, please test it and don't be surprised, if it needs more
tweaks
(maybe my flag settings are too restrictive).

all the best
-g

Am 27.09.14 16:11, schrieb Andrew Piskorski:

On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote:

Dear Andrew and Gustaf,
   I believe this is the function you are looking for:
 
http://msdn.microsoft.com/en-us/library/ms235413.aspx

 
No, it is not.  mktemp and friends merely generate a file name, while
mkstemp also opens the file and returns a file handle.  So yes, you
could use mktemp as part of an implementation of mkstemp, but they do
are not replacements for each other.
 

 

--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()?

2014-09-27 Thread Andrew Piskorski
On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote:
 Dear Andrew and Gustaf,
   I believe this is the function you are looking for:
 
 http://msdn.microsoft.com/en-us/library/ms235413.aspx

No, it is not.  mktemp and friends merely generate a file name, while
mkstemp also opens the file and returns a file handle.  So yes, you
could use mktemp as part of an implementation of mkstemp, but they do
are not replacements for each other.

-- 
Andrew Piskorski a...@piskorski.com

--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()?

2014-09-27 Thread Andrew Piskorski
On Fri, Sep 26, 2014 at 02:12:59PM +0200, Gustaf Neumann wrote:

 We have to be careful on licence mixes. The tcl8.5 version of
 TclpCreateTempFile uses already mkstemp, but the windows

I did not consider that at all.  But, hm, Tcl uses a quite permissive
BSD-like license, so it probably does not matter?  If we copy some
bits of their code, we may still put it our modified version under
Naviserver's Mozilla license?

 implemetation looks like a slim approach for a win32
 implementation (aside of the TclFile handling)  using
 CreateFile* and the appropriate flags to make the file
 a temp file...

Is that a good fit for Naviserver's needs?

-- 
Andrew Piskorski a...@piskorski.com

--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()?

2014-09-26 Thread Maurizio Martignano
http://msdn.microsoft.com/en-us/library/ms235413.aspx

Maurizio


-Original Message-
From: Gustaf Neumann [mailto:neum...@wu.ac.at] 
Sent: 26 September 2014 14:13
To: naviserver-devel@lists.sourceforge.net
Subject: Re: [naviserver-devel] no mkstemp() on Windows, use
TclpCreateTempFile()?

Dear Andrew,

We have to be careful on licence mixes. The tcl8.5 version of
TclpCreateTempFile uses already mkstemp, but the windows implemetation looks
like a slim approach for a win32 implementation (aside of the TclFile
handling)  using
CreateFile* and the appropriate flags to make the file a temp file...

-g

On 26.09.14 02:51, Andrew Piskorski wrote:
 mkstemp() does not exist on Windows, and Naviserver uses it in three
 places:

$ find . -name *.[ch] -print | xargs grep -in mkstemp
./nsd/adpeval.c:1183:fd = mkstemp(debugfile);
./nsd/tclhttp.c:426:fd =
mkstemp(httpPtr-spoolFileName);
./nsd/driver.c:2301:sockPtr-tfd = mkstemp(sockPtr-tfile);

 We could stick in our own mkstemp() implementation.  Some starting 
 points for that may be:


http://stackoverflow.com/questions/6036227/mkstemp-implementation-for-win32
http://sourceforge.net/p/mingw/bugs/2003/

 But Tcl 8.4 and later already have TclpCreateTempFile() (two separate 
 implementations for Unix and Windows), which seems to solve the same 
 problem.  It returns a TclFile object, not a file descriptor.

 Can/should Naviserver's existing users of mkstemp() be modified to 
 instead work with TclpCreateTempFile()?  Or will that not quite work, 
 and we should borrow some of the Windows version of 
 TclpCreateTempFile() for direct use in Naviserver?




--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI
DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you
Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI
DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()?

2014-09-26 Thread Maurizio Martignano
Dear Andrew and Gustaf,
I believe this is the function you are looking for:

http://msdn.microsoft.com/en-us/library/ms235413.aspx

Hope it helps,
Maurizio


-Original Message-
From: Gustaf Neumann [mailto:neum...@wu.ac.at] 
Sent: 26 September 2014 14:13
To: naviserver-devel@lists.sourceforge.net
Subject: Re: [naviserver-devel] no mkstemp() on Windows, use
TclpCreateTempFile()?

Dear Andrew,

We have to be careful on licence mixes. The tcl8.5 version of
TclpCreateTempFile uses already mkstemp, but the windows implemetation looks
like a slim approach for a win32 implementation (aside of the TclFile
handling)  using
CreateFile* and the appropriate flags to make the file a temp file...

-g

On 26.09.14 02:51, Andrew Piskorski wrote:
 mkstemp() does not exist on Windows, and Naviserver uses it in three
 places:

$ find . -name *.[ch] -print | xargs grep -in mkstemp
./nsd/adpeval.c:1183:fd = mkstemp(debugfile);
./nsd/tclhttp.c:426:fd =
mkstemp(httpPtr-spoolFileName);
./nsd/driver.c:2301:sockPtr-tfd = mkstemp(sockPtr-tfile);

 We could stick in our own mkstemp() implementation.  Some starting 
 points for that may be:


http://stackoverflow.com/questions/6036227/mkstemp-implementation-for-win32
http://sourceforge.net/p/mingw/bugs/2003/

 But Tcl 8.4 and later already have TclpCreateTempFile() (two separate 
 implementations for Unix and Windows), which seems to solve the same 
 problem.  It returns a TclFile object, not a file descriptor.

 Can/should Naviserver's existing users of mkstemp() be modified to 
 instead work with TclpCreateTempFile()?  Or will that not quite work, 
 and we should borrow some of the Windows version of 
 TclpCreateTempFile() for direct use in Naviserver?




--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI
DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you
Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI
DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel