Skip Menu |

This queue is for tickets about the libnet CPAN distribution.

Report information
The Basics
Id: 50849
Status: resolved
Priority: 0/
Queue: libnet

People
Owner: Nobody in particular
Requestors: Jamie.Young [...] datamail.co.nz
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.22_01



Subject: Net::FTP Bug 41878
Date: Tue, 27 Oct 2009 09:57:50 +1300
To: <bug-libnet [...] rt.cpan.org>
From: "Jamie Young" <Jamie.Young [...] datamail.co.nz>
Hello, This bug has been opened since December 22 2008. I took a look at the code in the Net::FTP module - it looks like fixing it should be pretty simple. I'm a unix admin and do a lot of perl programming - can I write a block of code that would fix this bug to help out? I'm going to have to write a workaround in my code anyway. Thanks, Jamie Young Unix Administrator Enterprise Services Datamail Ltd 1 Victoria Street Petone Lower Hutt 5012 PO Box 31249 Lower Hutt 5040 Phone: + 64 4 568 8200 Extn: 8718 DDI: + 64 4 576 4325 Fax: + 64 4 568 9600 www.datamail.co.nz <http://www.datamail.co.nz/> </PRE><div style="font-size:8pt;font-family:Tahoma,Arial; text-align:justify; color:gray;"><br><br><hr size="0"> At the Datamail Group we value teamwork, respect, achievement, client focus, and courage.<br><br>This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by replying immediately, destroy it and do not copy, disclose or use it in any way.<br><br></div> <span lang=EN-AU style='font-size:18.0pt;font-family:Webdings; color:green'>P</span><span lang=EN-AU>&nbsp;</span><span lang=EN-AU style='font-size:7.5pt;font-family:"Verdana","sans-serif"'> <span style='color:green'>The Datamail Group, through our GoGreen programme, is committed to environmental sustainability. Help us in our efforts by not printing this email.</span></span><hr size="0"> </PRE><div style="font-size:8pt;font-family:Arial; text-align:center;"><br><br><hr size="0"> This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite.<br> Please see <a href="http://www.dmzglobal.com/dmzmessaging.htm">http://www.dmzglobal.com/dmzmessaging.htm</a> for details.<br> <hr size="0"><br><br></div>
Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Mon, 26 Oct 2009 16:00:45 -0500
To: bug-libnet [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Oct 26, 2009, at 3:58 PM, Jamie Young via RT wrote: Show quoted text
> This bug has been opened since December 22 2008. I took a look at the > code in the Net::FTP module - it looks like fixing it should be pretty > simple. I'm a unix admin and do a lot of perl programming - can I > write > a block of code that would fix this bug to help out? I'm going to have > to write a workaround in my code anyway.
sure any help is appreciated. if you are familiar with git then there is a git repository on github at http://github.com/gbarr/perl-libnet Thanks, Graham.
Subject: RE: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Tue, 27 Oct 2009 11:06:57 +1300
To: <bug-libnet [...] rt.cpan.org>
From: "Jamie Young" <Jamie.Young [...] datamail.co.nz>
I'm not familiar with github - do I need to submit something to some kind of SVN or something? To fix the bug you only need to comment out/remove the lines I've highlighted below in the rmdir subroutine. If it fails to delete a file it may be because of the permissions of the file itself are too tight, not just that it's a directory. sub rmdir { @_ == 2 || @_ == 3 or croak('usage: $ftp->rmdir( DIR [, RECURSE ] )'); # Pick off the args my ($ftp, $dir, $recurse) = @_; my $ok; return $ok if $ok = $ftp->_RMD($dir) or !$recurse; # Try to delete the contents # Get a list of all the files in the directory my @filelist = grep { !/^\.{1,2}$/ } $ftp->ls($dir); return undef unless @filelist; # failed, it is probably not a directory # Go thru and delete each file or the directory my $file; foreach $file (map { m,/, ? $_ : "$dir/$_" } @filelist) { next # successfully deleted the file if $ftp->delete($file); # Failed to delete it, assume its a directory # Recurse and ignore errors, the final rmdir() will # fail on any errors here return $ok unless $ok = $ftp->rmdir($file, 1); } # Directory should be empty # Try to remove the directory again # Pass results directly to caller # If any of the prior deletes failed, this # rmdir() will fail because directory is not empty return $ftp->_RMD($dir); } Thanks, Jamie Young Unix Administrator Enterprise Services Datamail Ltd 1 Victoria Street Petone Lower Hutt 5012 PO Box 31249 Lower Hutt 5040 Phone: + 64 4 568 8200 Extn: 8718 DDI: + 64 4 576 4325 Fax: + 64 4 568 9600 www.datamail.co.nz Show quoted text
-----Original Message----- From: Graham Barr via RT [mailto:bug-libnet@rt.cpan.org] Sent: Tuesday, 27 October 2009 10:01 a.m. To: Jamie Young Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878 <URL: https://rt.cpan.org/Ticket/Display.html?id=50849 > On Oct 26, 2009, at 3:58 PM, Jamie Young via RT wrote:
> This bug has been opened since December 22 2008. I took a look at the > code in the Net::FTP module - it looks like fixing it should be pretty > simple. I'm a unix admin and do a lot of perl programming - can I > write > a block of code that would fix this bug to help out? I'm going to have > to write a workaround in my code anyway.
sure any help is appreciated. if you are familiar with git then there is a git repository on github at http://github.com/gbarr/perl-libnet Thanks, Graham. </PRE><div style="font-size:8pt;font-family:Tahoma,Arial; text-align:justify; color:gray;"><br><br><hr size="0"> At the Datamail Group we value teamwork, respect, achievement, client focus, and courage.<br><br>This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by replying immediately, destroy it and do not copy, disclose or use it in any way.<br><br></div> <span lang=EN-AU style='font-size:18.0pt;font-family:Webdings; color:green'>P</span><span lang=EN-AU>&nbsp;</span><span lang=EN-AU style='font-size:7.5pt;font-family:"Verdana","sans-serif"'> <span style='color:green'>The Datamail Group, through our GoGreen programme, is committed to environmental sustainability. Help us in our efforts by not printing this email.</span></span><hr size="0"> </PRE><div style="font-size:8pt;font-family:Arial; text-align:center;"><br><br><hr size="0"> This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite.<br> Please see <a href="http://www.dmzglobal.com/dmzmessaging.htm">http://www.dmzglobal.com/dmzmessaging.htm</a> for details.<br> <hr size="0"><br><br></div>
Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Mon, 26 Oct 2009 17:57:39 -0500
To: bug-libnet [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Oct 26, 2009, at 5:07 PM, Jamie Young via RT wrote: Show quoted text
> Queue: libnet > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50849 > > > I'm not familiar with github - do I need to submit something to some > kind of SVN or something?
if you are not familiar do not worry about it Show quoted text
> To fix the bug you only need to comment out/remove the lines I've > highlighted below in the rmdir subroutine. If it fails to delete a > file it may be because of the permissions of the file itself are too > tight, not just that it's a directory.
the ticket system removes any markup you may have added. please send a diff of the changes Graham.
Subject: RE: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Tue, 27 Oct 2009 12:26:07 +1300
To: <bug-libnet [...] rt.cpan.org>
From: "Jamie Young" <Jamie.Young [...] datamail.co.nz>
I've done a diff of before & after: is this what you want? 602,603c602,603 < return $ok < unless $ok = $ftp->rmdir($file, 1); --- Show quoted text
> #return $ok > #unless $ok = $ftp->rmdir($file, 1);
Thanks, Jamie Young Unix Administrator Enterprise Services Datamail Ltd 1 Victoria Street Petone Lower Hutt 5012 PO Box 31249 Lower Hutt 5040 Phone: + 64 4 568 8200  Extn: 8718 DDI:     + 64 4 576 4325 Fax:     + 64 4 568 9600 www.datamail.co.nz Show quoted text
-----Original Message----- From: Graham Barr via RT [mailto:bug-libnet@rt.cpan.org] Sent: Tuesday, 27 October 2009 11:58 a.m. To: Jamie Young Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878 <URL: http://rt.cpan.org/Ticket/Display.html?id=50849 > On Oct 26, 2009, at 5:07 PM, Jamie Young via RT wrote:
> Queue: libnet > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50849 > > > I'm not familiar with github - do I need to submit something to some > kind of SVN or something?
if you are not familiar do not worry about it
> To fix the bug you only need to comment out/remove the lines I've > highlighted below in the rmdir subroutine. If it fails to delete a > file it may be because of the permissions of the file itself are too > tight, not just that it's a directory.
the ticket system removes any markup you may have added. please send a diff of the changes Graham. At the Datamail Group we value teamwork, respect, achievement, client focus, and courage. This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by replying immediately, destroy it and do not copy, disclose or use it in any way. The Datamail Group, through our GoGreen programme, is committed to environmental sustainability. Help us in our efforts by not printing this email.
__________________________________________________________________ This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite. Please see http://www.dmzglobal.com/dmzmessaging.htm for details.
__________________________________________________________________
Subject: RE: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Tue, 27 Oct 2009 12:30:39 +1300
To: <bug-libnet [...] rt.cpan.org>
From: "Jamie Young" <Jamie.Young [...] datamail.co.nz>
Sorry - you probably want this diff format: --- original.pm 2009-10-27 12:10:51.000000000 +1300 +++ modified.pm 2009-10-27 12:13:05.000000000 +1300 @@ -599,8 +599,8 @@ # Failed to delete it, assume its a directory # Recurse and ignore errors, the final rmdir() will # fail on any errors here -return $ok -unless $ok = $ftp->rmdir($file, 1); +#return $ok +#unless $ok = $ftp->rmdir($file, 1); } # Directory should be empty Thanks, Jamie Young Unix Administrator Enterprise Services Datamail Ltd 1 Victoria Street Petone Lower Hutt 5012 PO Box 31249 Lower Hutt 5040 Phone: + 64 4 568 8200 Extn: 8718 DDI: + 64 4 576 4325 Fax: + 64 4 568 9600 www.datamail.co.nz Show quoted text
-----Original Message----- From: Graham Barr via RT [mailto:bug-libnet@rt.cpan.org] Sent: Tuesday, 27 October 2009 11:58 a.m. To: Jamie Young Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878 <URL: http://rt.cpan.org/Ticket/Display.html?id=50849 > On Oct 26, 2009, at 5:07 PM, Jamie Young via RT wrote:
> Queue: libnet > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50849 > > > I'm not familiar with github - do I need to submit something to some > kind of SVN or something?
if you are not familiar do not worry about it
> To fix the bug you only need to comment out/remove the lines I've > highlighted below in the rmdir subroutine. If it fails to delete a > file it may be because of the permissions of the file itself are too > tight, not just that it's a directory.
the ticket system removes any markup you may have added. please send a diff of the changes Graham. </PRE><div style="font-size:8pt;font-family:Tahoma,Arial; text-align:justify; color:gray;"><br><br><hr size="0"> At the Datamail Group we value teamwork, respect, achievement, client focus, and courage.<br><br>This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by replying immediately, destroy it and do not copy, disclose or use it in any way.<br><br></div> <span lang=EN-AU style='font-size:18.0pt;font-family:Webdings; color:green'>P</span><span lang=EN-AU>&nbsp;</span><span lang=EN-AU style='font-size:7.5pt;font-family:"Verdana","sans-serif"'> <span style='color:green'>The Datamail Group, through our GoGreen programme, is committed to environmental sustainability. Help us in our efforts by not printing this email.</span></span><hr size="0"> </PRE><div style="font-size:8pt;font-family:Arial; text-align:center;"><br><br><hr size="0"> This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite.<br> Please see <a href="http://www.dmzglobal.com/dmzmessaging.htm">http://www.dmzglobal.com/dmzmessaging.htm</a> for details.<br> <hr size="0"><br><br></div>
Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Mon, 26 Oct 2009 20:03:59 -0500
To: bug-libnet [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Oct 26, 2009, at 6:31 PM, Jamie Young via RT wrote: Show quoted text
> Queue: libnet > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50849 > > > Sorry - you probably want this diff format: > > --- original.pm 2009-10-27 12:10:51.000000000 +1300 > +++ modified.pm 2009-10-27 12:13:05.000000000 +1300 > @@ -599,8 +599,8 @@ > # Failed to delete it, assume its a directory > # Recurse and ignore errors, the final rmdir() will > # fail on any errors here > -return $ok > -unless $ok = $ftp->rmdir($file, 1); > +#return $ok > +#unless $ok = $ftp->rmdir($file, 1);
I do not think that is the right solution as that will prevent it from recursively deleting more that one level for example if you have a path a/b/c/d $ftp->rmdir("a",1); should remove it, but with you change it will fail to do so. I think this patch will resolve the issue --- a/Net/FTP.pm +++ b/Net/FTP.pm @@ -590,6 +590,9 @@ sub rmdir { return undef unless @filelist; # failed, it is probably not a directory + return $ftp->delete($dir) + if @filelist == 1 and $dir eq $filelist[0]; + # Go thru and delete each file or the directory my $file; foreach $file (map { m,/, ? $_ : "$dir/$_" } @filelist) { Graham.
Subject: RE: [rt.cpan.org #50849] Net::FTP Bug 41878
Date: Tue, 27 Oct 2009 15:12:45 +1300
To: <bug-libnet [...] rt.cpan.org>
From: "Jamie Young" <Jamie.Young [...] datamail.co.nz>
Great! Thanks, Jamie Young Unix Administrator Enterprise Services Datamail Ltd 1 Victoria Street Petone Lower Hutt 5012 PO Box 31249 Lower Hutt 5040 Phone: + 64 4 568 8200  Extn: 8718 DDI:     + 64 4 576 4325 Fax:     + 64 4 568 9600 www.datamail.co.nz Show quoted text
-----Original Message----- From: Graham Barr via RT [mailto:bug-libnet@rt.cpan.org] Sent: Tuesday, 27 October 2009 2:04 p.m. To: Jamie Young Subject: Re: [rt.cpan.org #50849] Net::FTP Bug 41878 <URL: http://rt.cpan.org/Ticket/Display.html?id=50849 > On Oct 26, 2009, at 6:31 PM, Jamie Young via RT wrote:
> Queue: libnet > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50849 > > > Sorry - you probably want this diff format: > > --- original.pm 2009-10-27 12:10:51.000000000 +1300 > +++ modified.pm 2009-10-27 12:13:05.000000000 +1300 > @@ -599,8 +599,8 @@ > # Failed to delete it, assume its a directory > # Recurse and ignore errors, the final rmdir() will > # fail on any errors here > -return $ok > -unless $ok = $ftp->rmdir($file, 1); > +#return $ok > +#unless $ok = $ftp->rmdir($file, 1);
I do not think that is the right solution as that will prevent it from recursively deleting more that one level for example if you have a path a/b/c/d $ftp->rmdir("a",1); should remove it, but with you change it will fail to do so. I think this patch will resolve the issue --- a/Net/FTP.pm +++ b/Net/FTP.pm @@ -590,6 +590,9 @@ sub rmdir { return undef unless @filelist; # failed, it is probably not a directory + return $ftp->delete($dir) + if @filelist == 1 and $dir eq $filelist[0]; + # Go thru and delete each file or the directory my $file; foreach $file (map { m,/, ? $_ : "$dir/$_" } @filelist) { Graham. At the Datamail Group we value teamwork, respect, achievement, client focus, and courage. This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by replying immediately, destroy it and do not copy, disclose or use it in any way. The Datamail Group, through our GoGreen programme, is committed to environmental sustainability. Help us in our efforts by not printing this email.
__________________________________________________________________ This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite. Please see http://www.dmzglobal.com/dmzmessaging.htm for details.
__________________________________________________________________
This is fixed in 1.22_01.