[Pkg-bugzilla-commits] r73 - in trunk/bugzilla-2.18: Bugzilla debian debian/patches

Alexis Sukrieh sukria-guest@costa.debian.org
Sat, 23 Apr 2005 14:59:20 +0000


Author: sukria-guest
Date: 2005-04-23 14:59:19 +0000 (Sat, 23 Apr 2005)
New Revision: 73

Modified:
   trunk/bugzilla-2.18/Bugzilla/Config.pm
   trunk/bugzilla-2.18/debian/bugzilla.postinst
   trunk/bugzilla-2.18/debian/patches/003_Config.diff
Log:
customized WriteParams 

Modified: trunk/bugzilla-2.18/Bugzilla/Config.pm
===================================================================
--- trunk/bugzilla-2.18/Bugzilla/Config.pm	2005-04-23 14:45:24 UTC (rev 72)
+++ trunk/bugzilla-2.18/Bugzilla/Config.pm	2005-04-23 14:59:19 UTC (rev 73)
@@ -56,6 +56,7 @@
 our $datadir = "$libpath/web/data";
 our $templatedir = "$libpath/template";
 our $webdotdir = "$datadir/webdot";
+our $params_file = "/etc/bugzilla/params";
 
 # Module stuff
 @Bugzilla::Config::EXPORT = qw(Param);
@@ -105,22 +106,22 @@
     # read in localconfig variables
     do $localconfig;
 
-    if (-e "$datadir/params") {
+    if (-e $params_file) {
         # Handle reading old param files by munging the symbol table
         # Don't have to do this if we use safe mode, since its evaled
         # in a sandbox where $foo is in the same module as $::foo
         #local *::param = \%param;
 
-        # Note that checksetup.pl sets file permissions on '$datadir/params'
+        # Note that checksetup.pl sets file permissions on $params_file
 
         # Using Safe mode is _not_ a guarantee of safety if someone does
         # manage to write to the file. However, it won't hurt...
         # See bug 165144 for not needing to eval this at all
         my $s = new Safe;
 
-        $s->rdo("$datadir/params");
-        die "Error reading $datadir/params: $!" if $!;
-        die "Error evaluating $datadir/params: $@" if $@;
+        $s->rdo($params_file);
+        die "Error reading $params_file: $!" if $!;
+        die "Error evaluating $params_file: $@" if $@;
 
         # Now read the param back out from the sandbox
         %param = %{$s->varglob('param')};
@@ -260,13 +261,21 @@
 
     print $fh (Data::Dumper->Dump([ \%param ], [ '*param' ]))
       || die "Can't write param file: $!";
-
     close $fh;
 
-    rename $tmpname, "$datadir/params"
-      || die "Can't rename $tmpname to $datadir/params: $!";
+    # We write it by hand
+    # this works really better than the original rename() call
+    # and will prevent overwriting of symlinks.
+    open TMPFILE, "<$tmpname" or die "$!";
+    open PARAMSFILE, ">$params_file" or die $!;
+    while (<TMPFILE>) {
+           print PARAMSFILE $_;
+    }
+    close TMPFILE;
+    close PARAMSFILE;
+    unlink $tmpname;
 
-    ChmodDataFile("$datadir/params", 0666);
+    ChmodDataFile($params_file, 0666);
 }
 
 # Some files in the data directory must be world readable iff we don't have

Modified: trunk/bugzilla-2.18/debian/bugzilla.postinst
===================================================================
--- trunk/bugzilla-2.18/debian/bugzilla.postinst	2005-04-23 14:45:24 UTC (rev 72)
+++ trunk/bugzilla-2.18/debian/bugzilla.postinst	2005-04-23 14:59:19 UTC (rev 73)
@@ -51,7 +51,7 @@
 	
 	params_218_src="/usr/share/bugzilla/debian/params"
 	params_218_dest="/etc/bugzilla/params"
-	params_218_new="/etc/bugzilla/params.new"
+	params_218_new="/usr/share/bugzilla/debian/params.new"
 	
 	# manage the upgrade before 2.18
 	# We aim here to upgrade the params file from oldest version.

Modified: trunk/bugzilla-2.18/debian/patches/003_Config.diff
===================================================================
--- trunk/bugzilla-2.18/debian/patches/003_Config.diff	2005-04-23 14:45:24 UTC (rev 72)
+++ trunk/bugzilla-2.18/debian/patches/003_Config.diff	2005-04-23 14:59:19 UTC (rev 73)
@@ -1,5 +1,5 @@
---- bugzilla-21.8.orig/Bugzilla/Config.pm	2005-04-23 16:14:44.260415040 +0200
-+++ bugzilla-2.18/Bugzilla/Config.pm	2005-04-23 16:14:09.703668464 +0200
+--- bugzilla-2.18.orig/Bugzilla/Config.pm	2005-04-23 17:01:22.933951992 +0200
++++ bugzilla-2.18/Bugzilla/Config.pm	2005-04-23 17:05:09.028580384 +0200
 @@ -56,6 +56,7 @@
  our $datadir = "$libpath/web/data";
  our $templatedir = "$libpath/template";
@@ -36,14 +36,26 @@
  
          # Now read the param back out from the sandbox
          %param = %{$s->varglob('param')};
-@@ -263,10 +264,10 @@
+@@ -260,13 +261,21 @@
  
+     print $fh (Data::Dumper->Dump([ \%param ], [ '*param' ]))
+       || die "Can't write param file: $!";
+-
      close $fh;
  
 -    rename $tmpname, "$datadir/params"
 -      || die "Can't rename $tmpname to $datadir/params: $!";
-+    rename $tmpname, $params_file
-+      || die "Can't rename $tmpname to $params_file: $!";
++    # We write it by hand
++    # this works really better than the original rename() call
++    # and will prevent overwriting of symlinks.
++    open TMPFILE, "<$tmpname" or die "$!";
++    open PARAMSFILE, ">$params_file" or die $!;
++    while (<TMPFILE>) {
++           print PARAMSFILE $_;
++    }
++    close TMPFILE;
++    close PARAMSFILE;
++    unlink $tmpname;
  
 -    ChmodDataFile("$datadir/params", 0666);
 +    ChmodDataFile($params_file, 0666);