Date: Sunday March 03, 2019 @ 02:19 Author: argrath Update of /cvsroot/perldocjp/docs/modules/File-Temp-0.12 In directory sf-cvs:/tmp/cvs-serv119729/modules/File-Temp-0.12 Modified Files: Temp.pod Log Message: split original =================================================================== File: Temp.pod Status: Up-to-date Working revision: 1.4 Sat Mar 2 17:19:07 2019 Repository revision: 1.4 /cvsroot/perldocjp/docs/modules/File-Temp-0.12/Temp.pod,v Existing Tags: No Tags Exist -------------- next part -------------- Index: docs/modules/File-Temp-0.12/Temp.pod diff -u docs/modules/File-Temp-0.12/Temp.pod:1.3 docs/modules/File-Temp-0.12/Temp.pod:1.4 --- docs/modules/File-Temp-0.12/Temp.pod:1.3 Tue Mar 8 16:38:19 2011 +++ docs/modules/File-Temp-0.12/Temp.pod Sun Mar 3 02:19:07 2019 @@ -56,7 +56,7 @@ =end __INTERNALS -=head1 ³µÍ× +=head1 SYNOPSIS use File::Temp qw/ tempfile tempdir /; @@ -105,18 +105,24 @@ =end later -=head1 ³µÍ× +=head1 DESCRIPTION + +=begin original C<File::Temp> can be used to create and open temporary files in a safe way. The tempfile() function can be used to return the name and the open filehandle of a temporary file. The tempdir() function can be used to create a temporary directory. +=end original + C<File::Temp> ¤Ï¡¢°ÂÁ´¤ÊÊýË¡¤Ç¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¡¢¥ª¡¼¥×¥ó¤¹¤ë¤Î¤Ë¡¢ »È¤¦¤³¤È¤¬½ÐÍè¤Þ¤¹¡£tempfile() ´Ø¿ô¤Ï¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î̾Á°¤È¡¢ ³«¤¤¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£tempdir() ´Ø¿ô¤Ï¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤¹¤ë¤Î¤Ë¡¢»È¤ï¤ì¤Þ¤¹¡£ +=begin original + The security aspect of temporary file creation is emphasized such that a filehandle and filename are returned together. This helps guarantee that a race condition can not occur where the temporary file is @@ -125,6 +131,8 @@ check, for example, that the sticky bit is set on world writable directories. See L<"safe_level"> for more information. +=end original + °ì»þ¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë¤³¤È¤Î¥»¥¥å¥ê¥Æ¥£¤Î¦Ì̤¬¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È ¥Õ¥¡¥¤¥ë̾¤¬°ì½ï¤ËÊÖ¤µ¤ì¤ë¤È¤¤¤¦¤³¤È¤Ç¡¢¶¯Ä´¤µ¤ì¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¤«¤ò¥Á¥§¥Ã¥¯¤·¡¢¥Õ¥¡¥¤¥ë¤ò³«¤¤¤Æ¤¤¤ë´Ö¤Ë¡¢ @@ -135,35 +143,53 @@ ¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¤«¤Î¥Á¥§¥Ã¥¯¤Ç¤¹¡£ ¾ÜºÙ¤Ï¡¢L<"safe_level">¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£ +=begin original + For compatibility with popular C library functions, Perl implementations of the mkstemp() family of functions are provided. These are, mkstemp(), mkstemps(), mkdtemp() and mktemp(). +=end original + °ìÈÌŪ¤ÊC¥é¥¤¥Ö¥é¥ê´Ø¿ô¤È¤Î¸ß´¹À¤Î¤¿¤á¤Ë¡¢ mkstemp() ´Ø¿ô¤ÎÃç´Ö¤¬¡¢Perl¤Î¼ÂÁõ¤¬Ä󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£ mkstemp(), mkstemps(), mkdtemp, mktemp ¤¬¤¢¤ê¤Þ¤¹¡£ +=begin original + Additionally, implementations of the standard L<POSIX|POSIX> tmpnam() and tmpfile() functions are provided if required. +=end original + ¤¯¤ï¤¨¤Æ¡¢É¸½à¤ÎL<POSIX|POSIX>¤Î¼ÂÁõ¤Ç¤¢¤ë¡¢tmpnam() ¤È¡¢tmpfile() ¤¬¡¢É¬Íפʤ顢Ä󶡤µ¤ì¤Þ¤¹¡£ +=begin original + Implementations of mktemp(), tmpnam(), and tempnam() are provided, but should be used with caution since they return only a filename that was valid when function was called, so cannot guarantee that the file will not exist by the time the caller opens the filename. +=end original + mktemp(), tmpanam(), tempnam()¤Î¼ÂÁõ¤ÏÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ¤Ç¤¹¤¬¡¢ÍÑ¿´¤·¤Æ»È¤ï¤ì¤ë¤Ù¤¤Ç¤¹¡£¤È¤¤¤¦¤Î¤Ï¡¢¤³¤ì¤é¤Ï¡¢ ´Ø¿ô¤¬¸Æ¤Ð¤ì¤ë¤È¡¢ÂÅÅö¤Ê¥Õ¥¡¥¤¥ë̾¤À¤±¤òÊÖ¤·¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤¬¡¢¸Æ¤Ó½Ð¤·¤¿¿Í¤¬¥Õ¥¡¥¤¥ë¤ò³«¤¯»þ¤Ë¸ºß¤·¤Æ¤¤¤Ê¤¤¤³¤È¤òÊݾڤǤ¤Þ¤»¤ó¡£ -=head1 ´Ø¿ô +=head1 FUNCTIONS + +(´Ø¿ô) + +=begin original This section describes the recommended interface for generating temporary files and directories. +=end original + ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ç¤Ï¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤È¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤òÀ¸À®¤¹¤ë¤¿¤á¤Î¡¢ ¿ä¾©¤µ¤ì¤ë¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£ @@ -171,27 +197,39 @@ =item B<tempfile> +=begin original + This is the basic function to generate temporary files. The behaviour of the file can be changed using various options: +=end original + ¤³¤ì¤Ï¡¢´ðËÜŪ¤Ê´Ø¿ô¤Ç¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤òÀ¸À®¤·¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Î¿¶Éñ¤ÏÍÍ¡¹¤Ê¥ª¥×¥·¥ç¥ó¤Ç¡¢Êѹ¹¤Ç¤¤Þ¤¹: ($fh, $filename) = tempfile(); +=begin original + Create a temporary file in the directory specified for temporary files, as specified by the tmpdir() function in L<File::Spec>. +=end original + L<File::Spec>¤Îtmpdir() ´Ø¿ô¤ÇÆÃÄꤵ¤ì¤ë¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ëÍѤΥǥ£¥ì¥¯¥È¥ê¤Ë¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¤Þ¤¹¡£ ($fh, $filename) = tempfile($template); +=begin original + Create a temporary file in the current directory using the supplied template. Trailing `X' characters are replaced with random letters to generate the filename. At least four `X' characters must be present in the template. +=end original + ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë¡¢Ä󶡤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¤ò»È¤Ã¤Æ¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¤Þ¤¹¡£¥Õ¥¡¥¤¥ë¤òÀ¸À®¤¹¤ë¤¿¤á¤Ë¡¢ Ê£¿ô¤Î`X'ʸ»ú¤Î¸å¤òÄɤ¦¤â¤Î¤¬¥é¥ó¥À¥à¤Êʸ»ú¤Ë¡¢ÃÖ¤´¹¤¨¤é¤ì¤Þ¤¹¡£ @@ -199,11 +237,15 @@ ($fh, $filename) = tempfile($template, SUFFIX => $suffix) +=begin original + Same as previously, except that a suffix is added to the template after the `X' translation. Useful for ensuring that a temporary filename has a particular extension when needed by other applications. But see the WARNING at the end. +=end original + `X'¤ÎÊÑ´¹¤Î¸å¤Ë¡¢ÀÜÈø»þ¤¬²Ã¤¨¤é¤ì¤ë¤³¤È¤ò½ü¤¤¤Æ¡¢Á°¤Î¤â¤Î¤È¡¢Æ±¤¸¤Ç¤¹¡£ ¾¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÇɬÍפȤµ¤ì¤ë¤È¤¤Ë¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ËÆÃÊ̤γÈÄ¥»Ò¤¬¤¢¤ë¤è¤¦¤Ë¤·¤¿¤¤¤Ê¤é¡¢ÊØÍø¤Ç¤¹¡£ @@ -211,20 +253,28 @@ ($fh, $filename) = tempfile($template, DIR => $dir); +=begin original + Translates the template as before except that a directory name is specified. +=end original + ¥Ç¥£¥ì¥¯¥È¥ê¤Î̾Á°¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤Î¤ò½ü¤¤¤Æ¡¢ Á°¤Î¤è¤¦¤Ë¥Æ¥ó¥×¥ì¡¼¥È¤òÊÑ´¹¤·¤Þ¤¹¡£ ($fh, $filename) = tempfile($template, UNLINK => 1); +=begin original + Return the filename and filehandle as before except that the file is automatically removed when the program exits. Default is for the file to be removed if a file handle is requested and to be kept if the filename is requested. In a scalar context (where no filename is returned) the file is always deleted either on exit or when it is closed. +=end original + °ÊÁ°¤Î¤è¤¦¤Ë¡¢¥Õ¥¡¥¤¥ë̾¤È¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¤¬¡¢ ¥×¥í¥°¥é¥à¤¬exit¤·¤¿¤È¤¤Ë¡¢¼«Æ°Åª¤Ë¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤¬ºï½ü¤µ¤ì¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¥Õ¥¡¥¤¥ë¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬Í׵ᤵ¤ì¤ì¤Ðºï½ü¤µ¤ì¡¢ @@ -232,11 +282,15 @@ (¥Õ¥¡¥¤¥ë̾¤¬ÊÖ¤µ¤ì¤Ê¤¤)¥¹¥«¥é¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢exit¤«¡¢¥¯¥í¡¼¥º¤µ¤ì¤ì¤Ð¡¢ ¥Õ¥¡¥¤¥ë¤Ï¤¤¤Ä¤âºï½ü¤µ¤ì¤Þ¤¹¡£ +=begin original + If the template is not specified, a template is always automatically generated. This temporary file is placed in tmpdir() (L<File::Spec>) unless a directory is specified explicitly with the DIR option. +=end original + ¥Æ¥ó¥×¥ì¡¼¥È»ØÄꤷ¤Ê¤±¤ì¤Ð¡¢¥Æ¥ó¥×¥ì¡¼¥È¤Ï¤¤¤Ä¤â¡¢ ¼«Æ°Åª¤ËÀ¸À®¤µ¤ì¤Þ¤¹¡£¤³¤Î¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Ï¡¢ DIR¥ª¥×¥·¥ç¥ó¤Ç¡¢ÌÀ¼¨Åª¤Ë¥Ç¥£¥ì¥¯¥È¥ê¤¬»ØÄꤵ¤ì¤Ê¤±¤ì¤Ð¡¢ @@ -244,6 +298,8 @@ $fh = tempfile( $template, DIR => $dir ); +=begin original + If called in scalar context, only the filehandle is returned and the file will automatically be deleted when closed (see the description of tmpfile() elsewhere in this document). @@ -255,6 +311,8 @@ the file is marked for deletion when the program ends (equivalent to setting UNLINK to 1). The C<UNLINK> flag is ignored if present. +=end original + ¥¹¥«¥é¥³¥ó¥Æ¥¥¹¥È¤Ç¸Æ¤Ð¤ë¤È¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬ÊÖ¤µ¤ì¡¢ ¥¯¥í¡¼¥º¤µ¤ì¤ë¤È(¤³¤Î¥É¥¥å¥á¥ó¥È¤Î¾¤Î¾ì½ê¤Ç¡¢tmpfile ¤ò¸«¤Æ¤¯¤À¤µ¤¤)¡¢ ¥Õ¥¡¥¤¥ë¤Ï¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤Þ¤¹¡£ @@ -268,6 +326,8 @@ (undef, $filename) = tempfile($template, OPEN => 0); +=begin original + This will return the filename based on the template but will not open this file. Cannot be used in conjunction with UNLINK set to true. Default is to always open the file @@ -276,6 +336,8 @@ and mktemp() functions described elsewhere in this document if opening the file is not required. +=end original + ¤³¤ì¤Ï¡¢¥Æ¥ó¥×¥ì¡¼¥È¤ò¸µ¤Ë¤·¤¿¡¢¥Õ¥¡¥¤¥ë̾¤òÊÖ¤·¤Þ¤¹¡£ ¤Ç¤¹¤¬¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤ò³«¤¤Þ¤»¤ó¡£ UNILINK ¤ò¿¿¤Ë¥»¥Ã¥È¤·¤Æ¤Ï¡¢°ì½ï¤Ë»È¤¨¤Þ¤»¤ó¡£ @@ -286,31 +348,47 @@ ¤³¤Î¥É¥¥å¥á¥ó¥È¤Î¾¤Î¤É¤³¤«¤ËÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¡¢ tmpnam() ¤È¡¢mktemp() ´Ø¿ô¤ò»È¤¦¤³¤È¤ò¹Í¤¨¤Æ¤¯¤À¤µ¤¤¡£ +=begin original + Options can be combined as required. +=end original + ¥ª¥×¥·¥ç¥ó¤Ï¡¢É¬Íפ˱þ¤¸¤Æ¡¢ÁȤ߹ç¤ï¤»¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ =item B<tempdir> +=begin original + This is the recommended interface for creation of temporary directories. The behaviour of the function depends on the arguments: +=end original + ¤³¤ì¤Ï¡¢¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤¹¤ë¤¿¤á¤Î¿ä¾©¤µ¤ì¤ë¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ç¤¹¡£ ¤³¤Î´Ø¿ô¤Î¿¶Éñ¤Ï°ú¿ô¤Ë¤è¤ê¤Þ¤¹: $tempdir = tempdir(); +=begin original + Create a directory in tmpdir() (see L<File::Spec|File::Spec>). +=end original + tmpdir() ¤Ç¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤·¤Þ¤¹(L<File::Spec|File::Spec>¤ò¸«¤Æ¤¯¤À¤µ¤¤)¡£ $tempdir = tempdir( $template ); +=begin original + Create a directory from the supplied template. This template is similar to that described for tempfile(). `X' characters at the end of the template are replaced with random letters to construct the directory name. At least four `X' characters must be in the template. +=end original + Ä󶡤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¤«¤é¡¢¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤·¤Þ¤¹¡£ ¤³¤Î¥Æ¥ó¥×¥ì¡¼¥È¤Ïtempfile()¤ÇÀâÌÀ¤µ¤ì¤¿¤â¤Î¤È»÷¤Æ¤¤¤Þ¤¹¡£ ¥Æ¥ó¥×¥ì¡¼¥È¤Î½ª¤ê¤Î¡¢`X'ʸ»ú¤Ï¥é¥ó¥À¥à¤Êʸ»ú¤ËÃÖ¤´¹¤¨¤é¤ì¡¢ @@ -318,38 +396,54 @@ $tempdir = tempdir ( DIR => $dir ); +=begin original + Specifies the directory to use for the temporary directory. The temporary directory name is derived from an internal template. +=end original + ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤Ë»È¤¦¥Ç¥£¥ì¥¯¥È¥ê¤òÆÃÄꤷ¤Þ¤¹¡£ ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê̾¤Ï¡¢ÆâÉô¤Î¥Æ¥ó¥×¥ì¡¼¥È¤«¤éÀ¸À®¤µ¤ì¤Þ¤¹¡£ $tempdir = tempdir ( $template, DIR => $dir ); +=begin original + Prepend the supplied directory name to the template. The template should not include parent directory specifications itself. Any parent directory specifications are removed from the template before prepending the supplied directory. +=end original + Ä󶡤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¡¢¥Æ¥ó¥×¥ì¡¼¥È¤Ëpreend¤·¤Þ¤¹¡£ ¥Æ¥ó¥×¥ì¡¼¥È¤Ï¡¢¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î»ÅÍͤ½¤Î¤â¤Î¤ò´Þ¤à¤Ù¤¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ Ä󶡤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤¬¡¢prepend¤¹¤ëÁ°¤Ë¡¢¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î»ÅÍͤϡ¢¥Æ¥ó¥×¥ì¡¼¥È¤«¤éºï½ü¤µ¤ì¤Þ¤¹¡£ $tempdir = tempdir ( $template, TMPDIR => 1 ); +=begin original + Using the supplied template, creat the temporary directory in a standard location for temporary files. Equivalent to doing +=end original + Ä󶡤µ¤ì¤¿template¤ò»È¤¦¤È¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î¤¿¤á¤Îɸ½à¤Î¾ì½ê¤Ë¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤òºî¤ê¤Þ¤¹¡£¼¡¤Î¤è¤¦¤Ë¤¹¤ë¤Î¤ÈƱ¤¸¤Ç¤¹¡£ $tempdir = tempdir ( $template, DIR => File::Spec->tmpdir); +=begin original + but shorter. Parent directory specifications are stripped from the template itself. The C<TMPDIR> option is ignored if C<DIR> is set explicitly. Additionally, C<TMPDIR> is implied if neither a template nor a directory are supplied. +=end original + ¤Ç¤¹¤¬¡¢¾å¤ÎÊý¤¬¡¢Ã»¤¤¡£¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î»ÅÍͤϥƥó¥×¥ì¡¼¥È¼«¿È¤«¤é¡¢ ¤Ï¤®¼è¤é¤ì¤Þ¤¹¡£C<TMPDIR>¥ª¥×¥·¥ç¥ó¤ÏC<DIR>¤¬¡¢ÌÀ¼¨Åª¤Ë¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢ ̵»ë¤µ¤ì¤Þ¤¹¡£²Ã¤¨¤Æ¡¢¥Æ¥ó¥×¥ì¡¼¥È¤â¥Ç¥£¥ì¥¯¥È¥ê¤âÄ󶡤µ¤ì¤Ê¤±¤ì¤Ð¡¢ @@ -357,6 +451,8 @@ $tempdir = tempdir( $template, CLEANUP => 1); +=begin original + Create a temporary directory using the supplied template, but attempt to remove it (and all files inside it) when the program exits. Note that an attempt will be made to remove all files from @@ -366,6 +462,8 @@ Of course, if the template is not specified, the temporary directory will be created in tmpdir() and will also be removed at program exit. +=end original + ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤òÄ󶡤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¤ò»È¤Ã¤ÆºîÀ®¤·¤Þ¤¹¡£ ¤Ç¤¹¤¬¡¢¥×¥í¥°¥é¥à¤¬½ªÎ»¤¹¤ë¤È¤¤Ë¡¢¤½¤ì(¤È¡¢¤½¤ÎÃæ¤ÎÁ´¤Æ¤Î¥Õ¥¡¥¤¥ë)¤òºï½ü¤·¤è¤¦¤È¤·¤Þ¤¹¡£ »î¤ß¤Ï¡¢¤³¤Î¥â¥¸¥å¡¼¥ë¤¬ºî¤Ã¤Æ¤¤¤Ê¤¤¤â¤Î¤Þ¤Ç¤â¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤«¤é¡¢Á´¤Æ¤Î¥Õ¥¡¥¤¥ë¤ò @@ -376,11 +474,17 @@ =back -=head1 MKTEMP ´Ø¿ô +=head1 MKTEMP FUNCTIONS + +(MKTEMP ´Ø¿ô) + +=begin original The following functions are Perl implementations of the mktemp() family of temp file generation system calls. +=end original + ²¼µ¤Î´Ø¿ô¤Ï¡¢temp¥Õ¥¡¥¤¥ë¤òÀ¸À®¤¹¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¡¢ mktemp()¤ÎÃç´Ö¤Î¡¢Perl¤Î¼ÂÁõ¤Ç¤¹¡£ @@ -388,92 +492,144 @@ =item B<mkstemp> +=begin original + Given a template, returns a filehandle to the temporary file and the name of the file. +=end original + ¥Æ¥ó¥×¥ì¡¼¥È¤òÍ¿¤¨¤ë¤È¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¡¢¥Õ¥¡¥¤¥ë̾¤ò ÊÖ¤·¤Þ¤¹¡£ ($fh, $name) = mkstemp( $template ); +=begin original + In scalar context, just the filehandle is returned. +=end original + ¥¹¥«¥é¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤À¤±¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ +=begin original + The template may be any filename with some number of X's appended to it, for example F</tmp/temp.XXXX>. The trailing X's are replaced with unique alphanumeric combinations. +=end original + ¥Æ¥ó¥×¥ì¡¼¥È¤Ï¡¢¤¤¤¯¤Ä¤«¤Î`X'¤¬¤Ä¤±¤é¤ì¤¿¥Õ¥¡¥¤¥ë̾¤Ç¤·¤ç¤¦¡£ ¤¿¤È¤¨¤Ð¡¢F</tmp/tmp.XXXX>¡£¸å¤Î X¤Ï¡¢¥æ¥Ë¡¼¥¯¤Ê±Ñ¿ô»ú¤ÎÁȹ礻¤ËÃÖ¤´¹¤¨¤é¤ì¤Þ¤¹¡£ =item B<mkstemps> +=begin original + Similar to mkstemp(), except that an extra argument can be supplied with a suffix to be appended to the template. +=end original + mkstemp()¤Ë»÷¤Æ¤¤¤Þ¤¹¡£¤¿¤À¤·¡¢ÆÃÊ̤ʰú¿ô¤òÍ¿¤¨¤Æ¡¢ ¥Æ¥ó¥×¥ì¡¼¥È¤ËÀÜÈø»ú¤òÄɲ乤뤳¤È¤¬¤Ç¤¤Þ¤¹¡£ ($fh, $name) = mkstemps( $template, $suffix ); +=begin original + For example a template of C<testXXXXXX> and suffix of C<.dat> would generate a file similar to F<testhGji_w.dat>. +=end original + Î㤨¤Ð¡¢C<testXXXXXX>¤Î¥Æ¥ó¥×¥ì¡¼¥È¤È¡¢C<.dat>¤ÎÀÜÈø»ú¤Ï¡¢ F<testthGji_w.dat>¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¤òÀ¸À®¤¹¤ë¤Ç¤·¤ç¤¦¡£ +=begin original + Returns just the filehandle alone when called in scalar context. +=end original + ¥¹¥«¥é¥³¥ó¥Æ¥¥¹¥È¤Ç¸Æ¤Ð¤ì¤ë¤È¡¢¤¿¤À¡¢¥Õ¥¡¥¤¥ë̾¤À¤±¤òÊÖ¤·¤Þ¤¹¡£ =item B<mkdtemp> +=begin original + Create a directory from a template. The template must end in X's that are replaced by the routine. +=end original + ¥Æ¥ó¥×¥ì¡¼¥È¤«¤é¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤·¤Þ¤¹¡£ ¥ë¡¼¥Á¥ó¤Ë¤è¤Ã¤ÆÃÖ¤´¹¤¨¤é¤ì¤ë¥Æ¥ó¥×¥ì¡¼¥È¤Ï¡¢ Ê£¿ô¤ÎX¤Ç½ª¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ $tmpdir_name = mkdtemp($template); +=begin original + Returns the name of the temporary directory created. Returns undef on failure. +=end original + ºîÀ®¤µ¤ì¤¿¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤Î̾Á°¤òÊÖ¤·¤Þ¤¹¡£ ¼ºÇÔ¤¹¤ë¤Èundef¤¬ÊÖ¤ê¤Þ¤¹¡£ +=begin original + Directory must be removed by the caller. +=end original + ¥Ç¥£¥ì¥¯¥È¥ê¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Çºï½ü¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =item B<mktemp> +=begin original + Returns a valid temporary filename but does not guarantee that the file will not be opened by someone else. +=end original + ÂÅÅö¤Ê¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë̾¤òÊÖ¤·¤Þ¤¹¡£ ¤Ç¤¹¤¬¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤¬¡¢Â¾¤Î狼¤Ë³«¤«¤ì¤Æ¤¤¤Ê¤¤¤È¤ÏÊݾڤ·¤Þ¤»¤ó¡£ $unopened_file = mktemp($template); +=begin original + Template is the same as that required by mkstemp(). +=end original + ¥Æ¥ó¥×¥ì¡¼¥È¤Ï¡¢mkstemp()¤ÇɬÍפȤµ¤ì¤ë¤Î¤ÈƱ¤¸¤Ç¤¹¡£ =back -=head1 POSIX ´Ø¿ô +=head1 POSIX FUNCTIONS + +(POSIX ´Ø¿ô) + +=begin original This section describes the re-implementation of the tmpnam() and tmpfile() functions described in L<POSIX> using the mkstemp() from this module. +=end original + ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ï¡¢¤³¤Î¥â¥¸¥å¡¼¥ë¤«¤é mkstemp()¤ò»È¤Ã¤Æ¤¤¤ë¡¢ L<POSIX>¤ËÀâÌÀ¤µ¤ì¤Æ¤¤¤ë tmpnam()¤Ètmpfile()´Ø¿ô¤ÎºÆ¼ÂÁõ¤òÀâÌÀ¤·¤Æ¤¤¤Þ¤¹¡£ +=begin original + Unlike the L<POSIX|POSIX> implementations, the directory used for the temporary file is not specified in a system include file (C<P_tmpdir>) but simply depends on the choice of tmpdir() @@ -482,6 +638,8 @@ may not be secure. If this is a problem, simply use mkstemp() and specify a template. +=end original + L<POSIX|POSIX>¤Î¼ÂÁõ¤È¤Ï°ã¤¤¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Ë»È¤ï¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê ¤Ï¡¢¥·¥¹¥Æ¥àÆâÉô¤Î¥Õ¥¡¥¤¥ë(C<P_tmpdir>)¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢ ñ½ã¤Ë¡¢L<File::Spec|File::Spec>¤Ë¤è¤Ã¤Æ¡¢tmpdir()¤¬ÊÖ¤¹¤â¤Î¤ÎÁªÂò¤Ë°Í¤Ã¤Æ¤¤¤Þ¤¹¡£ @@ -493,86 +651,128 @@ =item B<tmpnam> +=begin original + When called in scalar context, returns the full name (including path) of a temporary file (uses mktemp()). The only check is that the file does not already exist, but there is no guarantee that that condition will continue to apply. +=end original + ¥¹¥«¥é¥³¥ó¥Æ¥¥¹¥È¤Ç¸Æ¤Ð¤ì¤¿¤é¡¢(mktemp()¤ò»È¤¦)¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î(¥Ñ¥¹¤ò´Þ¤ó¤À)¥Õ¥ë¥Í¡¼¥à¤òÊÖ¤·¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤¬´û¤Ë¸ºß¤·¤Ê¤¤¤³¤È¤À¤±¤ò¥Á¥§¥Ã¥¯¤·¤Þ¤¹¤¬¡¢¤½¤Î¾õÂÖ¤¬Å¬ÍѤµ¤ì³¤±¤ëÊݾڤϤ¢¤ê¤Þ¤»¤ó¡£ $file = tmpnam(); +=begin original + When called in list context, a filehandle to the open file and a filename are returned. This is achieved by calling mkstemp() after constructing a suitable template. +=end original + ÇÛÎó¥³¥ó¥Æ¥¥¹¥È¤Ç¸Æ¤Ð¤ì¤ë¤È¡¢¥Õ¥¡¥¤¥ë¤ò³«¤¯¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¡¢ ¥Õ¥¡¥¤¥ë̾¤¬ÊÖ¤ê¤Þ¤¹¡£Å¬Àڤʥƥó¥×¥ì¡¼¥È¤òÁȤßΩ¤Æ¤¿¸å¤Ë¡¢ mkstemp()¤ò¸Æ¤Ö¤³¤È¤Ç¡¢À®¸ù¤·¤Þ¤¹¡£ ($fh, $file) = tmpnam(); +=begin original + If possible, this form should be used to prevent possible race conditions. +=end original + ²Äǽ¤Ê¤é¡¢ÀøºßŪ¤Ê¶¥¹ç¾õÂÖ¤òËɤ°¤¿¤á¤Ë¡¢¤³¤Î·Á¤Ç»È¤¦¤Ù¤¤Ç¤¹¡£ +=begin original + See L<File::Spec/tmpdir> for information on the choice of temporary directory for a particular operating system. +=end original + ÆÃÄê¤Î¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¥·¥¹¥Æ¥à¤Ç¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤òÁªÂò¤¹¤ë¾ðÊó¤Ë¡¢ L<File::Spec/tmpdir>¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£ =item B<tmpfile> +=begin original + In scalar context, returns the filehandle of a temporary file. +=end original + ¥¹¥«¥é¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ $fh = tmpfile(); +=begin original + The file is removed when the filehandle is closed or when the program exits. No access to the filename is provided. +=end original + ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬ÊĤ¸¤é¤ì¤ë¤È¤¤«¡¢¥×¥í¥°¥é¥à¤¬½ªÎ»¤¹¤ë¤È¤¤Ë¡¢ ¥Õ¥¡¥¤¥ë¤Ïºï½ü¤µ¤ì¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë̾¤Ø¤Î¥¢¥¯¥»¥¹¤ÏÄ󶡤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ +=begin original + If the temporary file can not be created undef is returned. Currently this command will probably not work when the temporary directory is on an NFS file system. +=end original + ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤¬ºî¤é¤ì¤Ê¤±¤ì¤Ð¡¢undef¤¬ÊÖ¤ê¤Þ¤¹¡£ ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤¬¡¢NFS¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î¾ì¹ç¡¢ ¸½ºß¤Î¤È¤³¤í¡¢¤³¤Î¥³¥Þ¥ó¥É¤Ï¡¢¤ª¤½¤é¤¯Æ°¤¤Þ¤»¤ó¡£ =back -=head1 Äɲäδؿô +=head1 ADDITIONAL FUNCTIONS + +(Äɲäδؿô) + +=begin original These functions are provided for backwards compatibility with common tempfile generation C library functions. +=end original + ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢¶¦Ä̤Υƥó¥Ý¥é¥ê¥Õ¥¡¥¤¥ëÀ¸À®¤ÎC¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Î ¸åÊý¸ß´¹¤Î¤¿¤á¤Ë¡¢Ä󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£ +=begin original + They are not exported and must be addressed using the full package name. +=end original + ¥¤¥¯¥¹¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢´°Á´¤Ê¥Ñ¥Ã¥±¡¼¥¸Ì¾¤ò»È¤Ã¤Æµ½Ò¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =over 4 =item B<tempnam> +=begin original + Return the name of a temporary file in the specified directory using a prefix. The file is guaranteed not to exist at the time the function was called, but such guarantees are good for one clock tick only. Always use the proper form of C<sysopen> with C<O_CREAT | O_EXCL> if you must open such a filename. +=end original + preix ¤ò»È¤Ã¤Æ»ØÄꤷ¤¿¥Ç¥£¥ì¥¯¥È¥êÆâ¤Ë¡¢ ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë̾¤òÊÖ¤·¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Ï´Ø¿ô¤¬¸Æ¤Ð¤ì¤¿¤½¤Î¤È¤¤Ë¸ºß¤·¤Æ¤¤¤Ê¤¤¤³¤È¤òÊݾڤµ¤ì¤Þ¤¹¡£ @@ -582,28 +782,44 @@ $filename = File::Temp::tempnam( $dir, $prefix ); +=begin original + Equivalent to running mktemp() with $dir/$prefixXXXXXXXX (using unix file convention as an example) +=end original + $dir/$prefixXXXXXXXXX ¤Ç¡¢mktemp()¤ò¼Â¹Ô¤¹¤ë¤Î¤ÈƱ¤¸¤Ç¤¹¡£ (Îã¤È¤·¤Æ¡¢unix ¤Î¥Õ¥¡¥¤¥ë¤Î´·Îã¤ò»È¤¤¤Þ¤¹) +=begin original + Because this function uses mktemp(), it can suffer from race conditions. +=end original + ¤³¤Î´Ø¿ô¤Ï¡¢mktemp()¤ò»È¤¦¤Î¤Ç¡¢¶¥¹ç¾õÂÖ¤«¤éÈï³²¤òÈï¤ê¤¨¤Þ¤¹¡£ =back -=head1 ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô +=head1 UTILITY FUNCTIONS + +(¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô) + +=begin original Useful functions for dealing with the filehandle and filename. +=end original + ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¥Õ¥¡¥¤¥ë̾¤ò°·¤¦¡¢Í±×¤Ê´Ø¿ô¡£ =over 4 =item B<unlink0> +=begin original + Given an open filehandle and the associated filename, make a safe unlink. This is achieved by first checking that the filename and filehandle initially point to the same file and that the number of @@ -613,6 +829,8 @@ closest you can come to making sure that the filename unlinked was the same as the file whose descriptor you hold. +=end original + ³«¤¤¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¡¢´ØÏ¢¤Ä¤±¤é¤ì¤¿¥Õ¥¡¥¤¥ë̾¤òÍ¿¤¨¤ë¤È¡¢ °ÂÁ´¤Ë¡¢ºï½ü¤·¤Þ¤¹¡£¤³¤ì¤Ï¡¢¥Õ¥¡¥¤¥ë̾¤È¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬¡¢ Ʊ¤¸¥Õ¥¡¥¤¥ë¤ò»Ø¤·¡¢¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯¤Î¿ô¤¬¡¢°ì¤Ä¤Ç¤¢¤ë¤³¤È)(stat()¤¬ÊÖ¤¹Á´¤Æ¤Î¥Õ¥£¡¼¥ë¥É¤¬Èæ³Ó¤µ¤ì¤Þ¤¹)¤ò @@ -623,6 +841,8 @@ ³Î¤«¤á¤ë¤Î¤Ë¡¢ºÇ¤â¼þÅþ¤Ç¤¹¡£¥¨¥é¡¼»þ¤Ë¤Ïµ¶¤¬Ê֤ꡣ¾õ¶·¤Ë¤è¤ê¡¢É¬ÍפȤµ¤ì¤Ê¤¤¤Î¤Ç¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ï¡¢ÊĤ¸¤é¤ì¤Þ¤»¤ó¡£ +=begin original + On some platforms, for example Windows NT, it is not possible to unlink an open file (the file must be closed first). On those platforms, the actual unlinking is deferred until the program ends and @@ -631,6 +851,8 @@ the time the end block is executed since the deferred removal may not have access to the filehandle). +=end original + ¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤Ë¤è¤Ã¤Æ¤Ï(Î㤨¤Ð¡¢Windows NT)¡¢³«¤¤¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤òºï½ü¤Ç¤¤Ê¤¤¤â¤Î¤â¤¢¤ê¤Þ¤¹ (¥Õ¥¡¥¤¥ë¤Ï¤Þ¤ºÊĤ¸¤é¤ì¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó)¡£¤½¤ì¤é¤Î¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤Ç¤Ï¡¢ ¥×¥í¥°¥é¥à¤¬½ªÎ»¤·¡¢Îɤ¤¾õÂ֤ˤʤë¤Þ¤Ç¡¢¼ÂºÝ¤Îºï½ü¤Ï¿ø¤¨ÃÖ¤«¤ì¤Þ¤¹¡£ @@ -638,6 +860,8 @@ (¤Ç¤¹¤¬¡¢ºÇ¸å¤Î¥Ö¥í¥Ã¥¯¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Ê¤±¤ì¤Ð¡¢ ¿ø¤¨ÃÖ¤«¤ì¤¿ºï½ü¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ë¥¢¥¯¥»¥¹¤·¤Ê¤¤¤Ç¤·¤ç¤¦¡£) +=begin original + Additionally, on Windows NT not all the fields returned by stat() can be compared. For example, the C<dev> and C<rdev> fields seem to be different. Also, it seems that the size of the file returned by stat() @@ -646,6 +870,8 @@ using autoflush (this is usually overcome by waiting a while after writing to the tempfile before attempting to C<unlink0> it). +=end original + ¤µ¤é¤Ë¡¢Windows NT ¤Ï¡¢stat()¤¬Á´¤Æ¤Î¥Õ¥£¡¼¥ë¥É¤òÊÖ¤µ¤Ê¤¤¤³¤È¤¬Èæ³Ó¤µ¤ìÆÀ¤Þ¤¹¡£ Î㤨¤Ð¡¢C<dev>¤È¡¢C<rdev>¥Õ¥£¡¼¥ë¥É¤Ï¡¢°ã¤Ã¤Æ¤¤¤Þ¤¹¡£ ¤Þ¤¿¡¢stat()¤¬ÊÖ¤¹¥Õ¥¡¥¤¥ë¤Î¥µ¥¤¥º¤Ï¡¢¾ï¤Ë¤Ï°ìÃפ·¤Þ¤»¤ó¡£ @@ -654,30 +880,44 @@ (¤³¤ì¤Ï¡¢ÉáÄÌ¡¢°ì»þ¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤ó¤À¸å¡¢¤½¤ì¤òC<unlink0>¤¬»î¤µ¤ì¤ëÁ°¤Ë¡¢ ¤·¤Ð¤é¤¯ÂԤĤ³¤È¤Ç¡¢Âнè¤Ç¤¤Þ¤¹¡£) +=begin original + Finally, on NFS file systems the link count of the file handle does not always go to zero immediately after unlinking. Currently, this command is expected to fail on NFS disks. +=end original + ºÇ¸å¤Ë¡¢NFS¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¥ê¥ó¥¯¥«¥¦¥ó¥È¤Ï¡¢ ºï½ü¤Î¸å¡¢¤¹¤°¤Ë¤Ï¡¢¾ï¤Ë¤Ï0¤Ë¤Ê¤ê¤Þ¤»¤ó¡£ ¸½ºß¡¢¤³¤Î¥³¥Þ¥ó¥É¤Ï¡¢NFS¥Ç¥£¥¹¥¯¾å¤Ç¤Ï¡¢¼ºÇÔ¤¹¤ë¤È»×¤¤¤Þ¤¹¡£ =back -=head1 ¥Ñ¥Ã¥±¡¼¥¸ÊÑ¿ô +=head1 PACKAGE VARIABLES + +(¥Ñ¥Ã¥±¡¼¥¸ÊÑ¿ô) + +=begin original These functions control the global state of the package. +=end original + ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢¥Ñ¥Ã¥±¡¼¥¸¤Î¥°¥í¡¼¥Ð¥ë¤Ê¾õÂÖ¤ò¥³¥ó¥È¥í¡¼¥ë¤·¤Þ¤¹¡£ =over 4 =item B<safe_level> +=begin original + Controls the lengths to which the module will go to check the safety of the temporary file or directory before proceeding. Options are: +=end original + ¤³¤Î¥â¥¸¥å¡¼¥ë¤¬¡¢½èÍýÁ°¤Ë¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤«¡¢¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤ò¡¢°ÂÁ´¤Ë¥Á¥§¥Ã¥¯¤·¤è¤¦¤È¤¹¤ëÄøÅÙ¤ò¥³¥ó¥È¥í¡¼¥ë¤·¤Þ¤¹¡£ ¥ª¥×¥·¥ç¥ó: @@ -685,12 +925,16 @@ =item STANDARD +=begin original + Do the basic security measures to ensure the directory exists and is writable, that the umask() is fixed before opening of the file, that temporary files are opened only if they do not already exist, and that possible race conditions are avoided. Finally the L<unlink0|"unlink0"> function is used to remove files safely. +=end original + ´ðËÜŪ¤Ê¥»¥¥å¥ê¥Æ¥£¤ÎÄøÅ٤ǡ¢°Ê²¼¤Î¤³¤È¤òÊݾڤ·¤Þ¤¹¡£ ¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¸ºß¤·¡¢½ñ¤¹þ¤ß²Äǽ¤Ç¤¢¤ë¤³¤È¡£ ¥Õ¥¡¥¤¥ë¤ò³«¤¯Á°¤Ë¡¢umask()¤¬¸ÇÄꤵ¤ì¤Æ¤¤¤ë¤³¤È¡£ @@ -699,56 +943,82 @@ =item MEDIUM +=begin original + In addition to the STANDARD security, the output directory is checked to make sure that it is owned either by root or the user running the program. If the directory is writable by group or by other, it is then checked to make sure that the sticky bit is set. +=end original + STANDARD¤Î°ÂÁ´À¤Ë²Ã¤¨¤Æ¡¢½ÐÎϥǥ£¥ì¥¯¥È¥ê¤¬ root¤«¡¢¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¥æ¡¼¥¶ ¤Î¤É¤Á¤é¤«¤Ë¤è¤Ã¤Æ¡¢½êͤµ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Î¤«¤á¤ë¥Á¥§¥Ã¥¯¤ò¤·¤Þ¤¹¡£ ¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¾¤Î¥°¥ë¡¼¥×¤«¥æ¡¼¥¶¤Ë¤è¤Ã¤Æ½ñ¤¹þ¤ß²Äǽ¤Ç¤¢¤ë¤Ê¤é¤Ð¡¢ ¥¹¥Æ¥£¥Ã¥¡¼¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Î¤«¤á¤ë¥Á¥§¥Ã¥¯¤ò¤·¤Þ¤¹¡£ +=begin original + Will not work on platforms that do not support the C<-k> test for sticky bit. +=end original + ¥¹¥Æ¥£¥Ã¥¡¼¥Ó¥Ã¥È¤Î¤¿¤á¤Î¡¢ C<-k> ¥Æ¥¹¥È¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤¤¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤Ç¤Ï¡¢Æ°¤¤Þ¤»¤ó¡£ =item HIGH +=begin original + In addition to the MEDIUM security checks, also check for the possibility of ``chown() giveaway'' using the L<POSIX|POSIX> sysconf() function. If this is a possibility, each directory in the path is checked in turn for safeness, recursively walking back to the root directory. +=end original + MEDIUM¤Î°ÂÁ´À¥Á¥§¥Ã¥¯¤Ë²Ã¤¨¤Æ¡¢L<POSIX|POSIX> sysconf() ´Ø¿ô¤ò»È¤Ã¤Æ¡¢ ``chown() giveaway''¤Î²ÄǽÀ¤â¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£ ¤â¤·¤³¤ì¤¬²Äǽ¤Ê¤é¡¢¤½¤ì¤¾¤ì¤Î¥Ñ¥¹¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ï¡¢½çÈ֤ˡ¢°ÂÁ´¤ò¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£ ¥ë¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê¤Þ¤Ç¡¢Á̤äơ¢ºÆµ¢Åª¤Ë¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£ +=begin original + For platforms that do not support the L<POSIX|POSIX> C<_PC_CHOWN_RESTRICTED> symbol (for example, Windows NT) it is assumed that ``chown() giveaway'' is possible and the recursive test is performed. +=end original + L<POSIX|POSIX>¤ÎC<_PC_CHOWN_RESTRICTED>¥·¥ó¥Ü¥ë¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤¤¥×¥é¥Ã¥È¥Õ¥©¡¼¥à(¤¿¤È¤¨¤Ð¡¢Windows NT)¤Î¤¿¤á¤Ë¡¢ ¤³¤ì¤Ï¡¢``chown() giveaway'' ¤Ï¡¢²Äǽ¤Ç¤¢¤ê¡¢ºÆµ¢Åª¤Ê¥Æ¥¹¥È¤â¤Ê¤µ¤ì¤ë¤È²¾Äꤷ¤Þ¤¹¡£ =back +=begin original + The level can be changed as follows: +=end original + ¥ì¥Ù¥ë¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¡¢Êѹ¹¤Ç¤¤Þ¤¹: File::Temp->safe_level( File::Temp::HIGH ); +=begin original + The level constants are not exported by the module. +=end original + ¥ì¥Ù¥ëÄê¿ô¤Ï¥â¥¸¥å¡¼¥ë¤Ë¤è¤Ã¤Æ¡¢¥¨¥¯¥¹¥Ý¡¼¥È¤µ¤ì¤Þ¤»¤ó¡£ +=begin original + Currently, you must be running at least perl v5.6.0 in order to run with MEDIUM or HIGH security. This is simply because the safety tests use functions from L<Fcntl|Fcntl> that are not @@ -756,6 +1026,8 @@ number for Fcntl is the same in perl 5.6.0 and in 5.005_03 even though they are different versions. +=end original + MEDIUM¤«¡¢HIGH¤Î¥»¥¥å¥ê¥Æ¥£¤ò¼Â¹Ô¤¹¤ë¤¿¤á¤Ë¤Ï¡¢ º£¤Î¤È¤³¤í¡¢¤¹¤¯¤Ê¤¯¤È¤â¡¢Perl v5.6.0¤ÇÆ°¤«¤µ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ ¤³¤ì¤Ï¡¢Ã±½ã¤Ë¡¢°ÂÁ´¤Ê¥Æ¥¹¥È¤Ï¡¢v5.6.0¤è¤ê¸Å¤¤¥Ð¡¼¥¸¥ç¥ó¤Î perl¤Ç¤Ï¡¢ÍøÍѤǤ¤Ê¤¤¡¢ @@ -763,6 +1035,8 @@ perl 5.6.0 ¤È¡¢5.005_03¤Î Fcntl¤Î¥Ð¡¼¥¸¥ç¥óÈֹ椬¡¢¤½¤ì¤é¤Ï°ã¤¦¤â¤Î¤Ç¤¢¤ë¤Ë¤â¤«¤«¤ï¤é¤º¡¢ ¥Ð¡¼¥¸¥ç¥óÈֹ椬Ʊ¤¸¤Ç¤¢¤ë¤³¤È¤¬ÌäÂê¤Ç¤¹¡£ +=begin original + On systems that do not support the HIGH or MEDIUM safety levels (for example Win NT or OS/2) any attempt to change the level will be ignored. The decision to ignore rather than raise an exception @@ -770,6 +1044,8 @@ for the systems that can support this without those programs failing on systems where the extra tests are irrelevant. +=end original + HIGH¤È¡¢MEDIUM¤Î°ÂÁ´¥ì¥Ù¥ë¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤¤OS(Win NT ¤ä OS/2)¤Ç¤Ï¡¢ ¤¤¤¯¤é¥ì¥Ù¥ë¤òÊѹ¹¤·¤è¤¦¤È¤·¤Æ¤â¡¢Ìµ»ë¤µ¤ì¤Þ¤¹¡£ Îã³°¤òµ¯¤³¤¹¤è¤ê¤â¤à¤·¤í¡¢Ìµ»ë¤¹¤ë¤È¸À¤¦·èÄê¤Ë¤è¤ê¡¢ @@ -777,9 +1053,13 @@ ¹â¤¤°ÂÁ´À¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤³¤È¤¬½ÐÍè¤ë¥·¥¹¥Æ¥à¤Î¤³¤È¤ò¹Í¤¨¤Æ¡¢ ¹â¤¤¥»¥¥å¥ê¥Æ¥£¤Ç½ñ¤«¤ì¤Æ¤¤¤ë¥×¥í¥°¥é¥à¤ò¥Ý¡¼¥¿¥Ö¥ë¤Ë¤·¤Þ¤¹¡£ +=begin original + If you really need to see whether the change has been accepted simply examine the return value of C<safe_level>. +=end original + ¤â¤·¡¢¼ÂºÝ¤Ë¡¢Êѹ¹¤¬¼õ¤±Æþ¤ì¤é¤ì¤¿¤«¤É¤¦¤«¤ò¸«¤ëɬÍפ¬¤¢¤ë¤Ê¤é¡¢ ñ¤Ë¡¢C<safe_level>¤ÎÊÖÃͤò¤òÄ´¤Ù¤Æ¤¯¤À¤µ¤¤¡£ @@ -789,39 +1069,59 @@ =item TopSystemUID +=begin original + This is the highest UID on the current system that refers to a root UID. This is used to make sure that the temporary directory is owned by a system UID (C<root>, C<bin>, C<sys> etc) rather than simply by root. +=end original + ¤³¤ì¤Ï¡¢root UID¤ò»²¾È¤¹¤ë¡¢¸½ºß¤Î¥·¥¹¥Æ¥à¤Ç¤â¤Ã¤È¤â¹â¤¤UID¤Ç¤¹¡£ ¤³¤ì¤Ï¡¢¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤¬¡¢Ã±½ã¤Ëroot¤Î¤â¤Î¤Ç¤¢¤ë¤Î¤Ç¤Ï¤Ê¤¯¤Æ¡¢ ¥·¥¹¥Æ¥àUID¤Î¤â¤Î(C<root>, C<bin>, C<sys> ¤Ê¤É)¤Ç¤¢¤ë¤³¤È¤ò³Î¤«¤á¤ë¤Î¤Ë¡¢»È¤ï¤ì¤Þ¤¹¡£ +=begin original + This is required since on many unix systems C</tmp> is not owned by root. +=end original + ¿¤¯¤Îunix ¤Î¥·¥¹¥Æ¥à¤Ç¡¢C</tmp>¤Ï¡¢root ¤Î¤â¤Î¤Ç¤Ï¤Ê¤¤¤Î¤Ç¡¢ ¤³¤ì¤¬É¬ÍפȤµ¤ì¤Þ¤¹¡£ +=begin original + Default is to assume that any UID less than or equal to 10 is a root UID. +=end original + ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢10°Ê²¼¤Î¤â¤Î¤Ï¡¢¤É¤ó¤ÊUID¤â¡¢root UID¤ÈÁÛÄꤷ¤Þ¤¹¡£ File::Temp->top_system_uid(10); my $topid = File::Temp->top_system_uid; +=begin original + This value can be adjusted to reduce security checking if required. The value is only relevant when C<safe_level> is set to MEDIUM or higher. +=end original + ɬÍפʤé¤Ð¡¢¤³¤ÎÃͤòÄ´À°¤·¤Æ¡¢¥»¥¥å¥ê¥Æ¥£¥Á¥§¥Ã¥¯¤ò²¼¤²¤ë¤³¤È¤â¤Ç¤¤Þ¤¹¡£ ¤³¤ÎÃͤϡ¢C<safe_level>¤¬¡¢MEDIUM°Ê¾å¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¡¢´ØÏ¢¤¬¤¢¤ê¤Þ¤¹¡£ =back -=head1 ·Ù¹ð +=head1 WARNING + +(·Ù¹ð) + +=begin original For maximum security, endeavour always to avoid ever looking at, touching, or even imputing the existence of the filename. You do not @@ -830,18 +1130,24 @@ conditions. It's far more secure to use the filehandle alone and dispense with the filename altogether. +=end original + ºÇ¹â¤Î¥»¥¥å¥ê¥Æ¥£¤Î¤¿¤á¤Ë¤Ï¡¢Â¸ºß¤¹¤ë¥Õ¥¡¥¤¥ë̾¤ò¡¢Ä´¤Ù¤³¤È¡¢ ºîÀ®¤¹¤ë¤³¤È¡¢ÆþÎϤ¹¤ë¤³¤È¤òÈò¤±¤ë¤è¤¦¤Ë¡¢ÅØÎϤ·¤Æ²¼¤µ¤¤¡£ ¥Õ¥¡¥¤¥ë¥Í¡¼¥à¤¬¡¢»ý¤Ã¤Æ¤¤¤ë¥Ï¥ó¥É¥ë¤ÈƱ¤¸¥Õ¥¡¥¤¥ë¤ËÀܳ¤·¤Æ¤¤¤ë¤³¤È ¤òÃΤê¤Þ¤»¤ó¡£¤½¤ì¤Ë¡¢¤½¤ì¤¬¡¢¤è¤ê¿¤¯¤Î¶¥¹ç¾õÂÖ¤ò°ú¤µ¯¤³¤¹¤À¤±¤Ç¤¢¤ë¤³¤È¤ò ¥Á¥§¥Ã¥¯¤·¤è¤¦¤È¤Ï¤Ç¤¤Þ¤»¤ó(ÌõÃð:¡©)¡£ +=begin original + If you need to pass the handle to something that expects a filename then, on a unix system, use C<"/dev/fd/" . fileno($fh)> for arbitrary programs, or more generally C<< "+<=&" . fileno($fh) >> for Perl programs. You will have to clear the close-on-exec bit on that file descriptor before passing it to another process. +=end original + ¥Õ¥¡¥¤¥ë¥Í¡¼¥à¤ò´üÂÔ¤¹¤ë¤â¤Î¤Ë¡¢¥Ï¥ó¥É¥ë¤òÅϤ¹É¬Íפ¬¤¢¤ë¤Ê¤é¡¢ unix ¥·¥¹¥Æ¥à¤Ç¤Ï¡¢Ç¤°Õ¤Î¥×¥í¥°¥é¥à¤Î¤¿¤á¤Ë¡¢C<"/dev/fd/" . fileno($fh)> ¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ ¤Þ¤¿¤Ï¡¢¤è¤ê¡¢°ìÈÌŪ¤Ë¤Ï¡¢Perl¤Î¥×¥í¥°¥é¥à¤Î¤¿¤á¤Ë¡¢C<< "+<=&" . fileno($fh) >> @@ -855,6 +1161,8 @@ =head2 ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ÈNFS +=begin original + Some problems are associated with using temporary files that reside on NFS file systems and it is recommended that a local filesystem is used whenever possible. Some of the security tests will most probably @@ -862,6 +1170,8 @@ the performance of I/O operations over NFS will not be as good as for a local disk. +=end original + NFS¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤¢¤ë¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ò»È¤¦¤³¤È¤Ë´Ø¤·¤Æ¡¢ ¤¤¤¯¤Ä¤«¤ÎÌäÂ꤬¤¢¤ê¡¢½ÐÍè¤ë¸Â¤ê¡¢¥í¡¼¥«¥ë¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ò»È¤¦¤³¤È¤¬ ¿ä¾©¤µ¤ì¤Þ¤¹¡£¤¤¤¯¤Ä¤«¤Î¥»¥¥å¥ê¥Æ¥£¥Æ¥¹¥È¤Ï¡¢¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤¬¡¢ @@ -869,7 +1179,11 @@ ¹¹¤Ë¡¢NFS±Û¤·¤ÎI/OÁàºî¤Ï¡¢¥í¡¼¥«¥ë¥Ç¥£¥¹¥¯¤ÈÈæ¤Ù¤Æ¡¢Îɤ¯¤Ê¤¤¤³¤È¤Ë µ¤¤ò¤Ä¤±¤Æ²¼¤µ¤¤¡£ -=head1 ·Ð°Þ +=head1 HISTORY + +(·Ð°Þ) + +=begin original Originally began life in May 1999 as an XS interface to the system mkstemp() function. In March 2000, the OpenBSD mkstemp() code was @@ -877,6 +1191,8 @@ security checking, to ensure the presence of the function regardless of operating system and to help with portability. +=end original + ¤â¤È¤â¤È¤Ï¡¢1999ǯ¤Î5·î¤Ë¥·¥¹¥Æ¥à¤Îmkstemp()´Ø¿ô¤Ø¤ÎXS¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤È¤·¤Æ¡¢ Ëä¤Þ¤ì¤Þ¤·¤¿¡£2000ǯ5·î¤Ë¡¢OpenBSD¤Îmkstemp()¥³¡¼¥É¤¬¡¢¥³¡¼¥É¤Î¥»¥¥å¥ê¥Æ¥£¥Á¥§¥Ã¥¯ ¤ò¥È¡¼¥¿¥ë¤Ë¡¢¥³¥ó¥È¥í¡¼¥ë¤¹¤ë¤¿¤á¤Ë¡¢Perl¤Ë°Ü¿¢¤µ¤ì¤Þ¤·¤¿¡£ @@ -887,14 +1203,16 @@ L<POSIX/tmpnam>, L<POSIX/tmpfile>, L<File::Spec>, L<File::Path> +=begin original + See L<IO::File> and L<File::MkTemp> for different implementations of temporary file handling. -¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ò°·¤¦°ã¤Ã¤¿¼ÂÁõ¤Î¡¢L<IO::File>¤È¡¢L<File::MkTemp>¤â¸«¤Æ¤¯¤À¤µ¤¤¡£ +=end original -=head1 Ãø¼Ô +¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ò°·¤¦°ã¤Ã¤¿¼ÂÁõ¤Î¡¢L<IO::File>¤È¡¢L<File::MkTemp>¤â¸«¤Æ¤¯¤À¤µ¤¤¡£ -(¸¶Ê¸¤Þ¤Þ) +=head1 AUTHOR Tim Jenness E<lt>t.jen****@jach*****<gt>