jonathan@comp.vuw.ac.nz (Jonathan) (09/04/88)
Symptom: Any calls to clnt_broadcast() fail on 4.3bsd with error message "Cannot send broadcast packet: Permission denied", even for the super-user. On Pyramid OSx 4.0, clnt_broadcast() succeeds, but no broadcast UDP packet leaves the local machine. Repeat_By: The broadcast RPC example from the manual is probably sufficient. Diagnosis: On 4.3bsd systems, a socket must be setsockopt()'ed SO_BROADCAST before it can be used for broadcast. SunRPC 3.9 doesn't, causing sendto() to return EACCESS. Fix: For 4.3bsd systems, apply the following context diff. It can easily be made applicable to other 4.3bsd-derived systems (eg, OSx 4.0), if you are prepared to replace the vendor's definition of clnt_broadcast() with the patched SunRPC 3.9 source. I don't know what the effect on non-bsd systems is. *** pmap_rmt.c Sun Sep 4 14:29:24 1988 --- pmap_rmt.bsdfix.c Sun Sep 4 14:28:11 1988 *************** *** 52,57 **** --- 52,59 ---- #include <arpa/inet.h> #define MAX_BROADCAST_SIZE 1400 + #include <sys/param.h> + extern int errno; static struct timeval timeout = { 3, 0 }; *************** *** 241,246 **** --- 243,249 ---- struct rpc_msg msg; struct timeval t; char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; + int brdcst_enbl =1; /* * initialization: create a socket, a broadcast address, and *************** *** 262,267 **** --- 265,279 ---- baddr.sin_family = AF_INET; baddr.sin_port = htons(PMAPPORT); baddr.sin_addr.s_addr = htonl(INADDR_ANY); + + #ifdef BSD4_3 + if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &brdcst_enbl, sizeof (brdcst_enbl)) < 0) { + perror("Broadcast authorization problem"); + stat = RPC_CANTSEND; + goto done_broad; + } + #endif BSD4_3 + /* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */ (void)gettimeofday(&t, (struct timezone *)0); msg.rm_xid = xid = getpid() ^ t.tv_sec ^ t.tv_usec; -- ----------------------------------------------------------------------------- sane mailers: jonathan@comp.vuw.ac.nz | Industrial democracy: UUCP path: ...!uunet!vuwcomp!jonathan | One factory, one vode!