[otrs-cvs] otrs/Kernel/System/Ticket ArticleStorageFS.pm, 1.79, 1.79.2.1

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/Kernel/System/Ticket
In directory lancelot:/tmp/cvs-serv19893/Kernel/System/Ticket

Modified Files:
      Tag: rel-3_1
	ArticleStorageFS.pm 
Log Message:
 - 2012-12-03 Fixed bug#8933 - ArticleStorageInit permission check problem.

Author: mg

Index: ArticleStorageFS.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/Ticket/ArticleStorageFS.pm,v
retrieving revision 1.79
retrieving revision 1.79.2.1
diff -2 -u -d -r1.79 -r1.79.2.1
--- ArticleStorageFS.pm	20 Mar 2012 20:43:59 -0000	1.79
+++ ArticleStorageFS.pm	3 Dec 2012 11:42:02 -0000	1.79.2.1
@@ -15,7 +15,7 @@
 use warnings;
 
-use File::Path;
-use File::Basename;
-use MIME::Base64;
+use File::Path qw();
+use MIME::Base64 qw();
+use Time::HiRes qw();
 
 use Kernel::System::VariableCheck qw(:all);
@@ -40,14 +40,12 @@
     $Self->{ArticleContentPath} = $Year . '/' . $Month . '/' . $Day;
 
-    # check fs write permissions!
-    my $Path = "$Self->{ArticleDataDir}/$Self->{ArticleContentPath}/check_permissions.$$";
-    if ( -d $Path ) {
-        File::Path::rmtree( [$Path] );
-    }
-    if ( mkdir( "$Self->{ArticleDataDir}/check_permissions_$$", 022 ) ) {
-        rmdir("$Self->{ArticleDataDir}/check_permissions_$$");
-        if ( File::Path::mkpath( [$Path], 0, 0775 ) ) {
-            File::Path::rmtree( [$Path] );
-        }
+    # Check fs write permissions.
+    # Generate a thread-safe article check directory.
+    my ( $Seconds, $Microseconds ) = Time::HiRes::gettimeofday();
+    my $PermissionCheckDirectory
+        = "check_permissions_${$}_" . ( int rand 1_000_000_000 ) . "_${Seconds}_${Microseconds}";
+    my $Path = "$Self->{ArticleDataDir}/$Self->{ArticleContentPath}/" . $PermissionCheckDirectory;
+    if ( File::Path::make_path( $Path, { mode => 0775 } ) ) {
+        rmdir $Path;
     }
     else {
@@ -55,9 +53,7 @@
         $Self->{LogObject}->Log(
             Priority => 'notice',
-            Message  => "Can't create $Self->{ArticleDataDir}/check_permissions_$$: $Error, "
-                . "Try: \$OTRS_HOME/bin/otrs.SetPermissions.pl !",
+            Message  => "Can't create $Path: $Error, try: \$OTRS_HOME/bin/otrs.SetPermissions.pl!",
         );
-        die "Error: Can't create $Self->{ArticleDataDir}/check_permissions_$$: $Error \n\n "
-            . "Try: \$OTRS_HOME/bin/otrs.SetPermissions.pl !!!\n";
+        die "Can't create $Path: $Error, try: \$OTRS_HOME/bin/otrs.SetPermissions.pl!";
     }
     return 1;
@@ -704,5 +700,5 @@
         # decode attachment if it's e. g. a postgresql backend!!!
         if ( !$Self->{DBObject}->GetDatabaseFunction('DirectBlob') ) {
-            $Data{Content} = decode_base64( $Row[1] );
+            $Data{Content} = MIME::Base64::decode_base64( $Row[1] );
         }
         else {
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.