deal with namespace pollution caused by tcpd.

This commit is contained in:
christos 2007-05-16 14:42:07 +00:00
parent f53e6de8bc
commit 724513abed
5 changed files with 20 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap_svc.c,v 1.5 2007/05/13 20:03:47 christos Exp $ */
/* $NetBSD: pmap_svc.c,v 1.6 2007/05/16 14:42:07 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -199,9 +199,9 @@ pmapproc_change(struct svc_req *rqstp, SVCXPRT *xprt, unsigned long op)
* and looping.
*/
if (sc == NULL)
rpcbreg.r_owner = __UNCONST(unknown);
rpcbreg.r_owner = __UNCONST(rpcbind_unknown);
else if (sc->sc_uid == 0)
rpcbreg.r_owner = __UNCONST(superuser);
rpcbreg.r_owner = __UNCONST(rpcbind_superuser);
else {
/* r_owner will be strdup-ed later */
snprintf(uidbuf, sizeof uidbuf, "%d", sc->sc_uid);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpcb_svc_com.c,v 1.11 2007/05/13 20:03:47 christos Exp $ */
/* $NetBSD: rpcb_svc_com.c,v 1.12 2007/05/16 14:42:07 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -255,7 +255,7 @@ map_unset(RPCB *regp, const char *owner)
* Check whether appropriate uid. Unset only
* if superuser or the owner itself.
*/
if (strcmp(owner, superuser) &&
if (strcmp(owner, rpcbind_superuser) &&
strcmp(rbl->rpcb_map.r_owner, owner))
return (0);
/* found it; rbl moves forward, prev stays */
@ -297,7 +297,7 @@ delete_prog(int prog)
reg.r_prog = rbl->rpcb_map.r_prog;
reg.r_vers = rbl->rpcb_map.r_vers;
reg.r_netid = strdup(rbl->rpcb_map.r_netid);
(void)map_unset(&reg, superuser);
(void)map_unset(&reg, rpcbind_superuser);
free(reg.r_netid);
}
}
@ -672,11 +672,12 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
fprintf(stderr, "%s %s req for (%lu, %lu, %lu, %s) from %s : ",
versnum == PMAPVERS ? "pmap_rmtcall" :
versnum == RPCBVERS ? "rpcb_rmtcall" :
versnum == RPCBVERS4 ? "rpcb_indirect" : unknown,
versnum == RPCBVERS4 ? "rpcb_indirect" :
rpcbind_unknown,
reply_type == RPCBPROC_INDIRECT ? "indirect" : "callit",
(unsigned long)a.rmt_prog, (unsigned long)a.rmt_vers,
(unsigned long)a.rmt_proc, transp->xp_netid,
uaddr ? uaddr : unknown);
uaddr ? uaddr : rpcbind_unknown);
if (uaddr)
free((void *) uaddr);
}
@ -1268,7 +1269,7 @@ handle_reply(int fd, SVCXPRT *xprt)
svc_getrpccaller(xprt));
if (debugging) {
fprintf(stderr, "handle_reply: forwarding address %s to %s\n",
a.rmt_uaddr, uaddr ? uaddr : unknown);
a.rmt_uaddr, uaddr ? uaddr : rpcbind_unknown);
}
if (uaddr)
free((void *) uaddr);
@ -1355,9 +1356,9 @@ getowner(SVCXPRT *transp, char *owner, size_t ownersize)
sc = __svc_getcallercreds(transp);
if (sc == NULL)
strlcpy(owner, unknown, ownersize);
strlcpy(owner, rpcbind_unknown, ownersize);
else if (sc->sc_uid == 0)
strlcpy(owner, superuser, ownersize);
strlcpy(owner, rpcbind_superuser, ownersize);
else
snprintf(owner, ownersize, "%d", sc->sc_uid);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpcbind.c,v 1.12 2007/05/13 21:19:56 christos Exp $ */
/* $NetBSD: rpcbind.c,v 1.13 2007/05/16 14:42:08 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -99,8 +99,8 @@ const char *tcp_uaddr; /* Universal TCP address */
#endif
static const char servname[] = "sunrpc";
const char superuser[] = "superuser";
const char unknown[] = "unknown";
const char rpcbind_superuser[] = "superuser";
const char rpcbind_unknown[] = "unknown";
static int init_transport(struct netconfig *);
static void rbllist_add(rpcprog_t, rpcvers_t, struct netconfig *,
@ -501,7 +501,7 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
rbl->rpcb_map.r_vers = vers;
rbl->rpcb_map.r_netid = strdup(nconf->nc_netid);
rbl->rpcb_map.r_addr = taddr2uaddr(nconf, addr);
rbl->rpcb_map.r_owner = strdup(superuser);
rbl->rpcb_map.r_owner = strdup(rpcbind_superuser);
rbl->rpcb_next = list_rbl; /* Attach to global list */
list_rbl = rbl;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpcbind.h,v 1.2 2007/05/13 20:03:47 christos Exp $ */
/* $NetBSD: rpcbind.h,v 1.3 2007/05/16 14:42:08 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -79,8 +79,8 @@ extern const char *udp_uaddr; /* Universal UDP address */
extern const char *tcp_uaddr; /* Universal TCP address */
#endif
extern const char superuser[];
extern const char unknown[];
extern const char rpcbind_superuser[];
extern const char rpcbind_unknown[];
int add_bndlist(struct netconfig *, struct netbuf *);
bool_t is_bound(const char *, const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: security.c,v 1.9 2007/05/13 20:03:47 christos Exp $ */
/* $NetBSD: security.c,v 1.10 2007/05/16 14:42:08 christos Exp $ */
#include <sys/types.h>
#include <sys/time.h>
@ -29,9 +29,7 @@
#include "rpcbind.h"
#ifdef LIBWRAP
# define unknown __unknown
# include <tcpd.h>
# undef unknown
#ifndef LIBWRAP_ALLOW_FACILITY
# define LIBWRAP_ALLOW_FACILITY LOG_AUTH
#endif