Re: [Toybox] FTP commands

2013-12-12 Thread Ashwini Sharma
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


On Thu, Dec 12, 2013 at 1:27 PM, ibid...@gmail.com wrote:

 Thanks!
 Noticed a few differences from standard help messages, plus a small
 problem with the port number handling:
 when no port was specified, it failed.
 The solution ended up dropping a couple lines.

 Attached is the diff from your second version.

 Thanks,
 Isaac Dunham

 ___
 Toybox mailing list
 Toybox@lists.landley.net
 http://lists.landley.net/listinfo.cgi/toybox-landley.net


___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] FTP commands

2013-12-12 Thread David Seikel
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...@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.


signature.asc
Description: PGP signature
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net