Re: [Bug-wget] Wget 1.13.4 v. VMS -- Various problems

2011-09-29 Thread Steven M. Schweda
 [...]
   2   24135   confval = long_options[longindex].val;
 
 Apparently, referencing long_options[-1] causes more trouble in a VMS
 environment than it does on a typical UNIX(-like) system.  [...]

   I still haven't looked at the details here, but I did notice that the
_second_ getopt_long() loop does things like:

  /* If LONGINDEX is unchanged, it means RET is referring a short
 option.  */
  if (longindex == -1)

rather than jumping right in and using longindex as a subscript. 
Perhaps the first getopt_long() loop should be so careful.


   Other helpful changes:

ALP $ gdiff -u src/log.c_orig src/log.c
--- src/log.c_orig  2011-07-29 08:43:44 -0500
+++ src/log.c   2011-09-29 08:43:17 -0500
@@ -573,14 +573,14 @@
 }
 }

-/* Close LOGFP, inhibit further logging and free the memory associated
-   with it.  */
+/* Close LOGFP (only if we opened it, not if it's stderr), inhibit
+   further logging and free the memory associated with it.  */
 void
 log_close (void)
 {
   int i;

-  if (logfp)
+  if (logfp  (logfp != stderr))
 fclose (logfp);
   logfp = NULL;
   inhibit_logging = true;

(This is particularly helpful if one is putting in debugging code like
fprintf( stderr, [...]), but closing stderr seems like a poor idea in
any case.)


ALP $ gdiff -u src/main.c_orig src/main.c
--- src/main.c_orig 2011-09-06 08:50:11 -0500
+++ src/main.c  2011-09-29 09:15:31 -0500
@@ -1467,7 +1480,7 @@
 xfree (url[i]);
   cleanup ();

-  return get_exit_status ();
+  exit (get_exit_status ());
 }
 #endif /* TESTING */

   On VMS, return x from main() and exit(x) are not equivalent, and
only exit(x) can deal with status codes other than EXIT_FAILURE and
EXIT_SUCCESS in a reasonable way.  (exit(x) is used in many other
places, so I wouldn't expect any damage from using it in one more.)



   Steven M. Schweda   sms@antinode-info
   382 South Warwick Street(+1) 651-699-9818
   Saint Paul  MN  55105-2547



Re: [Bug-wget] Wget 1.13.4 v. VMS -- Various problems

2011-09-29 Thread Steven M. Schweda
  [...]
2   24135   confval = long_options[longindex].val;
  
  Apparently, referencing long_options[-1] causes more trouble in a VMS
  environment than it does on a typical UNIX(-like) system.  [...]
 
I still haven't looked at the details here, [...]

   Now I have.  Adding a test on longindex seems to fix the problem
without causing any obvious (to me) damage:

ALP $ gdiff -u src/main.c_orig src/main.c
--- src/main.c_orig 2011-09-06 08:50:11 -0500
+++ src/main.c  2011-09-29 14:28:28 -0500
@@ -945,8 +945,8 @@

   init_switches ();

-  /* This seperate getopt_long is needed to find the user config
- and parse it before the other user options. */
+  /* This separate getopt_long is needed to find the user config file
+ option (--config) and parse it before the other user options. */
   longindex = -1;
   int retconf;
   bool use_userconfig = false;
@@ -957,20 +957,25 @@
   int confval;
   bool userrc_ret = true;
   struct cmdline_option *config_opt;
-  confval = long_options[longindex].val;
-  config_opt = option_data[confval  ~BOOLEAN_NEG_MARKER];
-  if (strcmp (config_opt-long_name, config) == 0)
-{
-  userrc_ret = run_wgetrc (optarg);
-  use_userconfig = true;
-}
-  if (!userrc_ret)
+
+  /* There is no short option for --config. */
+  if (longindex = 0)
 {
-  printf (Exiting due to error in %s\n, optarg);
-  exit (2);
+  confval = long_options[longindex].val;
+  config_opt = option_data[confval  ~BOOLEAN_NEG_MARKER];
+  if (strcmp (config_opt-long_name, config) == 0)
+{
+  userrc_ret = run_wgetrc (optarg);
+  use_userconfig = true;
+}
+  if (!userrc_ret)
+{
+  printf (Exiting due to error in %s\n, optarg);
+  exit (2);
+}
+  else
+break;
 }
-  else
-break;
 }

   /* If the user did not specify a config, read the system wgetrc and 
~/.wgetrc. */

[Plus the same return - exit() change as reported earlier.]

   I still have some VMS-specific builder changes to make, but the
changes to src/connect.c, src/log.c, and src/main.c seem to be all
that I've needed in the common code (so far).  For completeness:

ALP $ gdiff -u src/connect.c_orig src/connect.c
--- src/connect.c_orig  2011-08-07 15:55:23 -0500
+++ src/connect.c   2011-09-29 09:23:37 -0500
@@ -36,8 +36,13 @@
 #include unistd.h
 #include assert.h

-#include sys/socket.h
-#include sys/select.h
+#ifdef HAVE_SYS_SOCKET_H
+# include sys/socket.h
+#endif /* def HAVE_SYS_SOCKET_H */
+
+#ifdef HAVE_SYS_SELECT_H
+# include sys/select.h
+#endif /* def HAVE_SYS_SELECT_H */

 #ifndef WINDOWS
 # ifdef __VMS


   Assuming that I eventually get satisfactory VMS builders constructed,
is there any interest in including the VMS-specific files in the main
wget distribution kit, or should I assume that the victim will need to
obtain and unpack a suplementary VMS-specific kit (scattered VMS
builders, vms/ directory) onto a normal wget source directory?  (Or a
complete VMS-compatible kit, as in the past.)



   Steven M. Schweda   sms@antinode-info
   382 South Warwick Street(+1) 651-699-9818
   Saint Paul  MN  55105-2547



[Bug-wget] Recursive wget: change in handling of file permissions?

2011-09-29 Thread Metzler, Chris


I'm experiencing some odd behavior with recursive ftp wgets.  In a more
recent version, the recursive wget appears to ignore the umask and gives
the downloaded files the same permissions as on the remote machine,
despite not requesting this via a command line argument.

For example, on machine A (RHEL, wget 1.10.2), I execute the following
command:

wget -v -nH -A SAO -T 60 -w 1
ftp://ftp.ngdc.noaa.gov/ionosonde/data/AS00Q/individual/2011/121/scaled/
AS00Q_201112105.SAO

and download the file; the file is mode 664, which corresponds to the
umask of 002.  If I then add a recursive switch to the command line:

wget -v -nH -r -A SAO -T 60 -w 1
ftp://ftp.ngdc.noaa.gov/ionosonde/data/AS00Q/individual/2011/121/scaled/
AS00Q_201112105.SAO

the directory structure in which the file is created is obviously
different, but the file permissions are the same:  664, or rw-rw-r--.

Now, I move to machine B, (Ubuntu, wget 1.12) and do the same two
commands -- the first without the -r flag, and the second with.  On
the first run, the file downloads with mode 664, agreeing with the umask
of 002.  When I run the second command, *with* the -r flag, in
addition to the different directory structure, the file permissions are
444, or r--r--r--, the same as they are on the remote machine.

(NOTE:  at this point you maybe asking why are you doing a recursive
download, or adding the -A flag, when you're only downloading one file?
In practice, I'm not downloading just one file -- a specific filename
won't be present, and the URL will end with the scaled subdirectory.
I just wanted to include examples that you could try yourself without
downloading 100 files.)

I need to be able to do recursive downloads while having the file
permissions match my umask.  Is that no longer possible in more recent
versions of wget?  Or am I doing something wrong here?

Thanks,

-c


Chris Metzler
Naval Research Laboratory, Code 7669
202-767-6166
christopher.metz...@nrl.navy.mil




Re: [Bug-wget] Wget 1.13.4 v. VMS -- Various problems

2011-09-29 Thread Steven M. Schweda
I still have some VMS-specific builder changes to make, but the
 changes to src/connect.c, src/log.c, and src/main.c seem to be all
 that I've needed in the common code (so far).  [...]

   Well, not quite.  In src/openssl.c:ssl_init(), there's this:

  SSL_METHOD const *meth;

which causes a problem with some older OpenSSL kits (0.9.8j, for
example), where the argument to SSL_CTX_new() was not declared as
const (as it is in a newer OpenSSL kit, like, say, 1.0.0e):

CC /float = ieee_float  /include = ([], [.ALPHAL],  [-.LIB], [-.LIB.ALPHAL], [-.
VMS])   /prefix_library_entries =  (all_entries, except = (utime , __UTC_UTIME))
/object = [.ALPHAL]OPENSSL.OBJ /define = (VMS, _POSIX_EXIT  , ENABLE_DEBUG
 , _LARGEFILE , HAVE_SSL, ENABLE_NTLM  ) [-.SRC]OPENSSL.C

  ssl_ctx = SSL_CTX_new (meth);
.^
%CC-W-NOTCONSTQUAL, In this statement, the referenced type of the pointer value
meth is const, but the referenced type of the target of this assignment is not
.
at line number 204 in file ALP2$DKC0:[utility.source.WGET.wget-1_13_4.src]openss
l.c;1

Naturally, the latest HP-supplied SSL kit is based on some 0.9.8 kit, so
this would likely affect more users than one might expect.  I don't know
what the preferred solution would be.  Adding a type cast seems to fix
the problem here:

ALP $ gdiff -u src/openssl.c_orig src/openssl.c
--- src/openssl.c_orig  2011-08-29 03:01:24 -0500
+++ src/openssl.c   2011-09-29 17:40:09 -0500
@@ -201,7 +201,9 @@
   abort ();
 }

-  ssl_ctx = SSL_CTX_new (meth);
+  /* The type cast below accomodates older OpenSSL versions (0.9.8)
+ where SSL_CTX_new() is declared without a const argument. */
+  ssl_ctx = SSL_CTX_new ((SSL_METHOD *)meth);
   if (!ssl_ctx)
 goto error;

but I haven't tried it in any other environments.


   And there's still that error message in src/init.c which uses
SYSTEM_WGETRC, whether or not SYSTEM_WGETRC is defined.



   Steven M. Schweda   sms@antinode-info
   382 South Warwick Street(+1) 651-699-9818
   Saint Paul  MN  55105-2547



Re: [Bug-wget] Wget 1.13.4 v. VMS -- Various problems

2011-09-29 Thread Steven M. Schweda
And there's still that error message in src/init.c which uses
 SYSTEM_WGETRC, whether or not SYSTEM_WGETRC is defined.

   One possible solution:

--- src/init.c_orig 2011-08-19 05:06:20 -0500
+++ src/init.c  2011-09-30 00:44:16 -0500
@@ -597,21 +597,34 @@
  variable has been set. For internal testing purposes only!  */
   env_sysrc = getenv (SYSTEM_WGETRC);
   if (env_sysrc  file_exists_p (env_sysrc))
-ok = run_wgetrc (env_sysrc);
+{
+  ok = run_wgetrc (env_sysrc);
+  /* If there are any problems parsing the system wgetrc file, tell
+ the user and exit */
+  if (! ok)
+{
+  fprintf (stderr, _(\
+Parsing system wgetrc file (env SYSTEM_WGETRC) failed.  Please check\n\
+'%s',\n\
+or specify a different file using --config.\n), env_sysrc);
+  exit (2);
+}
+}
   /* Otherwise, if SYSTEM_WGETRC is defined, use it.  */
 #ifdef SYSTEM_WGETRC
   else if (file_exists_p (SYSTEM_WGETRC))
 ok = run_wgetrc (SYSTEM_WGETRC);
-#endif
   /* If there are any problems parsing the system wgetrc file, tell
  the user and exit */
   if (! ok)
 {
   fprintf (stderr, _(\
-Parsing system wgetrc file failed, please check '%s'.   \
-Or specify a different file using --config\n), SYSTEM_WGETRC);
+Parsing system wgetrc file failed.  Please check\n\
+'%s',\n\
+or specify a different file using --config.\n), SYSTEM_WGETRC);
   exit (2);
 }
+#endif
   /* Override it with your own, if one exists.  */
   file = wgetrc_file_name ();
   if (!file)


Aside from working when SYSTEM_WGETRC is not defined, it provides
distinct messages for the two different ways the system wgetrc file
might have been specified.

ALP $ define /user_mode system_wgetrc sys$manager:.wgetrcx
ALP $ wgx  --version
WGET: Syntax error in sys$manager:.wgetrcx at line 1.
Parsing system wgetrc file (env SYSTEM_WGETRC) failed.  Please check
'sys$manager:.wgetrcx',
or specify a different file using --config.



   Steven M. Schweda   sms@antinode-info
   382 South Warwick Street(+1) 651-699-9818
   Saint Paul  MN  55105-2547