ypserv uses the svcudp_create() function with a RPC_ANYSOCK argument. The RPC_ANYSOCK argument does not appear to respect the content of the /etc/services file. This means that it takes ports which belong to other services before they are started (e.g. imaps). Would it be at all sensible to only take ports which are not listed in /etc/services, or at least choose from a range of ports which are not currently allocated in /etc/services. Apologies if this is the wrong place to ask this.
If you would respect /etc/services, there wouldn't be much ports left which are not assigned to other services.
Is it sensible to have some sort of configuration to specify the range of ports you want to use, or a list to exclude? It's annoying to have to specify ports for each RPC daemon, and many RPC daemons don't have this option.
There is nothing which will be done in the library. If you want specific ports to be excluded, start the services early or run placeholder processes which allocate the processes early.