Hi all!

On Do, 15 Nov 2007, Frank Küster wrote:
> >> do find the .dvi.gz file before the .html file. However, texdoclua
> >> returns only 'File exists' and *does not start the previewer*. I have
> 
> See above... I'll have a look, but not this weekend.

The problem is in the tmpdir creation:
                  tmpdir = os.tmpname();
                  is_ok_tmpdir,error_string = lfs.mkdir(tmpdir)
                  if is_ok_tmpdir then
                     --                   needs_cleanup = true;
                  else
                     print(error_string);
                     os.exit(1);
                  end

The problem is the following: os.tmpname in luatex CREATES a temporary
file, while the documentation of lua5.1 on the web tells that it only
creates a temporary file.

The problem is that tmpdir exists as file and lfs.mkdir returns an error.

The following patch uses tmpdir (renamed to tmpfile) as tmpfile.

Could be that this is racy and prone to symlink attack, no idea.

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <[EMAIL PROTECTED]>        Vienna University of Technology
Debian Developer <[EMAIL PROTECTED]>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
HALCRO (n.)
An adhesive fibrous cloth used to hold babies' clothes
together. Thousands of tiny pieces of jam 'hook' on to thousands of
tiny-pieces of dribble, enabling the cloth to become 'sticky'.
                        --- Douglas Adams, The Meaning of Liff
--- /usr/bin/texdoc	2007-11-11 21:45:47.000000000 +0100
+++ texdoc	2007-11-17 10:44:21.000000000 +0100
@@ -298,23 +298,16 @@
 		  -- uncompress only once per file, in case it is given more
 		  -- than once (dvi besides ps or so)
 		  -- TODO: to be done
-
-		  tmpdir = os.tmpname();
-		  is_ok_tmpdir,error_string = lfs.mkdir(tmpdir)
-		  if is_ok_tmpdir then
-		     -- 		  needs_cleanup = true;
-		  else
-		     print(error_string);
-		     os.exit(1);
-		  end
 		  
-		  unzip_commandline = unzip_command .. filename .. " > " .. tmpdir .. "/" .. basename;
+		  tmpfile = os.tmpname();
+		  
+		  unzip_commandline = unzip_command .. filename .. " > " .. tmpfile;
 		  if os.execute(unzip_commandline) then
-		     filename = tmpdir .. "/" .. basename;
+		     filename = tmpfile;
 		  else
 		     print("Error executing \n" .. unzip_commandline);
 		  end
-		  viewer_replacement = filename .. ';' .. rmfile_command .. filename .. ';' .. rmdir_command .. tmpdir;
+		  viewer_replacement = filename .. ';' .. rmfile_command .. tmpfile ;
 	       else
 		  if ext == '' then
 		     -- fallback if complete filename has been specified
@@ -347,4 +340,4 @@
    end -- if construct "case mode in"
 end -- for docname
 
--- cleanup_tmpdir();
+-- cleanup_tmpfile();

Reply via email to