[Toybox] FTP commands

David Seikel onefang at gmail.com
Thu Dec 12 18:11:05 PST 2013


First of all, could every one stop CCing me, I'm actually on the list
and I'm getting this entire conversation twice.  It seems every one
just copies the CC list from the one they are replying to, then adds
one.  The CC list has been steadily growing here.  lol

On Thu, 12 Dec 2013 17:39:56 -0800 ibid.ag at gmail.com wrote:

> On Thu, Dec 12, 2013 at 02:25:38PM +0530, Ashwini Sharma wrote:
> > Hi,
> > 
> > The input parameter port was kept as string, so that the
> >  user can also give service name like "ftp" instead of numeric PORT.
> > 
> > Which will be resolved by getaddrinfo() using /etc/services.
> > 
> > regards,
> > Ashwini
> > 
> Thanks for the explanation.
> Unfortunately it doesn't always work that way:
> 
> //TT.port is initialized to "ftp" if not set
> static void get_sockaddr(char *host)
> {
>   struct addrinfo hints, *result;
>   char *ptr;
>   int status, port;
> 
>   errno = 0;
>   port = strtoul(TT.port, &ptr, 10); // <- may set errno if
> non-numeric port if (errno || port > 65535) error_exit("Invalid port,
> Range is [0-65535]"); // <- we hit this by default on musl
> 
>   memset(&hints, 0 , sizeof(struct addrinfo));
>   hints.ai_family = AF_UNSPEC;
>   hints.ai_socktype = SOCK_STREAM;
> 
>   status = getaddrinfo(host, TT.port, &hints,
>     &result);
>   if (status) error_exit("bad address '%s' : %s",
>     host, gai_strerror(status));
> 
>   memcpy(TT.buf, result->ai_addr, result->ai_addrlen);
>   freeaddrinfo(result);
> }
> 
> I'm thinking that should be 
> -  port = strtoul(TT.port, &ptr, 10);
> +  if (isdigit(TT.port[0])) port = strtoul(TT.port, &ptr, 10);
> 
> and initialize port to 0, if we want to keep support for -P ftp.
> (I don't imagine anyone using -P ssh or any non-numeric port other
> than "ftp".)

Yes keep support for -P.  I use it, and I think Aboriginal Linux uses
it.  At least from the busybox version, and I think we both want to
move to the toybox version.  I think we both use numeric ports for what
it's worth.

> OK, yes that works...
> 
> Attaching my full diff, which also addresses a couple nitpicks:
> 
> -Rob adds new applets to toys/pending/, default n. 
> They get default y when he thinks they're ready.
> -Any user-supplied value is all-caps in the help messages, so
> we have -u USER -p PASSWORD -P PORT
> 
> Thanks,
> Isaac Dunham
> 


-- 
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20131213/b68008f4/attachment-0002.sig>


More information about the Toybox mailing list