Author: Ralf Treinen <treinen@debian.org>
Description: run bibtex in the directory where the .aux file resides, in 
 order work around security-enhanced bibtex that cannot write outside
 its working directory
Debian-Bug: #666572

Index: bibtex2html/main.ml
===================================================================
--- bibtex2html.orig/main.ml	2012-04-01 16:59:13.000000000 +0200
+++ bibtex2html/main.ml	2012-04-01 16:59:49.000000000 +0200
@@ -105,7 +105,12 @@
    \end{enumerate} *)
 
 let create_aux_file fbib tmp =
-  let ch = open_out (tmp ^ ".aux") in
+  let ch = open_out (tmp ^ ".aux")
+  and absolute_fbib =
+    if Filename.is_relative fbib
+    then Filename.concat (Sys.getcwd ()) fbib
+    else fbib
+  in
   output_string ch "\\relax\n\\bibstyle{";
   output_string ch !style;
   output_string ch "}\n";
@@ -116,7 +121,7 @@
   else
     output_string ch "\\citation{*}\n";
   output_string ch "\\bibdata{";
-  output_string ch (Filename.chop_suffix fbib ".bib");
+  output_string ch (Filename.chop_suffix absolute_fbib ".bib");
   output_string ch "}\n";
   close_out ch
 
@@ -143,7 +148,8 @@
       else 
 	"" 
     in
-    let cmd = sprintf "%s %s %s" !command tmp redir in
+    let cmd = sprintf "cd %s && %s %s %s"
+      (Filename.dirname tmp) !command (Filename.basename tmp) redir in
     if !Options.debug then begin 
       eprintf "\nbibtex command: %s\n" cmd; flush stderr
     end;
