mirror of
https://git.savannah.gnu.org/git/inetutils.git
synced 2026-01-12 00:19:39 +08:00
ftp: Allow remote user in command.
Implement the extended host argument form `user@host' for quick selection of the remote user name.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
||||
2016-01-23 Mats Erik Andersson <gnu@gisladisker.se>
|
||||
|
||||
ftp: Allow remote user in command.
|
||||
|
||||
* ftp/ftp.c (hookup): Check for an embedded at-sign in the input
|
||||
variable `host', keeping the rightmost part. New variable P.
|
||||
(login): Likewise, but also using the string part to the left of
|
||||
the last at-sign as remote user name.
|
||||
|
||||
* doc/inetutils.texi (ftp invocation): Document this ability.
|
||||
* NEWS: Likewise.
|
||||
|
||||
2016-01-22 Mats Erik Andersson <gnu@gisladisker.se>
|
||||
|
||||
* bootstrap: Updated from gnulib.
|
||||
|
||||
5
NEWS
5
NEWS
@@ -5,6 +5,11 @@ Free Software Foundation, Inc.
|
||||
See the end of this file for license conditions.
|
||||
|
||||
Please send inetutils bug reports to <bug-inetutils@gnu.org>.
|
||||
|
||||
* ftp
|
||||
|
||||
Allow invocation, as well as command `open', to accept an explicit
|
||||
remote user name as extended host argument: `user@host'.
|
||||
|
||||
June 9, 2015
|
||||
Version 1.9.4:
|
||||
|
||||
@@ -1527,6 +1527,9 @@ Synopsis:
|
||||
@example
|
||||
ftp [@var{option}@dots{}] [@var{host} [@var{port}]]
|
||||
pftp [@var{option}@dots{}] [@var{host} [@var{port}]]
|
||||
|
||||
ftp [@var{option}@dots{}] @var{user@@host} [@var{port}]
|
||||
pftp [@var{option}@dots{}] @var{user@@host} [@var{port}]
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
@@ -1537,6 +1540,7 @@ The client host with which @command{ftp} is to communicate may be
|
||||
specified on the command line.
|
||||
If this is done, @command{ftp} will immediately attempt to establish
|
||||
a connection to the FTP server running on that host.
|
||||
Optionally, a remote user name can be specified at will.
|
||||
Otherwise, the program will start a command interpreter and will await
|
||||
further instructions from the user.
|
||||
Commands can either be entered interactively,
|
||||
@@ -2004,6 +2008,7 @@ character's position in @var{inchars} is longer than the length of
|
||||
@var{outchars}, the character is deleted from the file name.
|
||||
|
||||
@item open @var{host} [@var{port}]
|
||||
@itemx open @var{user@@host} [@var{port}]
|
||||
Establish a connection to the specified FTP server
|
||||
at @var{host}. An optional port number may be supplied,
|
||||
in which case, @command{ftp} will attempt to contact the server
|
||||
@@ -2011,6 +2016,10 @@ at that specific TCP port. If the @code{autologin} option
|
||||
is on (is so by default), @command{ftp} will also attempt to
|
||||
automatically log the user in to the FTP server.
|
||||
|
||||
The second form of invocation sets the remote user name to @var{user},
|
||||
which otherwise is taken as identical to the user identity owning the
|
||||
local session.
|
||||
|
||||
@item passive
|
||||
Toggle passive mode. If passive mode is turned on (default is off),
|
||||
the @command{ftp} client will send a @code{PASV} command for all data
|
||||
|
||||
17
ftp/ftp.c
17
ftp/ftp.c
@@ -133,7 +133,11 @@ hookup (char *host, int port)
|
||||
int s, tos;
|
||||
socklen_t len;
|
||||
static char hostnamebuf[80];
|
||||
char *rhost;
|
||||
char *rhost, *p;
|
||||
|
||||
p = strrchr (host, '@');
|
||||
if (p && p != host && isprint (p[1]))
|
||||
host = ++p;
|
||||
|
||||
#ifdef HAVE_IDN
|
||||
status = idna_to_ascii_lz (host, &rhost, 0);
|
||||
@@ -293,7 +297,7 @@ int
|
||||
login (char *host)
|
||||
{
|
||||
char tmp[80];
|
||||
char *user, *pass, *acct;
|
||||
char *user, *pass, *acct, *p;
|
||||
int n, aflag = 0;
|
||||
|
||||
user = pass = acct = 0;
|
||||
@@ -302,6 +306,15 @@ login (char *host)
|
||||
code = -1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
p = strrchr (host, '@');
|
||||
if (user == NULL && p && p != host && isprint (p[1]))
|
||||
{
|
||||
*p = 0;
|
||||
user = host;
|
||||
host = ++p;
|
||||
}
|
||||
|
||||
while (user == NULL)
|
||||
{
|
||||
char *myname = getlogin ();
|
||||
|
||||
Reference in New Issue
Block a user