[Toybox] [PATCH] netcat: Add UNIX domain socket support (-U)

Rob Landley rob at landley.net
Mon Jul 1 13:22:00 PDT 2019


On 7/1/19 3:07 PM, Tom Cherry wrote:
> On Mon, Jul 1, 2019 at 12:57 PM Rob Landley <rob at landley.net> wrote:
>>
>> On 7/1/19 2:34 PM, Tom Cherry via Toybox wrote:
>>> Other implementations of netcat support UNIX domain sockets via -U, so
>>> this change adds it to toybox too.
>>
>> I don't understand this bit?
>>
>> @@ -136,7 +177,7 @@ void netcat_main(void)
>>
>>        do {
>>          child = 0;
>> -        in1 = out2 = accept(sockfd, (struct sockaddr *)address, &len);
>> +        in1 = out2 = accept(sockfd, NULL, NULL);
>>          if (in1<0) perror_exit("accept");
> 
> I was rearranging the variable declarations and saw that address is
> both used in the if statement where I moved their declaration and for
> accept().  It is an output parameter for accept(), but isn't used
> after, and since accept() is specified to allow NULL, NULL here if the
> output parameters aren't used, I removed them.
> 
> I can go back to the original to make this diff smaller if you'd like.

It's fine. I have a todo item to set REMOTE_ADDR and REMOTE_PORT environment
variables in the child process, but that's queued up on some other changes
(which I also need to do for the shell stuff, and for my httpd todo item). I
need to convert this command to FLAG macros anyway, so I'll do a cleanup patch
on top of this.

Thanks. Applied,

Rob



More information about the Toybox mailing list