From MAILER-DAEMON Thu Jun 12 13:00:13 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wv8MH-0004GA-Ck
	for mharc-commit-inetutils@gnu.org; Thu, 12 Jun 2014 13:00:13 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50801)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Wv8ME-0004F9-P8
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 13:00:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Wv8MD-00030G-2D
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 13:00:10 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:60742)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Wv8MC-000309-Vi
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 13:00:09 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1Wv8MB-0000SX-IT
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 17:00:07 +0000
Date: Thu, 12 Jun 2014 17:00:07 +0000
Message-Id: <E1Wv8MB-0000SX-IT@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_2-22-g38246ac
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a776a603369e644f031eee771bf388ab0edb3b91
X-Git-Newrev: 38246ac903db567f149dad428403f2182ea03b4e
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jun 2014 17:00:12 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  38246ac903db567f149dad428403f2182ea03b4e (commit)
      from  a776a603369e644f031eee771bf388ab0edb3b91 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=38246ac903db567f149dad428403f2182ea03b4e


commit 38246ac903db567f149dad428403f2182ea03b4e
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Jun 5 23:31:56 2014 +0200

    ftp: Allow other locations of netrc file.
    
    Introduce a command line option and an environment
    variable to override the legacy location $HOME/.netrc.

diff --git a/ChangeLog b/ChangeLog
index f3a0470..9967cf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2014-06-05  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftp: Alternate selection of .netrc file.
+
+	* ftp/ftp_var.h (netrc): New variable.
+	* ftp/main.c (argp_options) <-N/--netrc>: New option.
+	(parse_opt) <'N'>: New case.
+	(main): Initialize `netrc'.
+	* ftp/ruserpass.c (remote_userpass): If `netrc' is NULL,
+	check NETRC in environment.  Whenever `netrc' has content,
+	us it instead of `~/.netrc'.  Once CFILE is valid, make
+	sure that the file location is a regular file, otherwise
+	returning to the interpreter.
+
+	* tests/ftp-localhost.sh: Two new test cases, checking the
+	functionality of NETRC in environment, and the option `-N'.
+
 2014-05-16  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftp: Size multipliers for hash increments.
diff --git a/NEWS b/NEWS
index ec49848..ec41f5f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,15 @@ Please send inetutils bug reports to <bug-inetutils@gnu.org>.
 
 Version 1.9.3:
 
+* ftp
+
+The internal command `hash' accepts a suffixed letter to the
+size argument, like `12k', instead of 12288. Also, the .netrc
+file can be overridden by the environment variable NETRC.
+Of even higher precedence is the new option `-N/--netrc'.
+The access to the resulting file, whatever method, is now
+denied unless it as a regular file.
+
 * syslogd
 
 A new switch `-T/--local-time' makes the service ignore a time
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index aff02e9..21a33b5 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -1381,6 +1381,15 @@ Disables file name globbing.
 @opindex --no-prompt
 Turns off interactive prompting during multiple file transfers.
 
+@item -N @var{netrc}
+@itemx --netrc=@var{netrc}
+@opindex -N
+@opindex --netrc
+Set a preferred location of the @file{.netrc} file,
+thus overriding any environment setting in @env{NETRC},
+as well as the default location @file{$HOME/.netrc},
+@pxref{The .netrc file}.
+
 @item -n
 @itemx --no-login
 @opindex -n
@@ -2046,8 +2055,13 @@ Avoid this problem by using the binary image type.
 @flindex .netrc
 
 The @file{.netrc} file contains login and initialization information
-used by the auto-login process.  It resides in the user's home
-directory.  The following tokens are recognized; they may be separated
+used by the auto-login process.  It generally resides in the user's
+home directory, but a location outside of the home directory
+can be set using the environment variable @env{NETRC}.
+Both locations are overridden by the command line option @option{-N}.
+The selected file must be a regular file, or access will be denied.
+
+The following tokens are recognized; they may be separated
 by spaces, tabs, or new-lines:
 
 @table @samp
@@ -2108,6 +2122,10 @@ executed as the last step in the auto-login process.
 @item HOME
 Used for locating a @file{.netrc} file, if one exists.
 
+@item NETRC
+Alternate location of the @file{.netrc} file,
+taking precedence over the standard location.
+
 @item SHELL
 For determining the default shell interpreter.
 @end table
diff --git a/ftp/ftp_var.h b/ftp/ftp_var.h
index 02ea7ba..ebe2c10 100644
--- a/ftp/ftp_var.h
+++ b/ftp/ftp_var.h
@@ -108,6 +108,7 @@ FTP_EXTERN char bytename[32];	/* local byte size in ascii */
 FTP_EXTERN int bytesize;	/* local byte size in binary */
 
 FTP_EXTERN char *hostname;	/* name of host connected to */
+FTP_EXTERN char *netrc;		/* netrc file chosen on command line */
 FTP_EXTERN int unix_server;	/* server is unix, can use binary for ascii */
 FTP_EXTERN int unix_proxy;	/* proxy is unix, can use binary for ascii */
 
diff --git a/ftp/main.c b/ftp/main.c
index cb52729..a3d252e 100644
--- a/ftp/main.c
+++ b/ftp/main.c
@@ -134,6 +134,8 @@ static struct argp_option argp_options[] = {
   {"verbose", 'v', NULL, 0, "verbose output", GRP+1},
   {"ipv4", '4', NULL, 0, "contact IPv4 hosts", GRP+1},
   {"ipv6", '6', NULL, 0, "contact IPv6 hosts", GRP+1},
+  {"netrc", 'N', "NETRC", 0, "select a specific initialization file",
+   GRP+1},
 #undef GRP
   {NULL, 0, NULL, 0, NULL, 0}
 };
@@ -192,6 +194,10 @@ parse_opt (int key, char *arg, struct argp_state *state _GL_UNUSED_PARAMETER)
       usefamily = AF_INET6;
       break;
 
+    case 'N':
+      netrc = arg;
+      break;
+
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -228,6 +234,7 @@ main (int argc, char *argv[])
   line = NULL;			/* reset global input */
   linelen = 0;
   argbuf = NULL;
+  netrc = NULL;
 
   /* Invoked as `pftp'?  Then set passive mode.  */
   cp = strrchr (argv[0], '/');
diff --git a/ftp/ruserpass.c b/ftp/ruserpass.c
index 2b8edec..953c853 100644
--- a/ftp/ruserpass.c
+++ b/ftp/ruserpass.c
@@ -123,6 +123,14 @@ remote_userpass (char *host, char **aname, char **apass, char **aacct)
   if (hdir == NULL)
     hdir = ".";
   snprintf (buf, sizeof buf, "%s/.netrc", hdir);
+
+  /* The switch `-N/--netrc' would have set this.  */
+  if (!netrc)
+    netrc = getenv ("NETRC");
+
+  if (netrc && netrc[0])
+    snprintf (buf, sizeof buf, "%s", netrc);
+
   cfile = fopen (buf, "r");
   if (cfile == NULL)
     {
@@ -131,6 +139,28 @@ remote_userpass (char *host, char **aname, char **apass, char **aacct)
       return (0);
     }
 
+  /* The .netrc is now opened and is thus fixed.
+   * Check that it is a regular file, and not a
+   * soft link in particular.
+   */
+  if (lstat (buf, &stb) < 0)
+    {
+      error (0, errno, "%s", buf);
+      fclose (cfile);
+      return (-1);
+    }
+
+  if (!S_ISREG (stb.st_mode))
+    {
+      if (S_ISLNK (stb.st_mode))
+	error (0, 0, "the .netrc file is symbolic link: %s", buf);
+      else
+	error (0, 0, "the .netrc file is no regular file: %s", buf);
+
+      fclose (cfile);
+      return (-1);
+    }
+
   myname = localhost ();
   if (!myname)
     myname = xstrdup ("");
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index 592fa1a..dc14009 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -393,6 +393,37 @@ HOME=$TMPDIR $FTP "$TARGET" $PORT -4 -v -p -t >$TMPDIR/ftp.stdout 2>&1
 
 test_report $? "$TMPDIR/ftp.stdout" "EPSV/$TARGET"
 
+# Test a passive connection: EPSV and IPv4.
+#
+# Set NETRC in environment to regulate login.
+#
+echo "EPSV to $TARGET (IPv4) using inetd, setting NETRC."
+cat <<STOP |
+rstatus
+epsv4
+dir
+`$do_transfer && test -n "$DLDIR" && echo "\
+cd $DLDIR"`
+`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
+STOP
+
+NETRC=$TMPDIR/.netrc \
+  $FTP "$TARGET" $PORT -4 -v -p -t >$TMPDIR/ftp.stdout 2>&1
+
+test_report $? "$TMPDIR/ftp.stdout" "EPSV/$TARGET with NETRC"
+
+$do_transfer && \
+    if cmp -s "$TMPDIR/$GETME" "$FTPHOME$DLDIR/$PUTME"; then
+	test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	date "+%s" >> "$TMPDIR/$GETME"
+    else
+	echo >&2 'Binary transfer failed.'
+	exit 1
+    fi
+
 # Test an active connection: EPRT and IPv4.
 #
 echo "EPRT to $TARGET (IPv4) using inetd."
@@ -420,6 +451,21 @@ $do_transfer && \
 	exit 1
     fi
 
+# Test an active connection: EPRT and IPv4.
+#
+# Use `-N' to set location of .netrc file.
+#
+echo "EPRT to $TARGET (IPv4) using inetd, apply the switch -N."
+cat <<STOP |
+rstatus
+epsv4
+dir
+STOP
+
+$FTP "$TARGET" $PORT -N"$TMPDIR/.netrc" -4 -v -t >$TMPDIR/ftp.stdout 2>&1
+
+test_report $? "$TMPDIR/ftp.stdout" "EPRT/$TARGET"
+
 # Test a passive connection: EPSV and IPv6.
 #
 echo "EPSV to $TARGET6 (IPv6) using inetd."

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |   17 +++++++++++++++++
 NEWS                   |    9 +++++++++
 doc/inetutils.texi     |   22 ++++++++++++++++++++--
 ftp/ftp_var.h          |    1 +
 ftp/main.c             |    7 +++++++
 ftp/ruserpass.c        |   30 ++++++++++++++++++++++++++++++
 tests/ftp-localhost.sh |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 130 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Jun 12 15:12:12 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WvAQ0-00037E-23
	for mharc-commit-inetutils@gnu.org; Thu, 12 Jun 2014 15:12:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35562)
	by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <ams@gnu.org>)
	id 1WvAPy-00036F-Hm
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 15:12:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ams@gnu.org>) id 1WvAPx-0004Aj-Fa
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 15:12:10 -0400
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45436)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ams@gnu.org>)
	id 1WvAPx-0004AO-DD
	for commit-inetutils@gnu.org; Thu, 12 Jun 2014 15:12:09 -0400
Received: from ams by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <ams@gnu.org>)
	id 1WvAPw-0003af-SL; Thu, 12 Jun 2014 15:12:08 -0400
Date: Thu, 12 Jun 2014 15:12:08 -0400
Message-Id: <E1WvAPw-0003af-SL@fencepost.gnu.org>
From: ams@gnu.org (Alfred M. Szmidt)
To: Mats Erik Andersson <gnu@gisladisker.se>
In-reply-to: <E1Wv8MB-0000SX-IT@vcs.savannah.gnu.org> (message from Mats Erik
	Andersson on Thu, 12 Jun 2014 17:00:07 +0000)
Subject: Re: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_2-22-g38246ac
References: <E1Wv8MB-0000SX-IT@vcs.savannah.gnu.org>
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
	(bad octet value).
X-Received-From: 2001:4830:134:3::e
Cc: commit-inetutils@gnu.org
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: ams@gnu.org
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jun 2014 19:12:11 -0000

   commit 38246ac903db567f149dad428403f2182ea03b4e
   Author: Mats Erik Andersson <gnu@gisladisker.se>
   Date:   Thu Jun 5 23:31:56 2014 +0200

       ftp: Allow other locations of netrc file.

       Introduce a command line option and an environment
       variable to override the legacy location $HOME/.netrc.

Cool!

(yes, still alive)


