#endif
#endif
+/*
+ * We record with each registration a flag telling whether it was
+ * registered with a privilege port or not.
+ * If it was, it can only be unregistered with a privileged port.
+ * So that we can still use standard pmap xdr routines, we store
+ * this flag in a structure wrapped around a pmaplist.
+ */
+struct flagged_pml {
+ struct pmaplist pml;
+ int priv;
+};
+
int
main(int argc, char **argv)
{
struct sockaddr_in addr;
int len = sizeof(struct sockaddr_in);
struct pmaplist *pml;
+ struct flagged_pml *fpml;
char *chroot_path = NULL;
struct in_addr bindaddr;
int have_bindaddr = 0;
exit(1);
}
/* make an entry for ourself */
- pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist));
- pml->pml_next = 0;
+ fpml = malloc(sizeof(struct flagged_pml));
+ pml = &fpml->pml;
+ fpml->priv = 1;
+ pml->pml_next = NULL;
pml->pml_map.pm_prog = PMAPPROG;
pml->pml_map.pm_vers = PMAPVERS;
pml->pml_map.pm_prot = IPPROTO_UDP;
exit(1);
}
/* make an entry for ourself */
- pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist));
+ fpml = malloc(sizeof(struct flagged_pml));
+ pml = &fpml->pml;
+ fpml->priv = 1;
pml->pml_map.pm_prog = PMAPPROG;
pml->pml_map.pm_vers = PMAPVERS;
pml->pml_map.pm_prot = IPPROTO_TCP;
{
struct pmap reg;
struct pmaplist *pml, *prevpml, *fnd;
+ struct flagged_pml *fpml;
int ans, port;
caddr_t t;
/*
* add to END of list
*/
- pml = (struct pmaplist *)
- malloc((u_int)sizeof(struct pmaplist));
+ fpml = (struct flagged_pml *)
+ malloc((u_int)sizeof(struct flagged_pml));
+ pml = &fpml->pml;
+ fpml->priv =
+ (ntohs(svc_getcaller(xprt)->sin_port)
+ < IPPORT_RESERVED);
pml->pml_map = reg;
pml->pml_next = 0;
+
if (pmaplist == 0) {
pmaplist = pml;
} else {
ans = 0;
break;
}
+ fpml = (struct flagged_pml*)pml;
+ if (fpml->priv &&
+ (ntohs(svc_getcaller(xprt)->sin_port)
+ >= IPPORT_RESERVED)) {
+ ans = 0;
+ break;
+ }
+
ans = 1;
t = (caddr_t)pml;
pml = pml->pml_next;