[plexus-utils]/[plexus-archiver] Unarchiver hangs on linux if a directory contains a dollar in his name

View: New views
2 Messages — Rating Filter:   Alert me  

Parent Message unknown [plexus-utils]/[plexus-archiver] Unarchiver hangs on linux if a directory contains a dollar in his name

by Vincent S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm currently trying to use plexus-archiver (version 1.0-alpha-12 in
relation with plexus-utils version 1.5.5.) in a backup plugin for
hudson.

The unarchiver hangs when a directory in the archive contains a dollar
in his name due to the chmod called during the unarchive phase.

I'm not sure if the problem comes from a wrong usage of plexus-utils on
plexus-archiver or from plexus-utils itself.

I solve it modifying the BourneShell.java in plexus-utils, but
I'm not successful to reproduce it in a  plexus-utils
testcase.

I put in attachement the patches for plexus-utils (with the test-case
not reproducing the problem ;)) and for plexus-archiver (add a failing test
when the plexus-utils patch is not applied).

What are you thinking about this problem ?

Thanks
Vincent



Re: [plexus-utils]/[plexus-archiver] Unarchiver hangs on linux if a directory contains a dollar in his name

by Vincent S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

oups, with the patches.....

Vincent



On Tue, Jun 2, 2009 at 12:20 AM, vincent sellier <vincent.sellier@...> wrote:
Hi,

I'm currently trying to use plexus-archiver (version 1.0-alpha-12 in
relation with plexus-utils version 1.5.5.) in a backup plugin for
hudson.

The unarchiver hangs when a directory in the archive contains a dollar
in his name due to the chmod called during the unarchive phase.

I'm not sure if the problem comes from a wrong usage of plexus-utils on
plexus-archiver or from plexus-utils itself.

I solve it modifying the BourneShell.java in plexus-utils, but
I'm not successful to reproduce it in a  plexus-utils

testcase.

I put in attachement the patches for plexus-utils (with the test-case
not reproducing the problem ;)) and for plexus-archiver (add a failing test
when the plexus-utils patch is not applied).

What are you thinking about this problem ?

Thanks
Vincent




[plexus-archiver_test-for-directory-with-dollar.patch]

Index: src/test/java/org/codehaus/plexus/archiver/tar/TarGZipUnArchiverTest.java
===================================================================
--- src/test/java/org/codehaus/plexus/archiver/tar/TarGZipUnArchiverTest.java (revision 8251)
+++ src/test/java/org/codehaus/plexus/archiver/tar/TarGZipUnArchiverTest.java (working copy)
@@ -52,6 +52,9 @@
 
         tarArchiver.addFile( getTestFile( "src/test/resources/manifests/manifest1.mf" ), fileName1 );
         tarArchiver.addFile( getTestFile( "src/test/resources/manifests/manifest2.mf" ), fileName2, 0664 );
+        tarArchiver.addFile( getTestFile( "src/test/resources/manifests/manifest2.mf" ), fileName2, 0664 );
+        tarArchiver.addFile( getTestFile( "src/test/resources/escapable/test$file.txt" ), "escapable/test$file.txt", 0664 );
+        tarArchiver.addFile( getTestFile( "src/test/resources/escapable/escapable$directory/test$file.txt" ), "escapable/escapable$directory/test$file.txt", 0664 );
         tarArchiver.setDestFile( getTestFile( "target/output/archive.tar" ) );
         tarArchiver.createArchive();
 
Index: src/test/resources/escapable/test$file.txt
===================================================================
--- src/test/resources/escapable/test$file.txt (revision 0)
+++ src/test/resources/escapable/test$file.txt (revision 0)
@@ -0,0 +1 @@
+this is a file with an escapable name
\ No newline at end of file
Index: src/test/resources/escapable/escapable$directory/test$file.txt
===================================================================
--- src/test/resources/escapable/escapable$directory/test$file.txt (revision 0)
+++ src/test/resources/escapable/escapable$directory/test$file.txt (revision 0)
@@ -0,0 +1 @@
+this is a file with an escapable name
\ No newline at end of file


[plexus-utils_directory-with-dollar.patch]

Index: src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java
===================================================================
--- src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java (revision 8251)
+++ src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java (working copy)
@@ -83,6 +83,14 @@
             fail( e.getMessage() );
         }
     }
+            
+    public void testCommandlineWithDollarInPath() throws Exception {
+        Commandline cmd = new Commandline( "echo", new BourneShell() );
+        cmd.setWorkingDirectory( baseDir + "/src/test/resources/name$dollar" );
+
+        cmd.execute();
+
+    }
 
     public void testCommandlineWithCommandInConstructor()
     {
Index: src/test/resources/name$dollar/file.txt
===================================================================
--- src/test/resources/name$dollar/file.txt (revision 0)
+++ src/test/resources/name$dollar/file.txt (revision 0)
@@ -0,0 +1 @@
+file in a directory with a $ in his name
Index: src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java
===================================================================
--- src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java (revision 8251)
+++ src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java (working copy)
@@ -134,7 +134,9 @@
             dir = StringUtils.replace( dir, "'", "\\\'" );
         }
 
-        sb.append( StringUtils.quoteAndEscape( dir, '\"' ) );
+        String quotedDir = StringUtils.quoteAndEscape( dir, '\"', new char[] { '$' }, getQuotingTriggerChars(), '\\', false);
+
+        sb.append( quotedDir  );
         sb.append( " && " );
 
         return sb.toString();


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email