Re: ftp(1) usage/man page HTTP Basic authentication tweaks
Here's a revised version of the diff that was done with a lot of discussion with and help from jmc@. This is what the diff does: * In both usage and the man page synopsis, combine the http and https usage formats into the following so that it is less verbose: ftp [-C] [-c cookie] [-o output] [-s srcaddr] http[s]://[user:password@]host[:port]/file ... * In the AUTO-FETCHING FILES section of the ftp(1) man page, mention that specifying "user" and "password" with HTTP and HTTPS URLs will log in using Basic authentication if http_proxy is not defined. * When compiled with -DSMALL, fix ftp(1) usage so that "[user:password@]" is not shown for http[s]. Looking for more ok's. Lawrence Index: ftp.1 === RCS file: /cvs/src/usr.bin/ftp/ftp.1,v retrieving revision 1.83 diff -u -p -r1.83 ftp.1 --- ftp.1 14 Aug 2012 20:47:08 - 1.83 +++ ftp.1 19 Aug 2012 18:22:21 - @@ -61,18 +61,7 @@ .Op Fl o Ar output .Op Fl s Ar srcaddr .Sm off -.No http:// Oo Ar user : password No @ -.Oc Ar host Oo : Ar port -.Oc No / Ar file -.Sm on -.Ar ... -.Nm ftp -.Op Fl C -.Op Fl c Ar cookie -.Op Fl o Ar output -.Op Fl s Ar srcaddr -.Sm off -.No https:// Oo Ar user : password No @ +.No http[s]:// Oo Ar user : password No @ .Oc Ar host Oo : Ar port .Oc No / Ar file .Sm on @@ -102,7 +91,7 @@ standard File Transfer Protocol (FTP). The program allows a user to transfer files to and from a remote network site. .Pp -The latter five usage formats will fetch a file using either the +The latter four usage formats will fetch a file using either the FTP, HTTP, or HTTPS protocols into the current directory. This is ideal for scripts. Refer to @@ -1272,11 +1261,14 @@ An FTP URL, retrieved using the FTP prot isn't defined. Otherwise, transfer using HTTP via the proxy defined in .Ev ftp_proxy . -If -.Ar user : Ns Ar password Ns @ -is given and +If a +.Ar user +and +.Ar password +are given and .Ev ftp_proxy -isn't defined, log in as +isn't defined, +log in as .Ar user with a password of .Ar password . @@ -1285,12 +1277,36 @@ An HTTP URL, retrieved using the HTTP pr If .Ev http_proxy is defined, it is used as a URL to an HTTP proxy server. +If a +.Ar user +and +.Ar password +are given and +.Ev http_proxy +isn't defined, +log in as +.Ar user +with a password of +.Ar password +using Basic authentication. .It https://[user:password@]host[:port]/file An HTTPS URL, retrieved using the HTTPS protocol. If .Ev http_proxy is defined, this HTTPS proxy server will be used to fetch the file using the CONNECT method. +If a +.Ar user +and +.Ar password +are given and +.Ev http_proxy +isn't defined, +log in as +.Ar user +with a password of +.Ar password +using Basic authentication. .It file:file .Ar file is retrieved from a mounted file system. Index: main.c === RCS file: /cvs/src/usr.bin/ftp/main.c,v retrieving revision 1.84 diff -u -p -r1.84 main.c --- main.c 14 Aug 2012 20:47:08 - 1.84 +++ main.c 19 Aug 2012 01:47:56 - @@ -778,13 +778,15 @@ usage(void) "[-s srcaddr]\n" " " #endif /* !SMALL */ - "http://[user:password@]host[:port]/file ...\n" + "http" #ifndef SMALL - " %s [-C] [-c cookie] [-o output] [-s srcaddr]\n" - " " - "https://[user:password@]host[:port]/file\n"; - " ...\n" -#endif /* !SMALL */ + "[s]" +#endif + "://" +#ifndef SMALL + "[user:password@]" +#endif + "host[:port]/file ...\n" " %s " #ifndef SMALL "[-C] " @@ -804,8 +806,7 @@ usage(void) #endif /* !SMALL */ "host:/file[/] ...\n", #ifndef SMALL - __progname, __progname, __progname, __progname, __progname, - __progname); + __progname, __progname, __progname, __progname, __progname); #else /* !SMALL */ __progname, __progname, __progname, __progname); #endif /* !SMALL */
Re: ftp(1) usage/man page HTTP Basic authentication tweaks
On Wed, Aug 15, 2012 at 06:09:34AM +0100, Jason McIntyre wrote: > On Tue, Aug 14, 2012 at 10:38:21PM -0400, Lawrence Teo wrote: > > This is a small follow-up diff to haesbaert@'s recent commit that > > enables HTTP Basic authentication in ftp(1): > > > > * In the AUTO-FETCHING FILES section of the ftp(1) man page, describe > > what [user:password@] does when used with HTTP and HTTPS URLs. > > > > * Fix usage formatting to match man page SYNOPSIS exactly. > > > > * Fix usage to hide [user:password@] for http/https when compiled > > with -DSMALL. > > > > Thoughts? OK? > > > > i'm ok with this, but i wonder if we couldn;t make things less verbose: > > - combine the http and https lines, at least in SYNOPSIS/usage(), into > one http[s] line. I was slightly hesitant about this at first, but now that I've tried it I like how nice and compact it is. :) Hopefully using "http[s]" in the man page source is the right way to do it, but if I should be using a macro for the square brackets instead, please let me know and I'll fix it. > - there is some scope at the beginning of the AUTO-FETCHING FILES > section to describe "user" and "password", and avoid having to repeat > the text three times. i know it combines withstuff about proxys > (proxies?). This is slightly trickier since the way "user" and "password" works for FTP v.s. HTTP/HTTPS is not the same. I did manage to reduce the repetitiveness somewhat by describing them at the beginning of AUTO-FETCHING FILES as you suggested. If you have thoughts on how the text can be improved, I'll be glad to change it. Thank you, Lawrence Index: ftp.1 === RCS file: /cvs/src/usr.bin/ftp/ftp.1,v retrieving revision 1.83 diff -u -p -r1.83 ftp.1 --- ftp.1 14 Aug 2012 20:47:08 - 1.83 +++ ftp.1 16 Aug 2012 02:05:48 - @@ -61,18 +61,7 @@ .Op Fl o Ar output .Op Fl s Ar srcaddr .Sm off -.No http:// Oo Ar user : password No @ -.Oc Ar host Oo : Ar port -.Oc No / Ar file -.Sm on -.Ar ... -.Nm ftp -.Op Fl C -.Op Fl c Ar cookie -.Op Fl o Ar output -.Op Fl s Ar srcaddr -.Sm off -.No https:// Oo Ar user : password No @ +.No http[s]:// Oo Ar user : password No @ .Oc Ar host Oo : Ar port .Oc No / Ar file .Sm on @@ -1260,6 +1249,29 @@ supports an auto-fetch feature. To enable auto-fetch, simply pass the list of hostnames/files on the command line. .Pp +If +.Ar user : Ns Ar password Ns @ +is given for an FTP URL and +.Ev ftp_proxy +isn't defined, +.Nm +will log in as +.Ar user +with a password of +.Ar password . +Similarly, if +.Ar user : Ns Ar password Ns @ +is given for an HTTP or HTTPS URL and +.Ev http_proxy +isn't defined, +.Nm +will authenticate as +.Ar user +with a password of +.Ar password +to retrieve the URL using Basic authentication as defined in +RFC 2617. +.Pp The following formats are valid syntax for an auto-fetch element: .Bl -tag -width Ds .It host:/file[/] @@ -1272,14 +1284,6 @@ An FTP URL, retrieved using the FTP prot isn't defined. Otherwise, transfer using HTTP via the proxy defined in .Ev ftp_proxy . -If -.Ar user : Ns Ar password Ns @ -is given and -.Ev ftp_proxy -isn't defined, log in as -.Ar user -with a password of -.Ar password . .It http://[user:password@]host[:port]/file An HTTP URL, retrieved using the HTTP protocol. If Index: main.c === RCS file: /cvs/src/usr.bin/ftp/main.c,v retrieving revision 1.84 diff -u -p -r1.84 main.c --- main.c 14 Aug 2012 20:47:08 - 1.84 +++ main.c 16 Aug 2012 01:49:48 - @@ -778,13 +778,15 @@ usage(void) "[-s srcaddr]\n" " " #endif /* !SMALL */ - "http://[user:password@]host[:port]/file ...\n" + "http" #ifndef SMALL - " %s [-C] [-c cookie] [-o output] [-s srcaddr]\n" - " " - "https://[user:password@]host[:port]/file\n"; - " ...\n" -#endif /* !SMALL */ + "[s]" +#endif + "://" +#ifndef SMALL + "[user:password@]" +#endif + "host[:port]/file ...\n" " %s " #ifndef SMALL "[-C] " @@ -804,8 +806,7 @@ usage(void) #endif /* !SMALL */ "host:/file[/] ...\n", #ifndef SMALL - __progname, __progname, __progname, __progname, __progname, - __progname); + __progname, __progname, __progname, __progname, __progname); #else /* !SMALL */ __progname, __progname, __progname, __progname); #endif /* !SMALL */
Re: ftp(1) usage/man page HTTP Basic authentication tweaks
On Tue, Aug 14, 2012 at 10:38:21PM -0400, Lawrence Teo wrote: > This is a small follow-up diff to haesbaert@'s recent commit that > enables HTTP Basic authentication in ftp(1): > > * In the AUTO-FETCHING FILES section of the ftp(1) man page, describe > what [user:password@] does when used with HTTP and HTTPS URLs. > > * Fix usage formatting to match man page SYNOPSIS exactly. > > * Fix usage to hide [user:password@] for http/https when compiled > with -DSMALL. > > Thoughts? OK? > i'm ok with this, but i wonder if we couldn;t make things less verbose: - combine the http and https lines, at least in SYNOPSIS/usage(), into one http[s] line. - there is some scope at the beginning of the AUTO-FETCHING FILES section to describe "user" and "password", and avoid having to repeat the text three times. i know it combines withstuff about proxys (proxies?). what do you think? jmc > > Index: ftp.1 > === > RCS file: /cvs/src/usr.bin/ftp/ftp.1,v > retrieving revision 1.83 > diff -u -p -r1.83 ftp.1 > --- ftp.1 14 Aug 2012 20:47:08 - 1.83 > +++ ftp.1 15 Aug 2012 02:07:33 - > @@ -1285,12 +1285,32 @@ An HTTP URL, retrieved using the HTTP pr > If > .Ev http_proxy > is defined, it is used as a URL to an HTTP proxy server. > +If > +.Ar user : Ns Ar password Ns @ > +is given and > +.Ev http_proxy > +isn't defined, authenticate as > +.Ar user > +with a password of > +.Ar password > +to retrieve the URL using Basic authentication as defined in > +RFC 2617. > .It https://[user:password@]host[:port]/file > An HTTPS URL, retrieved using the HTTPS protocol. > If > .Ev http_proxy > is defined, this HTTPS proxy server will be used to fetch the > file using the CONNECT method. > +If > +.Ar user : Ns Ar password Ns @ > +is given and > +.Ev http_proxy > +isn't defined, authenticate as > +.Ar user > +with a password of > +.Ar password > +to retrieve the URL using Basic authentication as defined in > +RFC 2617. > .It file:file > .Ar file > is retrieved from a mounted file system. > Index: main.c > === > RCS file: /cvs/src/usr.bin/ftp/main.c,v > retrieving revision 1.84 > diff -u -p -r1.84 main.c > --- main.c14 Aug 2012 20:47:08 - 1.84 > +++ main.c15 Aug 2012 01:51:07 - > @@ -778,12 +778,15 @@ usage(void) > "[-s srcaddr]\n" > " " > #endif /* !SMALL */ > - "http://[user:password@]host[:port]/file ...\n" > + "http://"; > +#ifndef SMALL > + "[user:password@]" > +#endif > + "host[:port]/file ...\n" > #ifndef SMALL > " %s [-C] [-c cookie] [-o output] [-s srcaddr]\n" > " " > - "https://[user:password@]host[:port]/file\n"; > - " ...\n" > + "https://[user:password@]host[:port]/file ...\n" > #endif /* !SMALL */ > " %s " > #ifndef SMALL
ftp(1) usage/man page HTTP Basic authentication tweaks
This is a small follow-up diff to haesbaert@'s recent commit that enables HTTP Basic authentication in ftp(1): * In the AUTO-FETCHING FILES section of the ftp(1) man page, describe what [user:password@] does when used with HTTP and HTTPS URLs. * Fix usage formatting to match man page SYNOPSIS exactly. * Fix usage to hide [user:password@] for http/https when compiled with -DSMALL. Thoughts? OK? Index: ftp.1 === RCS file: /cvs/src/usr.bin/ftp/ftp.1,v retrieving revision 1.83 diff -u -p -r1.83 ftp.1 --- ftp.1 14 Aug 2012 20:47:08 - 1.83 +++ ftp.1 15 Aug 2012 02:07:33 - @@ -1285,12 +1285,32 @@ An HTTP URL, retrieved using the HTTP pr If .Ev http_proxy is defined, it is used as a URL to an HTTP proxy server. +If +.Ar user : Ns Ar password Ns @ +is given and +.Ev http_proxy +isn't defined, authenticate as +.Ar user +with a password of +.Ar password +to retrieve the URL using Basic authentication as defined in +RFC 2617. .It https://[user:password@]host[:port]/file An HTTPS URL, retrieved using the HTTPS protocol. If .Ev http_proxy is defined, this HTTPS proxy server will be used to fetch the file using the CONNECT method. +If +.Ar user : Ns Ar password Ns @ +is given and +.Ev http_proxy +isn't defined, authenticate as +.Ar user +with a password of +.Ar password +to retrieve the URL using Basic authentication as defined in +RFC 2617. .It file:file .Ar file is retrieved from a mounted file system. Index: main.c === RCS file: /cvs/src/usr.bin/ftp/main.c,v retrieving revision 1.84 diff -u -p -r1.84 main.c --- main.c 14 Aug 2012 20:47:08 - 1.84 +++ main.c 15 Aug 2012 01:51:07 - @@ -778,12 +778,15 @@ usage(void) "[-s srcaddr]\n" " " #endif /* !SMALL */ - "http://[user:password@]host[:port]/file ...\n" + "http://"; +#ifndef SMALL + "[user:password@]" +#endif + "host[:port]/file ...\n" #ifndef SMALL " %s [-C] [-c cookie] [-o output] [-s srcaddr]\n" " " - "https://[user:password@]host[:port]/file\n"; - " ...\n" + "https://[user:password@]host[:port]/file ...\n" #endif /* !SMALL */ " %s " #ifndef SMALL