Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/networking/nc_bloaty.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/networking/nc_bloaty.c
r2725 r3232 61 61 //usage: ) 62 62 //usage:#define nc_full_usage "\n\n" 63 //usage: "Options:" 64 //usage: "\n -e PROG Run PROG after connect (must be last)" 63 //usage: " -e PROG Run PROG after connect (must be last)" 65 64 //usage: IF_NC_SERVER( 66 65 //usage: "\n -l Listen mode, for inbound connects" … … 117 116 unsigned wrote_net; /* total net bytes */ 118 117 #endif 118 char *proggie0saved; 119 119 /* ouraddr is never NULL and goes through three states as we progress: 120 120 1 - local address before bind (IP/port possibly zero) … … 129 129 jmp_buf jbuf; /* timer crud */ 130 130 131 /* will malloc up the following globals: */132 131 fd_set ding1; /* for select loop */ 133 132 fd_set ding2; … … 161 160 /* Must match getopt32 call! */ 162 161 enum { 163 OPT_h = (1 << 0), 164 OPT_n = (1 << 1), 165 OPT_p = (1 << 2), 166 OPT_s = (1 << 3), 167 OPT_u = (1 << 4), 168 OPT_v = (1 << 5), 169 OPT_w = (1 << 6), 170 OPT_l = (1 << 7) * ENABLE_NC_SERVER, 171 OPT_i = (1 << (7+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA, 172 OPT_o = (1 << (8+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA, 173 OPT_z = (1 << (9+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA, 162 OPT_n = (1 << 0), 163 OPT_p = (1 << 1), 164 OPT_s = (1 << 2), 165 OPT_u = (1 << 3), 166 OPT_v = (1 << 4), 167 OPT_w = (1 << 5), 168 OPT_l = (1 << 6) * ENABLE_NC_SERVER, 169 OPT_i = (1 << (6+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA, 170 OPT_o = (1 << (7+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA, 171 OPT_z = (1 << (8+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA, 174 172 }; 175 173 … … 265 263 static int doexec(char **proggie) 266 264 { 265 if (G.proggie0saved) 266 proggie[0] = G.proggie0saved; 267 267 xmove_fd(netfd, 0); 268 268 dup2(0, 1); 269 269 /* dup2(0, 2); - do we *really* want this? NO! 270 270 * exec'ed prog can do it yourself, if needed */ 271 execvp(proggie[0], proggie); 272 bb_perror_msg_and_die("can't execute '%s'", proggie[0]); 271 BB_EXECVP_or_die(proggie); 273 272 } 274 273 … … 388 387 /* "nc -nl -p LPORT RHOST" (w/o RPORT!): 389 388 * we should accept any remote port */ 390 set_nport(&remend , 0); /* blot out remote port# */389 set_nport(&remend.u.sa, 0); /* blot out remote port# */ 391 390 } 392 391 r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len); 393 set_nport(&remend , sv_port); /* restore */392 set_nport(&remend.u.sa, sv_port); /* restore */ 394 393 if (r != 0) { 395 394 /* nc 1.10 bails out instead, and its error message … … 431 430 rr = getsockopt(netfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x); 432 431 if (rr >= 0 && x) { /* we've got options, lessee em... */ 433 bin2hex(bigbuf_net, optbuf, x); 434 bigbuf_net[2*x] = '\0'; 432 *bin2hex(bigbuf_net, optbuf, x) = '\0'; 435 433 fprintf(stderr, "IP options: %s\n", bigbuf_net); 436 434 } … … 488 486 o_wait = 5; /* enough that we'll notice?? */ 489 487 rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); 490 set_nport( themaddr, htons(SLEAZE_PORT));488 set_nport(&themaddr->u.sa, htons(SLEAZE_PORT)); 491 489 connect_w_timeout(rr); 492 490 /* don't need to restore themaddr's port, it's not used anymore */ … … 730 728 char *str_p, *str_s; 731 729 IF_NC_EXTRA(char *str_i, *str_o;) 732 char *themdotted = themdotted; /* gcc*/730 char *themdotted = themdotted; /* for compiler */ 733 731 char **proggie; 734 732 int x; … … 758 756 goto e_found; 759 757 } 758 /* -<other_opts>e PROG [ARGS] ? */ 759 /* (aboriginal linux uses this form) */ 760 if (proggie[0][0] == '-') { 761 char *optpos = *proggie + 1; 762 /* Skip all valid opts w/o params */ 763 optpos = optpos + strspn(optpos, "nuv"IF_NC_SERVER("l")IF_NC_EXTRA("z")); 764 if (*optpos == 'e' && !optpos[1]) { 765 *optpos = '\0'; 766 proggie++; 767 G.proggie0saved = *proggie; 768 *proggie = NULL; /* terminate argv for getopt32 */ 769 goto e_found; 770 } 771 } 760 772 } 761 773 proggie = NULL; … … 764 776 // -g -G -t -r deleted, unimplemented -a deleted too 765 777 opt_complementary = "?2:vv:w+"; /* max 2 params; -v is a counter; -w N */ 766 getopt32(argv, " hnp:s:uvw:" IF_NC_SERVER("l")778 getopt32(argv, "np:s:uvw:" IF_NC_SERVER("l") 767 779 IF_NC_EXTRA("i:o:z"), 768 780 &str_p, &str_s, &o_wait … … 815 827 x); 816 828 if (o_lport) 817 set_nport( ouraddr, htons(o_lport));829 set_nport(&ouraddr->u.sa, htons(o_lport)); 818 830 } 819 831 xmove_fd(x, netfd);
Note:
See TracChangeset
for help on using the changeset viewer.