[Rt-commit] rt branch, 4.2/html-external-formatters-writable-home, created. rt-4.2.10rc1-1-g092d406

? sunnavy sunnavy at bestpractical.com
Tue Feb 24 10:45:59 EST 2015


The branch, 4.2/html-external-formatters-writable-home has been created
        at  092d406e21b9b71a318ed93cae1695c594bf93c1 (commit)

- Log -----------------------------------------------------------------
commit 092d406e21b9b71a318ed93cae1695c594bf93c1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 24 21:02:57 2015 +0800

    make external formatters write to tmpdir instead
    
    in 927ece5, we set $ENV{HOME} to specify a dir external formatters can write
    under, but the dir we chose($RT::VarPath) isn't writable by web user by default.
    depending on the layout user chooses, $RT::VarPath could be /var, which makes
    it impossible to chown it to web user
    
    this commit changes it to tmpdir to make sure it's writable.

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 18fd1d3..7c36441 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -59,6 +59,7 @@ use File::Temp;
 use Mail::Mailer ();
 use Text::ParseWords qw/shellwords/;
 use RT::Util 'safe_run_child';
+use File::Spec;
 
 BEGIN {
     use base 'Exporter';
@@ -1834,7 +1835,7 @@ sub _HTMLFormatter {
 
             if ($path) {
                 local $ENV{PATH} = $path;
-                local $ENV{HOME} = $RT::VarPath;
+                local $ENV{HOME} = File::Spec->tmpdir();
                 if (not defined $package->program_version) {
                     RT->Logger->warn("Could not find or run external '$prog' HTML formatter in $path$prog")
                         if $wanted;
@@ -1843,7 +1844,7 @@ sub _HTMLFormatter {
             } else {
                 local $ENV{PATH} = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
                     unless defined $ENV{PATH};
-                local $ENV{HOME} = $RT::VarPath;
+                local $ENV{HOME} = File::Spec->tmpdir();
                 if (not defined $package->program_version) {
                     RT->Logger->warn("Could not find or run external '$prog' HTML formatter in \$PATH ($ENV{PATH}) -- you may need to install it or provide the full path")
                         if $wanted;
@@ -1857,7 +1858,7 @@ sub _HTMLFormatter {
                 my $text = RT::Util::safe_run_child {
                     local $ENV{PATH} = $path || $ENV{PATH}
                         || '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin';
-                    local $ENV{HOME} = $RT::VarPath;
+                    local $ENV{HOME} = File::Spec->tmpdir();
                     $package->format_string(
                         Encode::encode( "UTF-8", $html ),
                         input_charset => "UTF-8",

-----------------------------------------------------------------------


More information about the rt-commit mailing list