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

2023-10-29 Thread Tim Rühsen

On 10/27/23 11:16, Christian Rosentreter wrote:


Thanks Tim!
Seems to work well for me.


You are welcome, Christian :)


Took me a while to get to the "commit". wget's primary homepage under 
https://www.gnu.org/software/wget/
doesn't make it very easy to find any information about the repository. But 
luckily I eventually located
the "savannah" page with the required details. :-)


Sorry about that. We still keep the Savannah repository up-to-date, but 
develop and CI test on https://gitlab.com/gnuwget/wget.


Regards, Tim


OpenPGP_signature.asc
Description: OpenPGP digital signature


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

2023-10-27 Thread Christian Rosentreter


Thanks Tim!
Seems to work well for me.


Took me a while to get to the "commit". wget's primary homepage under 
https://www.gnu.org/software/wget/
doesn't make it very easy to find any information about the repository. But 
luckily I eventually located
the "savannah" page with the required details. :-)


> On 22 Oct 2023, at 2:08 PM, Tim Rühsen  wrote:
> 
> Hey Christian, Andries,
> 
> Thanks for the analysis and the patch.
> 
> I moved the store/restore of errno a bit up the call chain in order to make 
> it independent of the TLS backend.
> 
> Pushed as commit 25525f80372dbdfa367da7ab8592a6a747fc1f68.
> 
> Regards, Tim




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

2023-10-22 Thread Tim Rühsen

Hey Christian, Andries,

Thanks for the analysis and the patch.

I moved the store/restore of errno a bit up the call chain in order to 
make it independent of the TLS backend.


Pushed as commit 25525f80372dbdfa367da7ab8592a6a747fc1f68.

Regards, Tim

On 10/21/23 23:58, Christian Rosentreter wrote:


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.0 +0200
+++ src/openssl.c   2023-10-21 23:42:06.0 +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  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 ‘’ (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…













OpenPGP_signature.asc
Description: OpenPGP digital signature


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

2023-10-21 Thread Christian Rosentreter


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.0 +0200
+++ src/openssl.c   2023-10-21 23:42:06.0 +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  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 ‘’ (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…
>>> 
>>> 
>>> 
>>> 
>>> 
> 
> 
> 




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

2023-10-21 Thread Andries E. Brouwer
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 ‘’ (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…
> > 
> > 
> > 
> > 
> > 






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

2023-10-21 Thread Christian Rosentreter


Hello Tim,

thanks for your reply.

Yes, I'm running the latest version (running on a rusty OS X "Yosemite"), also 
see the
text you quoted at the bottom (unless there are silent updates w/o version 
bump?). My copy
was build on July 25, 2023. Pretty up-to-date by my standards. :-) All used 
dependencies
are also pretty recent (maybe a day or 2 days older than wget, most was build 
for wget).
Full output of `wget --version`, see below at the end of my reply.

I only applied this required single-line patch from the bug tracker to fix FTPS 
crashes
for one of my use cases: https://savannah.gnu.org/bugs/?62137   I don't see how 
this should
break other things however.

I always get "(Success)" here, never "(Permission denied)". I tried `chown 
root`, or just
`chmod -w`, etc., as soon wget has no permissions it will still report 
"(Success)". I also tried
with `--no-config` just in case (I only have "local-encoding = UTF-8" in 
there), same result.


I tested an older wget (1.20.1) on my Raspberry PI under whatever Linux it runs 
("Raspbian
GNU/Linux 10 (buster)" according to "/etc/os-release") and it works as you 
describe and reports
"Permission denied" in this case. But I also build the latest 1.21.4 version 
and it fails
with "(Success)" under my Linux too:

   $ mkdir ~/Desktop/wget_tmp
   $ cd ~/Desktop/wget_tmp/
   $ wget https://ftp.gnu.org/gnu/wget/wget-1.21.4.tar.gz
   $ tar -xvzf wget-1.21.4.tar.gz
   $ cd wget-1.21.4/
   $ ./configure --with-ssl=openssl  # GnuTLS not available
   $ make

   $ mkdir ~/Desktop/foobar
   $ cd ~/Desktop/foobar
   $ chmod -w .

   $ ../wget_tmp/wget-1.21.4/src/wget https://www.christianrosentreter.com/
   --2023-10-21 20:53:19--  https://www.christianrosentreter.com/
   Resolving www.christianrosentreter.com... 85.13.142.16
   Connecting to 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).


   $ ../wget_tmp/wget-1.21.4/src/wget --version
   GNU Wget 1.21.4 built on linux-gnueabihf.

   -cares +digest -gpgme +https +ipv6 -iri +large-file -metalink +nls 
   +ntlm +opie -psl +ssl/openssl 

   Wgetrc: 
   /usr/local/etc/wgetrc (system)
   Locale: 
   /usr/local/share/locale 
   Compile: 
   gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
   -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib 
   -DHAVE_LIBSSL -DNDEBUG -g -O2 
   Link: 
   gcc -DHAVE_LIBSSL -DNDEBUG -g -O2 -lssl -lcrypto -lz 
   ../lib/libgnu.a 

   Copyright (C) 2015 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later
   .
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.

   Originally written by Hrvoje Niksic .
   Please send bug reports and questions to .



I'm happy to investigate further, but I would need a direction where I should 
look at. I'm
not familiar with wget from a development/ code perspective. Basically I'm just 
a wget user
that's already happy when it builds w/o major hassle and works w/o crashing 
afterwards. :-)





Here's the full uncut output of `wget --version` on my OS X machine:

   $ 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 

   Wgetrc: 
   /usr/local/etc/wget/wgetrc (system)
   Compile: 
   gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wget/wgetrc" 
   -DLOCALEDIR="/usr/local/silo/wget/1.21.4/share/locale" -I. -I../lib 
   -I../lib -I/usr/local/silo/libiconv/latest/include 
   -I/usr/local/silo/libunistring/latest/include 
   -I/usr/local/silo/libmetalink/latest/include 
   -I/usr/local/silo/c-ares/latest/include 
   -I/usr/local/silo/pcre2/latest/include 
   -I/usr/local/silo/uuid-ossp/latest/include 
   -I/usr/local/silo/libidn2/latest/include 
   -I/usr/local/silo/openssl/latest@3/include -DHAVE_LIBSSL 
   -I/usr/local/silo/zlib/latest/include 
   -I/usr/local/silo/libpsl/latest/include -DNDEBUG -g -O2 
   Link: 
   gcc -I/usr/local/silo/libmetalink/latest/include 
   -I/usr/local/silo/c-ares/latest/include 
   -I/usr/local/silo/pcre2/latest/include 
   -I/usr/local/silo/uuid-ossp/latest/include 
   -I/usr/local/silo/libidn2/latest/include 
   -I/usr/local/silo/openssl/latest@3/include -DHAVE_LIBSSL 
   -I/usr/local/silo/zlib/latest/include 
   -I/usr/local/silo/libpsl/latest/include -DNDEBUG -g -O2 
   -L/usr/local/silo/libiconv/latest/lib 
   -L/usr/local/silo/libunistring/latest/lib 
   -L/usr/local/silo/libmetalink/latest/lib -lmetalink 
   -L/usr/local/silo/c-ares/latest/lib -lcares 
   -L/usr/local/silo/pcre2/latest/lib -lpcre2-8 
   -L/usr/local/silo/uuid-ossp/latest/lib -luuid 

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

2023-10-21 Thread Michael D. Setzer II
On 21 Oct 2023 at 19:22, Tim Rühsen wrote:

Date sent:  Sat, 21 Oct 2023 19:22:25 +0200
Subject:Re: wget claims "Success" when it failed to write to local 
directory
To: Christian Rosentreter , bug-wget@gnu.org
From:   Tim Rühsen 

Did a test with wget2 and get this result with error (2) if no write
permission?
wget2 https://www.christianrosentreter.com/
Failed to open 'index.html' (2)
index.html   100%
[==
===>]1.89K--.-KB/s
  [Files: 1  Bytes: 1.89K [2.23KB/s] Redirects: 0  
Todo: 0  Errors: 0]

With write permission it downloads index.html fine.
wget2 https://www.christianrosentreter.com/
index.html   100%
[==
==>]1.89K--.-KB/s
  [Files: 1  Bytes: 1.89K [2.27KB/s] Redirects: 0  
Todo: 0  Errors: 0   ]





> 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…
> >
> >
> >
> >
> >



++
 Michael D. Setzer II - Computer Science Instructor (Retired)
 mailto:mi...@guam.net
 mailto:msetze...@gmail.com
 Guam - Where America's Day Begins
 G4L Disk Imaging Project maintainer
 http://sourceforge.net/projects/g4l/
++




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

2023-10-21 Thread Michael D. Setzer II
On 21 Oct 2023 at 17:16, Christian Rosentreter wrote:

From:   Christian Rosentreter 
Subject:wget claims "Success" when it failed to write to
local directory
Date sent:  Sat, 21 Oct 2023 17:16:44 +0200
To: bug-wget@gnu.org

>
> 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:
>

I'm a user of wget2 but in looking at man pages reports that error
code 3 is a File I/O error?

Exit Status
   Wget2 may return one of several error codes if it encounters
problems.

0   No problems occurred.
1   Generic error code.
2   Parse error. For instance, when parsing
command-line options, the .wget2rc or .netrc...
3   File I/O error.

So, would agree the Success is probable an incorrect message, but
since error code did report that there was a File I/O error the wget
program worked successfully.


>
> ### 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…
>
>
>
>
>


++
 Michael D. Setzer II - Computer Science Instructor (Retired)
 mailto:mi...@guam.net
 mailto:msetze...@gmail.com
 Guam - Where America's Day Begins
 G4L Disk Imaging Project maintainer
 http://sourceforge.net/projects/g4l/
++






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

2023-10-21 Thread Tim Rühsen

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…







OpenPGP_signature.asc
Description: OpenPGP digital signature