[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: Lidt om midlertidige filer



On Sun, 4 Dec 2005 19:30:26 +0100, Jens wrote:

> On Sunday 04 December 2005 18:18, Adam Sjøgren wrote:

>> Når jeg skrev tempfile(3) var det fordi mktemp(3) under BUGS på min
>> æske har teksten: "Never use mktemp()." - og fordi du nævnte både
>> C-programmering og shell.

> BUGS? Er det inde på man siden, for det er der ikke på min man side
> om mktemp.

Ja:

 "BUGS
         Never use mktemp(). Some  implementations  follow  4.3BSD  and  replace
         XXXXXX  by  the current process ID and a single letter, so that at most
         26 different names can be returned.  Since on the one  hand  the  names
         are  easy to guess, and on the other hand there is a race between test-
         ing whether the name exists and opening the file, every use of mktemp()
         is a security risk.  The race is avoided by mkstemp(3)."

   - mktemp(3)

> Mit 'problem' med tmpfile er at der står at filen bliver slettet, når den 
> filen lukkes, og det er jeg jo nødt til, med mindre jeg selv vil til at 
> skrive en filkopieringsrutine, og det gider jeg godt nok ikke.  :-)

I det tilfælde er mkstemp(3) nemmere at bruge.

> Og min man side om mkstemp har bare dette stående under NOTE:

> The prototype is in <unistd.h> for libc4, libc5, glibc1; glibc2 follows the 
> Single Unix Specification and has the prototype in <stdlib.h>.

Der er to NOTES-sektioner i den på min Debian GNU/Linux unstable boks:

 "NOTES
         The old behaviour (creating a file with mode 0666) may  be  a  security
         risk, especially since other Unix flavours use 0600, and somebody might
         overlook this detail when porting programs.

         More generally, the POSIX specification does  not  say  anything  about
         file modes, so the application should make sure its umask is set appro-
         priately before calling mkstemp().

  CONFORMING TO
         4.3BSD, POSIX 1003.1-2001

  NOTES
         The prototype is in <unistd.h> for libc4, libc5, glibc1; glibc2 follows
         the Single Unix Specification and has the prototype in <stdlib.h>.

         Don't  use this function, use tmpfile(3) instead.  It is better defined
         and more portable."

   - mkstemp(3)


Man-siderne på min æske kommer fra Debian GNU/Linux' manpages-dev
2.10-1 pakke.


  Mvh.

-- 
 "we push onward. to you, it is 2005, to us, it is            Adam Sjøgren
  2011. we are always far ahead."                        sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-01-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *