]> sjero.net Git - wget/commitdiff
[svn] Change default anonymous FTP password to "-wget@".
authorhniksic <devnull@localhost>
Sun, 29 Apr 2001 10:53:55 +0000 (03:53 -0700)
committerhniksic <devnull@localhost>
Sun, 29 Apr 2001 10:53:55 +0000 (03:53 -0700)
Published in <sxsu239htnl.fsf@florida.arsdigita.de>.

src/ChangeLog
src/ftp.c
src/host.c
src/init.c
src/main.c
src/mswindows.c
src/netrc.c
src/utils.c

index f5b70250b038db192415b7722ef2a02dce4530e5..cde7aebd49ba084155112fbc7d5c3f7e28c5f44f 100644 (file)
@@ -1,3 +1,17 @@
+2001-04-28  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * main.c (main): Removed undocumented option `--email-address'.
+
+       * netrc.c: Use the latest read_whole_line.
+
+       * init.c (defaults): Set opt.ftp_pass to "-wget@".
+
+       * mswindows.c (pwd_cuserid): Ditto.
+
+       * utils.c (pwd_cuserid): Removed.
+
+       * host.c (ftp_getaddress): Removed.
+
 2001-04-28  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        (http_loop): Allocate space for filename_plus_orig_suffix with
index 1e8ad517d20d737c5f7e060a31bf25725ec5d016..8f80e42407d3dc6821893c68e6421b4c29796935 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -133,8 +133,6 @@ getftp (struct urlinfo *u, long *len, long restval, ccon *con)
   passwd = u->passwd;
   search_netrc (u->host, (const char **)&user, (const char **)&passwd, 1);
   user = user ? user : opt.ftp_acc;
-  if (!opt.ftp_pass)
-    opt.ftp_pass = ftp_getaddress ();
   passwd = passwd ? passwd : opt.ftp_pass;
   assert (user && passwd);
 
index 9cfb21f9e06e49cb372e1faa5bcddea0f1c7ee42..eaf70762d0f190e9c6d57793711a156393a6eed3 100644 (file)
@@ -360,130 +360,6 @@ sufmatch (const char **list, const char *what)
   return 0;
 }
 
-/* Return email address of the form username@FQDN suitable for
-   anonymous FTP passwords.  This process is error-prone, and the
-   escape hatch is the MY_HOST preprocessor constant, which can be
-   used to hard-code either your hostname or FQDN at compile-time.
-
-   If the FQDN cannot be determined, a warning is printed, and the
-   function returns a short `username@' form, accepted by most
-   anonymous servers.
-
-   The returned string is generated by malloc() and should be freed
-   using free().
-
-   If not even the username cannot be divined, it means things are
-   seriously fucked up, and Wget exits.  */
-char *
-ftp_getaddress (void)
-{
-  static char *address;
-
-  /* Do the drill only the first time, as it won't change.  */
-  if (!address)
-    {
-      char userid[32];         /* 9 should be enough for Unix, but
-                                  I'd rather be on the safe side.  */
-      char *host, *fqdn;
-
-      if (!pwd_cuserid (userid))
-       {
-         logprintf (LOG_ALWAYS, _("%s: Cannot determine user-id.\n"),
-                    exec_name);
-         exit (1);
-       }
-#ifdef MY_HOST
-      STRDUP_ALLOCA (host, MY_HOST);
-#else /* not MY_HOST */
-#ifdef HAVE_UNAME
-      {
-       struct utsname ubuf;
-       if (uname (&ubuf) < 0)
-         {
-           logprintf (LOG_ALWAYS, _("%s: Warning: uname failed: %s\n"),
-                      exec_name, strerror (errno));
-           fqdn = "";
-           goto giveup;
-         }
-       STRDUP_ALLOCA (host, ubuf.nodename);
-      }
-#else /* not HAVE_UNAME */
-#ifdef HAVE_GETHOSTNAME
-      host = alloca (256);
-      if (gethostname (host, 256) < 0)
-       {
-         logprintf (LOG_ALWAYS, _("%s: Warning: gethostname failed\n"),
-                    exec_name);
-         fqdn = "";
-         goto giveup;
-       }
-#else /* not HAVE_GETHOSTNAME */
- #error Cannot determine host name.
-#endif /* not HAVE_GETHOSTNAME */
-#endif /* not HAVE_UNAME */
-#endif /* not MY_HOST */
-      /* If the address we got so far contains a period, don't bother
-         anymore.  */
-      if (strchr (host, '.'))
-       fqdn = host;
-      else
-       {
-         /* #### I've seen the following scheme fail on at least one
-            system!  Do we care?  */
-         char *tmpstore;
-         /* According to Richard Stevens, the correct way to find the
-            FQDN is to (1) find the host name, (2) find its IP
-            address using gethostbyname(), and (3) get the FQDN using
-            gethostbyaddr().  So that's what we'll do.  Step one has
-            been done above.  */
-         /* (2) */
-         struct hostent *hp = gethostbyname (host);
-         if (!hp || !hp->h_addr_list)
-           {
-             logprintf (LOG_ALWAYS, _("\
-%s: Warning: cannot determine local IP address.\n"),
-                        exec_name);
-             fqdn = "";
-             goto giveup;
-           }
-         /* Copy the argument, so the call to gethostbyaddr doesn't
-            clobber it -- just in case.  */
-         tmpstore = (char *)alloca (hp->h_length);
-         memcpy (tmpstore, *hp->h_addr_list, hp->h_length);
-         /* (3) */
-         hp = gethostbyaddr (tmpstore, hp->h_length, hp->h_addrtype);
-         if (!hp || !hp->h_name)
-           {
-             logprintf (LOG_ALWAYS, _("\
-%s: Warning: cannot reverse-lookup local IP address.\n"),
-                        exec_name);
-             fqdn = "";
-             goto giveup;
-           }
-         if (!strchr (hp->h_name, '.'))
-           {
-#if 0
-             /* This gets ticked pretty often.  Karl Berry reports
-                 that there can be valid reasons for the local host
-                 name not to be an FQDN, so I've decided to remove the
-                 annoying warning.  */
-             logprintf (LOG_ALWAYS, _("\
-%s: Warning: reverse-lookup of local address did not yield FQDN!\n"),
-                      exec_name);
-#endif
-             fqdn = "";
-             goto giveup;
-           }
-         /* Once we're here, hp->h_name contains the correct FQDN.  */
-         STRDUP_ALLOCA (fqdn, hp->h_name);
-       }
-    giveup:
-      address = (char *)xmalloc (strlen (userid) + 1 + strlen (fqdn) + 1);
-      sprintf (address, "%s@%s", userid, fqdn);
-    }
-  return address;
-}
-
 /* Print error messages for host errors.  */
 char *
 herrmsg (int error)
index d824d8c32fb83f6debb6755cca0e3eaf3776505f..62115a863935ad0b3c5005fd8ea443f2ae5e9cac 100644 (file)
@@ -227,8 +227,8 @@ defaults (void)
   opt.ntry = 20;
   opt.reclevel = 5;
   opt.add_hostdir = 1;
-  opt.ftp_acc = xstrdup ("anonymous");
-  /*opt.ftp_pass = xstrdup (ftp_getaddress ());*/
+  opt.ftp_acc  = xstrdup ("anonymous");
+  opt.ftp_pass = xstrdup ("-wget@");
   opt.netrc = 1;
   opt.ftp_glob = 1;
   opt.htmlify = 1;
index 5f1f26035391e67261aae4cf30fae159465aeab1..255bb8c44552987b1498e59e0a0d85c4ec54cdca 100644 (file)
@@ -251,7 +251,6 @@ main (int argc, char *const *argv)
     { "debug", no_argument, NULL, 'd' },
     { "delete-after", no_argument, NULL, 136 },
     { "dont-remove-listing", no_argument, NULL, 149 },
-    { "email-address", no_argument, NULL, 154 }, /* undocumented (debug) */
     { "follow-ftp", no_argument, NULL, 142 },
     { "force-directories", no_argument, NULL, 'x' },
     { "force-hier", no_argument, NULL, 'x' }, /* obsolete */
@@ -400,11 +399,6 @@ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:",
        case 150:
          setval ("simplehostcheck", "on");
          break;
-       case 154:
-         /* For debugging purposes.  */
-         printf ("%s\n", ftp_getaddress ());
-         exit (0);
-         break;
        case 155:
          setval ("bindaddress", optarg);
          break;
index a938cab62f68f702603ce9d595bfb8ce20e405ca..46f86749d9f2d1af5efa7040532e34a2bae0bec0 100644 (file)
@@ -63,32 +63,6 @@ read_registry (HKEY hkey, char *subkey, char *valuename, char *buf, int *len)
   return buf;
 }
 
-char *
-pwd_cuserid (char *where)
-{
-  char buf[32], *ptr;
-  int len = sizeof (buf);
-  if (GetUserName (buf, (LPDWORD) &len) == TRUE)
-    {
-      ;
-    }
-  else if (!!(ptr = getenv ("USERNAME")))
-    {
-      strcpy (buf, ptr);
-    }
-  else if (!read_registry (HKEY_LOCAL_MACHINE, "Network\\Logon",
-                         "username", buf, &len))
-    {
-      return NULL;
-    }
-  if (where)
-    {
-      strncpy (where, buf, len);
-      return where;
-    }
-  return xstrdup (buf);
-}
-
 void
 windows_main_junk (int *argc, char **argv, char **exec_name)
 {
index 9777e9e261a5d4eb5dc9e996e81dc661040c6089..8a048fd9129f81a2f9de09f19ac35273fbe99d58 100644 (file)
@@ -67,7 +67,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
   /* Find ~/.netrc.  */
   if (!processed_netrc)
     {
-      char *home = home_dir();
+      char *home = home_dir ();
 
       netrc_list = NULL;
       processed_netrc = 1;
@@ -140,51 +140,58 @@ search_netrc (const char *host, const char **acc, const char **passwd,
 
 
 #ifdef STANDALONE
+
+#include <assert.h>
+
 /* Normally, these functions would be defined by your package.  */
 # define xmalloc malloc
 # define xfree free
 # define xstrdup strdup
 
-/* The function reads a whole line.  It reads the line realloc-ing the
+# define xrealloc realloc
+
+/* Read a line from FP.  The function reallocs the storage as needed
+   to accomodate for any length of the line.  Reallocs are done
    storage exponentially, doubling the storage after each overflow to
-   minimize the number of calls to realloc().
+   minimize the number of calls to realloc() and fgets().  The newline
+   character at the end of line is retained.
 
-   It is not an exemplary of correctness, since it kills off the
-   newline (and no, there is no way to know if there was a newline at
-   EOF).  */
-# define xrealloc realloc
-# define DYNAMIC_LINE_BUFFER 40
+   After end-of-file is encountered without anything being read, NULL
+   is returned.  NULL is also returned on error.  To distinguish
+   between these two cases, use the stdio function ferror().  */
 
 char *
 read_whole_line (FILE *fp)
 {
-  char *line;
-  int i, bufsize, c;
-
-  i = 0;
-  bufsize = DYNAMIC_LINE_BUFFER;
-  line = xmalloc(bufsize);
-  /* Construct the line.  */
-  while ((c = getc(fp)) != EOF && c != '\n')
+  int length = 0;
+  int bufsize = 81;
+  char *line = (char *)xmalloc (bufsize);
+
+  while (fgets (line + length, bufsize - length, fp))
     {
-      if (i > bufsize - 1)
-       line = (char *)xrealloc(line, (bufsize <<= 1));
-      line[i++] = c;
+      length += strlen (line + length);
+      assert (length > 0);
+      if (line[length - 1] == '\n')
+       break;
+      /* fgets() guarantees to read the whole line, or to use up the
+         space we've given it.  We can double the buffer
+         unconditionally.  */
+      bufsize <<= 1;
+      line = xrealloc (line, bufsize);
     }
-  if (c == EOF && !i)
+  if (length == 0 || ferror (fp))
     {
-      xfree(line);
+      xfree (line);
       return NULL;
     }
-
-  /* Check for overflow at zero-termination (no need to double the
-     buffer in this case.  */
-  if (i == bufsize)
-    line = (char *)xrealloc(line, i + 1);
-  line[i] = '\0';
+  if (length + 1 < bufsize)
+    /* Relieve the memory from our exponential greediness.  We say
+       `length + 1' because the terminating \0 is not included in
+       LENGTH.  We don't need to zero-terminate the string ourselves,
+       though, because fgets() does that.  */
+    line = xrealloc (line, length + 1);
   return line;
 }
-
 #endif /* STANDALONE */
 
 /* Maybe add NEWENTRY to the account information list, LIST.  NEWENTRY is
index 1f326d50d2041db2a3c713953e880c99af83bc1e..77ea43489df4574ef11bf59cf838adf4fed66f62 100644 (file)
@@ -431,31 +431,7 @@ uerrmsg (uerr_t errnum)
 /* The Windows versions of the following two functions are defined in
    mswindows.c.  */
 
-/* A cuserid() immitation using getpwuid(), to avoid hassling with
-   utmp.  Besides, not all systems have cuesrid().  Under Windows, it
-   is defined in mswindows.c.
-
-   If WHERE is non-NULL, the username will be stored there.
-   Otherwise, it will be returned as a static buffer (as returned by
-   getpwuid()).  In the latter case, the buffer should be copied
-   before calling getpwuid() or pwd_cuserid() again.  */
 #ifndef WINDOWS
-char *
-pwd_cuserid (char *where)
-{
-  struct passwd *pwd;
-
-  if (!(pwd = getpwuid (getuid ())) || !pwd->pw_name)
-    return NULL;
-  if (where)
-    {
-      strcpy (where, pwd->pw_name);
-      return where;
-    }
-  else
-    return pwd->pw_name;
-}
-
 void
 fork_to_background (void)
 {