- if (bind(st->fd, (struct sockaddr *)&addr, sizeof(addr))!=0) {
- fatal_perror("udp (%s:%d): bind",st->loc.file,st->loc.line);
+ if (st->authbind) {
+ pid_t c;
+ int status;
+
+ /* XXX this fork() and waitpid() business needs to be hidden
+ in some system-specific library functions. */
+ c=fork();
+ if (c==-1) {
+ fatal_perror("udp_phase_hook: fork() for authbind");
+ }
+ if (c==0) {
+ char *argv[4];
+ argv[0]=st->authbind;
+ argv[1]="00000000";
+ argv[2]=alloca(8);
+ if (!argv[2]) exit(ENOMEM);
+ sprintf(argv[2],"%04X",htons(st->port));
+ argv[3]=NULL;
+ dup2(st->fd,0);
+ execvp(st->authbind,argv);
+ exit(ENOEXEC);
+ }
+ waitpid(c,&status,0);
+ if (WEXITSTATUS(status)!=0) {
+ errno=WEXITSTATUS(status);
+ fatal_perror("udp (%s:%d): authbind",st->loc.file,st->loc.line);
+ }
+ } else {
+ if (bind(st->fd, (struct sockaddr *)&addr, sizeof(addr))!=0) {
+ fatal_perror("udp (%s:%d): bind",st->loc.file,st->loc.line);
+ }