+ if (uc->authbind) {
+ pid_t c;
+ int status;
+ char desc[200];
+ snprintf(desc,sizeof(desc),"authbind for %s: %s",
+ iaddr_to_string(addr), uc->authbind);
+
+ /* XXX this fork() and waitpid() business needs to be hidden
+ in some system-specific library functions. */
+ c=fork();
+ if (c==-1)
+ FAIL("fork() for authbind");
+ if (c==0) {
+ char *argv[5], addrstr[33], portstr[5];
+ const char *addrfam;
+ int port;
+ afterfork();
+ switch (addr->sa.sa_family) {
+ case AF_INET:
+ sprintf(addrstr,"%08lX",(long)addr->sin.sin_addr.s_addr);
+ port=addr->sin.sin_port;
+ addrfam=NULL;
+ break;
+#ifdef CONFIG_IPV6
+ case AF_INET6: {
+ int i;
+ for (i=0; i<16; i++)
+ sprintf(addrstr+i*2,"%02X",addr->sin6.sin6_addr.s6_addr[i]);
+ port=addr->sin6.sin6_port;
+ addrfam="6";
+ break;
+ }
+#endif /*CONFIG_IPV6*/
+ default:
+ fatal("udp (%s:%d): unsupported address family for authbind",
+ cc->loc.file,cc->loc.line);
+ }
+ sprintf(portstr,"%04X",port);
+ argv[0]=uc->authbind;
+ argv[1]=addrstr;
+ argv[2]=portstr;
+ argv[3]=(char*)addrfam;
+ argv[4]=NULL;
+ dup2(us->fd,0);
+ execvp(uc->authbind,argv);
+ _exit(255);
+ }
+ while (waitpid(c,&status,0)==-1) {
+ if (errno==EINTR) continue;
+ FAIL("waitpid for authbind");
+ }
+ if (status) {
+ if (WIFEXITED(status) && WEXITSTATUS(status)<127) {
+ int es=WEXITSTATUS(status);
+ lg_perror(FAIL_LG,es,
+ "%s exited with error exit status %d;"
+ " indicates error",desc,es);
+ } else {
+ lg_exitstatus(FAIL_LG,status,desc);
+ }
+ goto failed;
+ }
+ } else {
+ if (bind(us->fd, &addr->sa, iaddr_socklen(addr))!=0)
+ FAIL("bind (%s)",iaddr_to_string(addr));
+ }
+
+ bool_t ok=record_socket_gotaddr(uc,us,failmsgclass);
+ if (!ok) goto failed;