bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wget claims "Success" when it failed to write to local directory


From: Christian Rosentreter
Subject: Re: wget claims "Success" when it failed to write to local directory
Date: Sat, 21 Oct 2023 23:58:41 +0200

Hi Andries,

I re-done my wget build with the following patch. It fixes my issue and it now
properly reports "(Permission denied)" instead "(Success)" in case of error
when wget lacks writing permissions to the directory it operates in.


This confirms your past findings/ analysis.

OpenSSL's shutdown clobbers errno which wget fails to properly cache/ handle.
Hence we don't see the issue with the system default wget from Raspian: that 
copy
is build with GNUTLS.




--- src/openssl.c.orig  2023-05-11 00:18:48.000000000 +0200
+++ src/openssl.c       2023-10-21 23:42:06.000000000 +0200
@@ -757,7 +757,16 @@
   struct openssl_transport_context *ctx = arg;
   SSL *conn = ctx->conn;
 
+  /* HOTFIX:  OpenSSL's SSL_shutdown clobbers 'errno' which
+   *          wget fails to properly cache in http.c leading
+   *          to curious "Success" messages in failure cases.
+   *
+   * WARNING: This is not a PROPER fix!
+   */
+  int olderrno = errno;
   SSL_shutdown (conn);
+  errno = olderrno;
+  
   SSL_free (conn);
   xfree (ctx->last_error);
   xfree (ctx);





> On 21 Oct 2023, at 9:03 PM, Andries E. Brouwer <aeb@cwi.nl> wrote:
> 
> Hi Tim,
> 
> That reminds me of some earlier discussion, see
> https://lists.gnu.org/archive/html/bug-wget/2021-05/msg00012.html
> 
> I rechecked wget 1.21.4, and it still gives Cannot write to ‘<dir>’ (Success).
> I suppose the same analysis still applies.
> 
> Andries
> 
> 
> On Sat, Oct 21, 2023 at 07:22:25PM +0200, Tim Rühsen wrote:
>> Hi,
>> 
>> do you run the latest wget (1.21.4)?
>> 
>> With that version, you get a
>> 
>>  Cannot write to 'index.html' (Permission denied).
>> 
>> Regards, Tim
>> 
>> On 10/21/23 17:16, Christian Rosentreter wrote:
>>> 
>>> Hi there,
>>> 
>>> There's a minor cosmetic bug in wget 1.x where it claims "Success" when it 
>>> in fact entirely failed to write to the local
>>> disk, e.g. because of missing permissions/ write access to the current 
>>> directory. The return code is "3" however, so it's
>>> basically only the message that it prints on screen that is funny in a 
>>> suspicious way:
>>> 
>>> 
>>> ### Prepare situation…
>>> $ mkdir foobar
>>> $ chmod -w foobar   # remove write access
>>> $ cd foobar
>>> 
>>> 
>>> ### Note: the "Permission denied" and "Cannot write to" messages, but we
>>> ###       get a "(Success)" anyway:
>>> $ wget https://www.christianrosentreter.com/
>>> --2023-10-21 17:05:35--  https://www.christianrosentreter.com/
>>> Resolving www.christianrosentreter.com (www.christianrosentreter.com)... 
>>> 85.13.142.16
>>> Connecting to www.christianrosentreter.com 
>>> (www.christianrosentreter.com)|85.13.142.16|:443... connected.
>>> HTTP request sent, awaiting response... 200 OK
>>> Length: unspecified [text/html]
>>> index.html: Permission denied
>>> 
>>> Cannot write to 'index.html' (Success).
>>> 
>>> 
>>> ### The return code seems to be reasonable though:
>>> $ echo $?
>>> 3
>>> 
>>> 
>>> ### Version tested:
>>> $ wget --version
>>> GNU Wget 1.21.4 built on darwin14.5.0.
>>> 
>>> +cares +digest -gpgme +https +ipv6 +iri +large-file +metalink -nls
>>> +ntlm +opie +psl +ssl/openssl
>>> 
>>> …cut…
>>> 
>>> 
>>> 
>>> 
>>> 
> 
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]