]> sjero.net Git - wget/commitdiff
Fix some problems under VMS.
authorSteven Schweda <sms@antinode.info>
Sun, 23 Oct 2011 11:11:22 +0000 (13:11 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Sun, 23 Oct 2011 11:11:22 +0000 (13:11 +0200)
src/ChangeLog
src/connect.c
src/ftp.c
src/init.c
src/log.c
src/main.c
src/openssl.c
src/utils.c

index c9c317ba6ccc360767607de1227fb298f15b72be..c2af118e347b1e06e05a58d7131d6c51b8ab187c 100644 (file)
@@ -1,3 +1,28 @@
+2011-10-07  Steven Schweda  <address@hidden>
+
+       * connect.c: Add HAVE_SYS_SELECT_H and HAVE_SYS_SOCKET_H conditions
+       on includes of <sys/select.h> and <sys/socket.h>, respectively.
+       * ftp.c (getftp): Move BIN_TYPE_TRANSFER macro into VMS-specific
+       section.  On VMS, use Stream_LF attributes for listing files.  Pass
+       BIN_TYPE_FILE to fopen_excl() instead of constant-everywhere "true".
+       * ftp.c (ftp_retrieve_list): Restore lost test of opt.preserve_perm
+       (--preserve-permissions) on the chmod() operation.
+       * init.c, main.c: Remove "deprecated" from opt.preserve_perm
+       (--preserve-permissions).
+       * init.c (initialize): Use distinct messages for errors in C macro
+       SYSTEM_WGETRC and environment-variable SYSTEM_WGETRC.  Avoid use of
+       C macro SYSTEM_WGETRC when it's not defined.
+       * log.c (log_close): Avoid closing logfp when it's stderr.
+       * main.c (print_help):  Restore --preserve-permissions.
+       * main.c (main): Avoid using a negative value of longindex as a
+       subscript (for long_options[]) when searching for "--config".
+       * main.c (main): Exit the program using exit() instead of "return".
+       (VMS handles these differently, and exit() is better.)
+       * openssl.c (ssl_init): Add type cast (SSL_METHOD *) to newly "const"
+       "meth" argument to accommodate OpenSSL version 0.9.8, where that
+       argument is not "const" in the OpenSSL function (SSL_CTX_new).
+       * utils.c (fopen_excl): Comment typography.
+
 2011-10-02  Henrik Holst <henrik.holst@millistream.com> (tiny change)
        * http.c (gethttp): If 'contentonerror' is used then do not
         skip the http body on 4xx and 5xx errors.
index e12c049a11002e5a432f1758e1db7befe4ddf3ba..6008c3c2cb5e95e7cae011e1dc4dd7a301c17baf 100644 (file)
@@ -36,8 +36,13 @@ as that of the covered work.  */
 #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
index a586d84952411d32edcf390c0be30d166c330ecd..f75397d09b181870d76737a0f8262152e1d69cf3 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1152,13 +1152,25 @@ Error in server response, closing control connection.\n"));
    Elsewhere, define a constant "binary" flag.
    Isn't it nice to have distinct text and binary file types?
 */
-# define BIN_TYPE_TRANSFER (type_char != 'A')
+/* 2011-09-30 SMS.
+   Added listing files to the set of non-"binary" (text, Stream_LF)
+   files.  (Wget works either way, but other programs, like, say, text
+   editors, work better on listing files which have text attributes.) 
+   Now we use "binary" attributes for a binary ("IMAGE") transfer,
+   unless "--ftp-stmlf" was specified, and we always use non-"binary"
+   (text, Stream_LF) attributes for a listing file, or for an ASCII
+   transfer.
+   Tidied the VMS-specific BIN_TYPE_xxx macros, and changed the call to
+   fopen_excl() (restored?) to use BIN_TYPE_FILE instead of "true".
+*/
 #ifdef __VMS
+# define BIN_TYPE_TRANSFER (type_char != 'A')
+# define BIN_TYPE_FILE \
+   ((!(cmd & DO_LIST)) && BIN_TYPE_TRANSFER && (opt.ftp_stmlf == 0))
 # define FOPEN_OPT_ARGS "fop=sqo", "acc", acc_cb, &open_id
 # define FOPEN_OPT_ARGS_BIN "ctx=bin,stm", "rfm=fix", "mrs=512" FOPEN_OPT_ARGS
-# define BIN_TYPE_FILE (BIN_TYPE_TRANSFER && (opt.ftp_stmlf == 0))
 #else /* def __VMS */
-# define BIN_TYPE_FILE 1
+# define BIN_TYPE_FILE true
 #endif /* def __VMS [else] */
 
       if (restval && !(con->cmd & DO_LIST))
@@ -1217,7 +1229,7 @@ Error in server response, closing control connection.\n"));
         }
       else
         {
-          fp = fopen_excl (con->target, true);
+          fp = fopen_excl (con->target, BIN_TYPE_FILE);
           if (!fp && errno == EEXIST)
             {
               /* We cannot just invent a new name and use it (which is
@@ -1880,8 +1892,10 @@ Already have correct symlink %s -> %s\n\n"),
 
       set_local_file (&actual_target, con->target);
 
-      /* If downloading a plain file, set valid (non-zero) permissions. */
-      if (dlthis && (actual_target != NULL) && (f->type == FT_PLAINFILE))
+      /* If downloading a plain file, and the user requested it, then
+         set valid (non-zero) permissions. */
+      if (dlthis && (actual_target != NULL) &&
+       (f->type == FT_PLAINFILE) && opt.preserve_perm)
         {
           if (f->perms)
             chmod (actual_target, f->perms);
index b40be8ad7effcbb9d33e2add2032724017717af1..eae355235486cf6db064f627f997aed0f7df2f62 100644 (file)
@@ -214,7 +214,7 @@ static const struct {
   { "postdata",         &opt.post_data,         cmd_string },
   { "postfile",         &opt.post_file_name,    cmd_file },
   { "preferfamily",     NULL,                   cmd_spec_prefer_family },
-  { "preservepermissions", &opt.preserve_perm,  cmd_boolean },/* deprecated */
+  { "preservepermissions", &opt.preserve_perm,  cmd_boolean },
 #ifdef HAVE_SSL
   { "privatekey",       &opt.private_key,       cmd_file },
   { "privatekeytype",   &opt.private_key_type,  cmd_cert_type },
@@ -598,21 +598,34 @@ initialize (void)
      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)
index 361b45370b0887062fb6f61e4e2ed2c8581c34d8..e6875f6bd722768a1391114d3dc5d6cb1d6c8454 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -573,14 +573,14 @@ log_init (const char *file, bool appendp)
     }
 }
 
-/* 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;
index b80eef0a9484b324a199e1a58db4683fd2d26df0..05ad0e76576c73c2e6ace66838513287621e8b31 100644 (file)
@@ -243,7 +243,7 @@ static struct cmdline_option option_data[] =
     { "post-data", 0, OPT_VALUE, "postdata", -1 },
     { "post-file", 0, OPT_VALUE, "postfile", -1 },
     { "prefer-family", 0, OPT_VALUE, "preferfamily", -1 },
-    { "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 }, /* deprecated */
+    { "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 },
     { IF_SSL ("private-key"), 0, OPT_VALUE, "privatekey", -1 },
     { IF_SSL ("private-key-type"), 0, OPT_VALUE, "privatekeytype", -1 },
     { "progress", 0, OPT_VALUE, "progress", -1 },
@@ -646,6 +646,8 @@ FTP options:\n"),
        --no-glob               turn off FTP file name globbing.\n"),
     N_("\
        --no-passive-ftp        disable the \"passive\" transfer mode.\n"),
+    N_("\
+       --preserve-permissions  preserve remote file permissions.\n"),
     N_("\
        --retr-symlinks         when recursing, get linked-to files (not dir).\n"),
     "\n",
@@ -948,8 +950,8 @@ main (int argc, char **argv)
 
   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;
@@ -960,20 +962,25 @@ main (int argc, char **argv)
       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. */
@@ -1470,7 +1477,7 @@ outputting to a regular file.\n"));
     xfree (url[i]);
   cleanup ();
 
-  return get_exit_status ();
+  exit (get_exit_status ());
 }
 #endif /* TESTING */
 \f
index 2e2366903f7c8a906a55f69e48c15d8ea0eb4cd9..bc37491561228a750040b9e2361cbc75bacec1e1 100644 (file)
@@ -201,7 +201,9 @@ ssl_init ()
       abort ();
     }
 
-  ssl_ctx = SSL_CTX_new (meth);
+  /* The type cast below accommodates 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;
 
index 4950ab2ea392f1223bb98a809d7472e0eb91e89a..509088b644a6566da06cdedb7818974c0f8c6c75 100644 (file)
@@ -769,8 +769,7 @@ fopen_excl (const char *fname, int binary)
       open_id = 13;
       fd = open( fname,                 /* File name. */
        flags,                           /* Flags. */
-       0777,                            /* Mode for default protection.
-*/
+       0777,                            /* Mode for default protection. */
        "rfm=stmlf",                     /* Stream_LF. */
        OPEN_OPT_ARGS);                  /* Access callback. */
     }