rpcbind: Code cleanup

Fix a number of style issues and attempt to reduce the diff to NetBSD.

Reviewed by:	glebius, kib
Differential Revision:	https://reviews.freebsd.org/D51773
This commit is contained in:
Dag-Erling Smørgrav 2025-08-07 03:23:19 +02:00
parent 650bcf5b6b
commit 7378290edb
9 changed files with 471 additions and 456 deletions

View file

@ -42,13 +42,16 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <rpc/rpc.h>
#include <rpc/svc_dg.h>
#include <netconfig.h>
#include <syslog.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "rpcbind.h"
@ -61,9 +64,9 @@ struct fdlist {
static struct fdlist *fdhead; /* Link list of the check fd's */
static struct fdlist *fdtail;
static char *nullstring = "";
static char nullstring[] = "";
static bool_t check_bound(struct fdlist *, char *uaddr);
static bool_t check_bound(struct fdlist *, const char *uaddr);
/*
* Returns 1 if the given address is bound for the given addr & transport
@ -71,7 +74,7 @@ static bool_t check_bound(struct fdlist *, char *uaddr);
* Returns 0 for success.
*/
static bool_t
check_bound(struct fdlist *fdl, char *uaddr)
check_bound(struct fdlist *fdl, const char *uaddr)
{
int fd;
struct netbuf *na;
@ -101,7 +104,7 @@ check_bound(struct fdlist *fdl, char *uaddr)
}
int
add_bndlist(struct netconfig *nconf, struct netbuf *baddr __unused)
add_bndlist(const struct netconfig *nconf, struct netbuf *baddr __unused)
{
struct fdlist *fdl;
struct netconfig *newnconf;
@ -109,7 +112,7 @@ add_bndlist(struct netconfig *nconf, struct netbuf *baddr __unused)
newnconf = getnetconfigent(nconf->nc_netid);
if (newnconf == NULL)
return (-1);
fdl = malloc(sizeof (struct fdlist));
fdl = malloc(sizeof(*fdl));
if (fdl == NULL) {
freenetconfigent(newnconf);
syslog(LOG_ERR, "no memory!");
@ -131,7 +134,7 @@ add_bndlist(struct netconfig *nconf, struct netbuf *baddr __unused)
}
bool_t
is_bound(char *netid, char *uaddr)
is_bound(const char *netid, const char *uaddr)
{
struct fdlist *fdl;
@ -189,7 +192,7 @@ mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr)
return (NULL);
}
#ifdef ND_DEBUG
#ifdef RPCBIND_DEBUG
if (debugging) {
if (saddr == NULL) {
fprintf(stderr, "mergeaddr: client uaddr = %s\n",
@ -205,7 +208,7 @@ mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr)
* This is all we should need for IP 4 and 6
*/
m_uaddr = addrmerge(svc_getrpccaller(xprt), s_uaddr, c_uaddr, netid);
#ifdef ND_DEBUG
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "mergeaddr: uaddr = %s, merged uaddr = %s\n",
uaddr, m_uaddr);

View file

@ -35,7 +35,7 @@
/*
* pmap_svc.c
* The server procedure for the version 2 portmaper.
* The server procedure for the version 2 portmapper.
* All the portmapper related interface from the portmap side.
*/
@ -47,12 +47,12 @@
#include <rpc/pmap_prot.h>
#include <rpc/rpcb_prot.h>
#ifdef RPCBIND_DEBUG
#include <stdio.h>
#include <stdlib.h>
#endif
#include "rpcbind.h"
static struct pmaplist *find_service_pmap(rpcprog_t, rpcvers_t,
rpcprot_t);
static struct pmaplist *find_service_pmap(rpcprog_t, rpcvers_t, rpcprot_t);
static bool_t pmapproc_change(struct svc_req *, SVCXPRT *, u_long);
static bool_t pmapproc_getport(struct svc_req *, SVCXPRT *);
static bool_t pmapproc_dump(struct svc_req *, SVCXPRT *);
@ -168,6 +168,11 @@ pmapproc_change(struct svc_req *rqstp __unused, SVCXPRT *xprt, unsigned long op)
uid_t uid;
char uidbuf[32];
if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
svcerr_decode(xprt);
return (FALSE);
}
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "%s request for (%lu, %lu) : ",
@ -175,11 +180,6 @@ pmapproc_change(struct svc_req *rqstp __unused, SVCXPRT *xprt, unsigned long op)
reg.pm_prog, reg.pm_vers);
#endif
if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
svcerr_decode(xprt);
return (FALSE);
}
if (!check_access(xprt, op, &reg, PMAPVERS)) {
svcerr_weakauth(xprt);
return FALSE;
@ -192,12 +192,12 @@ pmapproc_change(struct svc_req *rqstp __unused, SVCXPRT *xprt, unsigned long op)
* and looping.
*/
if (__rpc_get_local_uid(xprt, &uid) < 0)
rpcbreg.r_owner = "unknown";
rpcbreg.r_owner = __UNCONST(rpcbind_unknown);
else if (uid == 0)
rpcbreg.r_owner = "superuser";
rpcbreg.r_owner = __UNCONST(rpcbind_superuser);
else {
/* r_owner will be strdup-ed later */
snprintf(uidbuf, sizeof uidbuf, "%d", uid);
snprintf(uidbuf, sizeof(uidbuf), "%d", uid);
rpcbreg.r_owner = uidbuf;
}
@ -207,14 +207,14 @@ pmapproc_change(struct svc_req *rqstp __unused, SVCXPRT *xprt, unsigned long op)
if (op == PMAPPROC_SET) {
char buf[32];
snprintf(buf, sizeof buf, "0.0.0.0.%d.%d",
snprintf(buf, sizeof(buf), "0.0.0.0.%d.%d",
(int)((reg.pm_port >> 8) & 0xff),
(int)(reg.pm_port & 0xff));
rpcbreg.r_addr = buf;
if (reg.pm_prot == IPPROTO_UDP) {
rpcbreg.r_netid = udptrans;
rpcbreg.r_netid = __UNCONST(udptrans);
} else if (reg.pm_prot == IPPROTO_TCP) {
rpcbreg.r_netid = tcptrans;
rpcbreg.r_netid = __UNCONST(tcptrans);
} else {
ans = FALSE;
goto done_change;
@ -224,9 +224,9 @@ pmapproc_change(struct svc_req *rqstp __unused, SVCXPRT *xprt, unsigned long op)
bool_t ans1, ans2;
rpcbreg.r_addr = NULL;
rpcbreg.r_netid = tcptrans;
rpcbreg.r_netid = __UNCONST(tcptrans);
ans1 = map_unset(&rpcbreg, rpcbreg.r_owner);
rpcbreg.r_netid = udptrans;
rpcbreg.r_netid = __UNCONST(udptrans);
ans2 = map_unset(&rpcbreg, rpcbreg.r_owner);
ans = ans1 || ans2;
} else {
@ -285,9 +285,9 @@ pmapproc_getport(struct svc_req *rqstp __unused, SVCXPRT *xprt)
#endif
fnd = find_service_pmap(reg.pm_prog, reg.pm_vers, reg.pm_prot);
if (fnd) {
char serveuaddr[32], *ua;
char serveuaddr[32];
int h1, h2, h3, h4, p1, p2;
char *netid;
const char *netid, *ua;
if (reg.pm_prot == IPPROTO_UDP) {
ua = udp_uaddr;
@ -303,7 +303,7 @@ pmapproc_getport(struct svc_req *rqstp __unused, SVCXPRT *xprt)
&h4, &p1, &p2) == 6) {
p1 = (fnd->pml_map.pm_port >> 8) & 0xff;
p2 = (fnd->pml_map.pm_port) & 0xff;
snprintf(serveuaddr, sizeof serveuaddr,
snprintf(serveuaddr, sizeof(serveuaddr),
"%d.%d.%d.%d.%d.%d", h1, h2, h3, h4, p1, p2);
if (is_bound(netid, serveuaddr)) {
port = fnd->pml_map.pm_port;

View file

@ -37,15 +37,18 @@
* Copyright (c) 1990 by Sun Microsystems, Inc.
*/
#include <netconfig.h>
#include <sys/stat.h>
#include <rpc/rpc.h>
#include <rpc/rpcb_prot.h>
#include <sys/stat.h>
#ifdef PORTMAP
#include <rpc/pmap_prot.h>
#endif
#include <netconfig.h>
#include <stdlib.h>
#include <string.h>
#include "rpcbind.h"
static rpcb_stat_byvers inf;
@ -96,8 +99,8 @@ rpcbs_unset(rpcvers_t rtype, bool_t success)
}
void
rpcbs_getaddr(rpcvers_t rtype, rpcprog_t prog, rpcvers_t vers, char *netid,
char *uaddr)
rpcbs_getaddr(rpcvers_t rtype, rpcprog_t prog, rpcvers_t vers,
const char *netid, const char *uaddr)
{
rpcbs_addrlist *al;
struct netconfig *nconf;
@ -121,7 +124,7 @@ rpcbs_getaddr(rpcvers_t rtype, rpcprog_t prog, rpcvers_t vers, char *netid,
if (nconf == NULL) {
return;
}
al = (rpcbs_addrlist *) malloc(sizeof (rpcbs_addrlist));
al = malloc(sizeof(*al));
if (al == NULL) {
return;
}
@ -170,7 +173,7 @@ rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t rpcbproc, rpcprog_t prog,
if (nconf == NULL) {
return;
}
rl = (rpcbs_rmtcalllist *) malloc(sizeof (rpcbs_rmtcalllist));
rl = malloc(sizeof(*rl));
if (rl == NULL) {
return;
}

View file

@ -46,6 +46,7 @@
#include <netconfig.h>
#include <stdio.h>
#ifdef RPCBIND_DEBUG
#include <stdio.h>
#include <stdlib.h>
#endif
#include <string.h>
@ -53,9 +54,9 @@
#include "rpcbind.h"
static void *rpcbproc_getaddr_3_local(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
rpcvers_t);
static void *rpcbproc_dump_3_local(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
rpcvers_t);
/*
* Called by svc_getreqset. There is a separate server handle for
@ -89,7 +90,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
#endif
/* This call just logs, no actual checks */
check_access(transp, rqstp->rq_proc, NULL, RPCBVERS);
(void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
(void) svc_sendreply(transp, (xdrproc_t)xdr_void, NULL);
return;
case RPCBPROC_SET:
@ -204,7 +205,7 @@ done:
/* ARGSUSED */
static void *
rpcbproc_getaddr_3_local(void *arg, struct svc_req *rqstp __unused,
SVCXPRT *transp __unused, rpcvers_t versnum __unused)
SVCXPRT *transp __unused, rpcvers_t versnum __unused)
{
RPCB *regp = (RPCB *)arg;
#ifdef RPCBIND_DEBUG
@ -212,7 +213,7 @@ rpcbproc_getaddr_3_local(void *arg, struct svc_req *rqstp __unused,
char *uaddr;
uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid),
svc_getrpccaller(transp));
svc_getrpccaller(transp));
fprintf(stderr, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
regp->r_netid, uaddr);
@ -226,7 +227,7 @@ rpcbproc_getaddr_3_local(void *arg, struct svc_req *rqstp __unused,
/* ARGSUSED */
static void *
rpcbproc_dump_3_local(void *arg __unused, struct svc_req *rqstp __unused,
SVCXPRT *transp __unused, rpcvers_t versnum __unused)
SVCXPRT *transp __unused, rpcvers_t versnum __unused)
{
return ((void *)&list_rbl);
}

View file

@ -51,12 +51,14 @@
#include "rpcbind.h"
static void *rpcbproc_getaddr_4_local(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
static void *rpcbproc_getversaddr_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
static void *rpcbproc_getaddrlist_4_local
(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
rpcvers_t);
static void *rpcbproc_getversaddr_4_local(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
static void *rpcbproc_getaddrlist_4_local(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
static void free_rpcb_entry_list(rpcb_entry_list_ptr *);
static void *rpcbproc_dump_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
static void *rpcbproc_dump_4_local(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
/*
* Called by svc_getreqset. There is a separate server handle for
@ -88,8 +90,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
fprintf(stderr, "RPCBPROC_NULL\n");
#endif
check_access(transp, rqstp->rq_proc, NULL, RPCBVERS4);
(void) svc_sendreply(transp, (xdrproc_t) xdr_void,
(char *)NULL);
(void) svc_sendreply(transp, (xdrproc_t) xdr_void, NULL);
return;
case RPCBPROC_SET:
@ -257,7 +258,7 @@ done:
/* ARGSUSED */
static void *
rpcbproc_getaddr_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp,
rpcvers_t rpcbversnum __unused)
rpcvers_t rpcbversnum __unused)
{
RPCB *regp = (RPCB *)arg;
#ifdef RPCBIND_DEBUG
@ -315,7 +316,7 @@ rpcbproc_getversaddr_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp,
/* ARGSUSED */
static void *
rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp __unused,
SVCXPRT *transp, rpcvers_t versnum __unused)
SVCXPRT *transp, rpcvers_t versnum __unused)
{
RPCB *regp = (RPCB *)arg;
static rpcb_entry_list_ptr rlist;
@ -384,7 +385,7 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp __unused,
/*
* Add it to rlist.
*/
rp = malloc(sizeof (rpcb_entry_list));
rp = malloc(sizeof(*rp));
if (rp == NULL)
goto fail;
a = &rp->rpcb_entry_map;
@ -397,7 +398,7 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp __unused,
if (rlist == NULL) {
rlist = rp;
tail = rp;
} else {
} else if (tail != NULL) {
tail->rpcb_entry_next = rp;
tail = rp;
}
@ -417,9 +418,10 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp __unused,
* Perhaps wrong, but better than it not getting counted at all.
*/
rpcbs_getaddr(RPCBVERS4 - 2, prog, vers, transp->xp_netid, maddr);
return (void *)&rlist;
return (&rlist);
fail: free_rpcb_entry_list(&rlist);
fail:
free_rpcb_entry_list(&rlist);
return (NULL);
}
@ -444,7 +446,7 @@ free_rpcb_entry_list(rpcb_entry_list_ptr *rlistp)
/* ARGSUSED */
static void *
rpcbproc_dump_4_local(void *arg __unused, struct svc_req *req __unused,
SVCXPRT *xprt __unused, rpcvers_t versnum __unused)
SVCXPRT *xprt __unused, rpcvers_t versnum __unused)
{
return ((void *)&list_rbl);
}

View file

@ -110,7 +110,7 @@ static int check_rmtcalls(struct pollfd *, int);
static void xprt_set_caller(SVCXPRT *, struct finfo *);
static void send_svcsyserr(SVCXPRT *, struct finfo *);
static void handle_reply(int, SVCXPRT *);
static void find_versions(rpcprog_t, char *, rpcvers_t *, rpcvers_t *);
static void find_versions(rpcprog_t, const char *, rpcvers_t *, rpcvers_t *);
static rpcblist_ptr find_service(rpcprog_t, rpcvers_t, char *);
static char *getowner(SVCXPRT *, char *, size_t);
static int add_pmaplist(RPCB *);
@ -122,17 +122,17 @@ static int del_pmaplist(RPCB *);
/* ARGSUSED */
void *
rpcbproc_set_com(void *arg, struct svc_req *rqstp __unused, SVCXPRT *transp,
rpcvers_t rpcbversnum)
rpcvers_t rpcbversnum)
{
RPCB *regp = (RPCB *)arg;
RPCB *regp = arg;
static bool_t ans;
char owner[64];
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "RPCB_SET request for (%lu, %lu, %s, %s) : ",
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
regp->r_netid, regp->r_addr);
fprintf(stderr, "%s: RPCB_SET request for (%lu, %lu, %s, %s): ",
__func__, (unsigned long)regp->r_prog,
(unsigned long)regp->r_vers, regp->r_netid, regp->r_addr);
#endif
ans = map_set(regp, getowner(transp, owner, sizeof owner));
#ifdef RPCBIND_DEBUG
@ -145,7 +145,7 @@ rpcbproc_set_com(void *arg, struct svc_req *rqstp __unused, SVCXPRT *transp,
}
bool_t
map_set(RPCB *regp, char *owner)
map_set(RPCB *regp, const char *owner)
{
RPCB reg, *a;
rpcblist_ptr rbl, fnd;
@ -170,7 +170,7 @@ map_set(RPCB *regp, char *owner)
/*
* add to the end of the list
*/
rbl = malloc(sizeof (RPCBLIST));
rbl = malloc(sizeof(*rbl));
if (rbl == NULL)
return (FALSE);
a = &(rbl->rpcb_map);
@ -186,7 +186,7 @@ map_set(RPCB *regp, char *owner)
free(rbl);
return (FALSE);
}
rbl->rpcb_next = (rpcblist_ptr)NULL;
rbl->rpcb_next = NULL;
if (list_rbl == NULL) {
list_rbl = rbl;
} else {
@ -196,7 +196,7 @@ map_set(RPCB *regp, char *owner)
fnd->rpcb_next = rbl;
}
#ifdef PORTMAP
(void) add_pmaplist(regp);
(void)add_pmaplist(regp);
#endif
return (TRUE);
}
@ -207,17 +207,17 @@ map_set(RPCB *regp, char *owner)
/* ARGSUSED */
void *
rpcbproc_unset_com(void *arg, struct svc_req *rqstp __unused, SVCXPRT *transp,
rpcvers_t rpcbversnum)
rpcvers_t rpcbversnum)
{
RPCB *regp = (RPCB *)arg;
RPCB *regp = arg;
static bool_t ans;
char owner[64];
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "RPCB_UNSET request for (%lu, %lu, %s) : ",
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
regp->r_netid);
fprintf(stderr, "%s: RPCB_UNSET request for (%lu, %lu, %s): ",
__func__, (unsigned long)regp->r_prog,
(unsigned long)regp->r_vers, regp->r_netid);
#endif
ans = map_unset(regp, getowner(transp, owner, sizeof owner));
#ifdef RPCBIND_DEBUG
@ -230,7 +230,7 @@ rpcbproc_unset_com(void *arg, struct svc_req *rqstp __unused, SVCXPRT *transp,
}
bool_t
map_unset(RPCB *regp, char *owner)
map_unset(RPCB *regp, const char *owner)
{
int ans = 0;
rpcblist_ptr rbl, prev, tmp;
@ -252,7 +252,7 @@ map_unset(RPCB *regp, 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 */
@ -270,21 +270,21 @@ map_unset(RPCB *regp, char *owner)
}
#ifdef PORTMAP
if (ans)
(void) del_pmaplist(regp);
(void)del_pmaplist(regp);
#endif
/*
* We return 1 either when the entry was not there or it
* was able to unset it. It can come to this point only if
* atleast one of the conditions is true.
* at least one of the conditions is true.
*/
return (1);
}
void
delete_prog(unsigned int prog)
delete_prog(rpcprog_t prog)
{
RPCB reg;
register rpcblist_ptr rbl;
rpcblist_ptr rbl;
for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) {
if ((rbl->rpcb_map.r_prog != prog))
@ -294,14 +294,18 @@ delete_prog(unsigned 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");
free(reg.r_netid);
if (reg.r_netid == NULL)
syslog(LOG_ERR, "%s: %m", __func__);
else {
(void)map_unset(&reg, rpcbind_superuser);
free(reg.r_netid);
}
}
}
void *
rpcbproc_getaddr_com(RPCB *regp, struct svc_req *rqstp __unused,
SVCXPRT *transp, rpcvers_t rpcbversnum, rpcvers_t verstype)
SVCXPRT *transp, rpcvers_t rpcbversnum, rpcvers_t verstype)
{
static char *uaddr;
char *saddr = NULL;
@ -333,23 +337,23 @@ rpcbproc_getaddr_com(RPCB *regp, struct svc_req *rqstp __unused,
}
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "getaddr: %s\n", uaddr);
fprintf(stderr, "%s: %s\n", __func__, uaddr);
#endif
/* XXX: should have used some defined constant here */
rpcbs_getaddr(rpcbversnum - 2, regp->r_prog, regp->r_vers,
transp->xp_netid, uaddr);
return (void *)&uaddr;
return (&uaddr);
}
/* ARGSUSED */
void *
rpcbproc_gettime_com(void *arg __unused, struct svc_req *rqstp __unused,
SVCXPRT *transp __unused, rpcvers_t rpcbversnum __unused)
SVCXPRT *transp __unused, rpcvers_t rpcbversnum __unused)
{
static time_t curtime;
(void) time(&curtime);
return (void *)&curtime;
(void)time(&curtime);
return (&curtime);
}
/*
@ -359,9 +363,9 @@ rpcbproc_gettime_com(void *arg __unused, struct svc_req *rqstp __unused,
/* ARGSUSED */
void *
rpcbproc_uaddr2taddr_com(void *arg, struct svc_req *rqstp __unused,
SVCXPRT *transp, rpcvers_t rpcbversnum __unused)
SVCXPRT *transp, rpcvers_t rpcbversnum __unused)
{
char **uaddrp = (char **)arg;
char **uaddrp = arg;
struct netconfig *nconf;
static struct netbuf nbuf;
static struct netbuf *taddr;
@ -370,10 +374,10 @@ rpcbproc_uaddr2taddr_com(void *arg, struct svc_req *rqstp __unused,
taddr = NULL;
if (((nconf = rpcbind_get_conf(transp->xp_netid)) == NULL) ||
((taddr = uaddr2taddr(nconf, *uaddrp)) == NULL)) {
(void) memset((char *)&nbuf, 0, sizeof (struct netbuf));
return (void *)&nbuf;
memset(&nbuf, 0, sizeof(nbuf));
return (&nbuf);
}
return (void *)taddr;
return (taddr);
}
/*
@ -383,9 +387,9 @@ rpcbproc_uaddr2taddr_com(void *arg, struct svc_req *rqstp __unused,
/* ARGSUSED */
void *
rpcbproc_taddr2uaddr_com(void *arg, struct svc_req *rqstp __unused,
SVCXPRT *transp, rpcvers_t rpcbversnum __unused)
SVCXPRT *transp, rpcvers_t rpcbversnum __unused)
{
struct netbuf *taddr = (struct netbuf *)arg;
struct netbuf *taddr = arg;
static char *uaddr;
struct netconfig *nconf;
@ -393,7 +397,7 @@ rpcbproc_taddr2uaddr_com(void *arg, struct svc_req *rqstp __unused,
int fd;
if ((fd = open("/dev/null", O_RDONLY)) == -1) {
uaddr = (char *)strerror(errno);
uaddr = strerror(errno);
return (&uaddr);
}
#endif /* CHEW_FDS */
@ -480,7 +484,7 @@ static struct rmtcallfd_list *rmthead;
static struct rmtcallfd_list *rmttail;
int
create_rmtcall_fd(struct netconfig *nconf)
create_rmtcall_fd(const struct netconfig *nconf)
{
int fd;
struct rmtcallfd_list *rmt;
@ -488,21 +492,20 @@ create_rmtcall_fd(struct netconfig *nconf)
if ((fd = __rpc_nconf2fd(nconf)) == -1) {
if (debugging)
fprintf(stderr,
"create_rmtcall_fd: couldn't open \"%s\" (errno %d)\n",
nconf->nc_device, errno);
fprintf(stderr, "%s: couldn't open \"%s\": %m\n",
__func__, nconf->nc_device);
return (-1);
}
xprt = svc_tli_create(fd, 0, (struct t_bind *) 0, 0, 0);
xprt = svc_tli_create(fd, 0, NULL, 0, 0);
if (xprt == NULL) {
if (debugging)
fprintf(stderr,
"create_rmtcall_fd: svc_tli_create failed\n");
fprintf(stderr, "%s: svc_tli_create failed\n",
__func__);
return (-1);
}
rmt = malloc(sizeof (struct rmtcallfd_list));
rmt = malloc(sizeof(*rmt));
if (rmt == NULL) {
syslog(LOG_ERR, "create_rmtcall_fd: no memory!");
syslog(LOG_ERR, "%s: %m", __func__);
return (-1);
}
rmt->xprt = xprt;
@ -591,16 +594,16 @@ find_rmtcallxprt_by_fd(int fd)
void
rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
rpcproc_t reply_type, rpcvers_t versnum)
rpcproc_t reply_type, rpcvers_t versnum)
{
register rpcblist_ptr rbl;
rpcblist_ptr rbl;
struct netconfig *nconf;
struct netbuf *caller;
struct r_rmtcall_args a;
char *buf_alloc = NULL, *outbufp;
char *outbuf_alloc = NULL;
char buf[RPC_BUF_MAX], outbuf[RPC_BUF_MAX];
struct netbuf *na = (struct netbuf *) NULL;
struct netbuf *na = NULL;
struct rpc_msg call_msg;
int outlen;
u_int sendsz;
@ -638,8 +641,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
#endif /* notyet */
if (buf_alloc == NULL) {
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: No Memory!\n");
fprintf(stderr, "%s: %m\n", __func__);
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
return;
@ -650,12 +652,11 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
}
call_msg.rm_xid = 0; /* For error checking purposes */
if (!svc_getargs(transp, (xdrproc_t) xdr_rmtcall_args, (char *) &a)) {
if (!svc_getargs(transp, (xdrproc_t)xdr_rmtcall_args, (char *) &a)) {
if (reply_type == RPCBPROC_INDIRECT)
svcerr_decode(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: svc_getargs failed\n");
fprintf(stderr, "%s: svc_getargs failed\n", __func__);
goto error;
}
@ -668,14 +669,15 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
#ifdef RPCBIND_DEBUG
if (debugging) {
uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), caller);
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",
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");
fprintf(stderr,
"%s: %s %s req for (%lu, %lu, %lu, %s) from %s: ",
__func__, versnum == PMAPVERS ? "pmap_rmtcall" :
versnum == RPCBVERS ? "rpcb_rmtcall" :
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 : rpcbind_unknown);
free(uaddr);
}
#endif
@ -685,7 +687,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
rpcbs_rmtcall(versnum - 2, reply_type, a.rmt_prog, a.rmt_vers,
a.rmt_proc, transp->xp_netid, rbl);
if (rbl == (rpcblist_ptr)NULL) {
if (rbl == NULL) {
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "not found\n");
@ -726,19 +728,18 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
free(uaddr);
}
nconf = rpcbind_get_conf(transp->xp_netid);
if (nconf == (struct netconfig *)NULL) {
if (nconf == NULL) {
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: rpcbind_get_conf failed\n");
fprintf(stderr, "%s: rpcbind_get_conf failed\n",
__func__);
goto error;
}
localsa = local_sa(((struct sockaddr *)caller->buf)->sa_family);
if (localsa == NULL) {
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: no local address\n");
fprintf(stderr, "%s: no local address\n", __func__);
goto error;
}
tbuf.len = tbuf.maxlen = localsa->sa_len;
@ -749,7 +750,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
nconf->nc_netid);
#ifdef RPCBIND_DEBUG
if (debugging)
fprintf(stderr, "merged uaddr %s\n", m_uaddr);
fprintf(stderr, "%s: merged uaddr %s\n", __func__, m_uaddr);
#endif
if ((fd = find_rmtcallfd_by_netid(nconf->nc_netid)) == -1) {
if (reply_type == RPCBPROC_INDIRECT)
@ -769,22 +770,20 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
* beat on it any more.
*/
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: duplicate request\n");
fprintf(stderr, "%s: duplicate request\n", __func__);
goto error;
case -1:
/* forward_register failed. Perhaps no memory. */
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: forward_register failed\n");
fprintf(stderr, "%s: forward_register failed\n",
__func__);
goto error;
}
#ifdef DEBUG_RMTCALL
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: original XID %x, new XID %x\n",
*xidp, call_msg.rm_xid);
fprintf(stderr, "%s: original XID %x, new XID %x\n", __func__,
*xidp, call_msg.rm_xid);
#endif
call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
@ -797,11 +796,10 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
outbuf_alloc = malloc(sendsz);
#endif /* notyet */
if (outbuf_alloc == NULL) {
if (debugging)
fprintf(stderr, "%s: %m\n", __func__);
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: No memory!\n");
goto error;
}
xdrmem_create(&outxdr, outbuf_alloc, sendsz, XDR_ENCODE);
@ -812,16 +810,14 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: xdr_callhdr failed\n");
fprintf(stderr, "%s: xdr_callhdr failed\n", __func__);
goto error;
}
if (!xdr_u_int32_t(&outxdr, &(a.rmt_proc))) {
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: xdr_u_long failed\n");
fprintf(stderr, "%s: xdr_u_long failed\n", __func__);
goto error;
}
@ -839,8 +835,8 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
} else {
/* we do not support any other authentication scheme */
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: oa_flavor != AUTH_NONE and oa_flavor != AUTH_SYS\n");
fprintf(stderr, "%s: oa_flavor != AUTH_NONE and "
"oa_flavor != AUTH_SYS\n", __func__);
if (reply_type == RPCBPROC_INDIRECT)
svcerr_weakauth(transp); /* XXX too strong.. */
goto error;
@ -850,7 +846,8 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
svcerr_systemerr(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: authwhatever_create returned NULL\n");
"%s: authwhatever_create returned NULL\n",
__func__);
goto error;
}
if (!AUTH_MARSHALL(auth, &outxdr)) {
@ -858,8 +855,8 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
svcerr_systemerr(transp);
AUTH_DESTROY(auth);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: AUTH_MARSHALL failed\n");
fprintf(stderr, "%s: AUTH_MARSHALL failed\n",
__func__);
goto error;
}
AUTH_DESTROY(auth);
@ -867,8 +864,8 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: xdr_opaque_parms failed\n");
fprintf(stderr, "%s: xdr_opaque_parms failed\n",
__func__);
goto error;
}
outlen = (int) XDR_GETPOS(&outxdr);
@ -887,8 +884,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
if (sendto(fd, outbufp, outlen, 0, (struct sockaddr *)na->buf, na->len)
!= outlen) {
if (debugging)
fprintf(stderr,
"rpcbproc_callit_com: sendto failed: errno %d\n", errno);
fprintf(stderr, "%s: sendto failed: %m\n", __func__);
if (reply_type == RPCBPROC_INDIRECT)
svcerr_systemerr(transp);
goto error;
@ -897,7 +893,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
error:
if (call_msg.rm_xid != 0)
(void) free_slot_by_xid(call_msg.rm_xid);
(void)free_slot_by_xid(call_msg.rm_xid);
out:
free(local_uaddr);
free(buf_alloc);
@ -913,14 +909,12 @@ out:
*/
static int
forward_register(u_int32_t caller_xid, struct netbuf *caller_addr,
int forward_fd, char *uaddr, rpcproc_t reply_type,
rpcvers_t versnum, u_int32_t *callxidp)
int forward_fd, char *uaddr, rpcproc_t reply_type,
rpcvers_t versnum, u_int32_t *callxidp)
{
int i;
int j = 0;
time_t min_time, time_now;
static u_int32_t lastxid;
int entry = -1;
static u_int32_t lastxid;
time_t min_time, time_now;
int i, j = 0, entry = -1;
min_time = FINFO[0].time;
time_now = time((time_t *)0);
@ -945,7 +939,7 @@ forward_register(u_int32_t caller_xid, struct netbuf *caller_addr,
} else {
/* Should we wait any longer */
if ((time_now - FINFO[i].time) > MAXTIME_OFF)
(void) free_slot_by_index(i);
(void)free_slot_by_index(i);
}
}
if (entry == -1) {
@ -961,7 +955,7 @@ forward_register(u_int32_t caller_xid, struct netbuf *caller_addr,
/* use this empty slot */
j = entry;
} else {
(void) free_slot_by_index(j);
(void)free_slot_by_index(j);
}
if ((FINFO[j].caller_addr = netbufdup(caller_addr)) == NULL) {
return (-1);
@ -990,7 +984,7 @@ forward_register(u_int32_t caller_xid, struct netbuf *caller_addr,
static struct finfo *
forward_find(u_int32_t reply_xid)
{
int i;
int i;
i = reply_xid % (u_int32_t)NFORWARD;
if ((FINFO[i].flag & FINFO_ACTIVE) &&
@ -1012,7 +1006,7 @@ free_slot_by_xid(u_int32_t xid)
static int
free_slot_by_index(int index)
{
struct finfo *fi;
struct finfo *fi;
fi = &FINFO[index];
if (fi->flag & FINFO_ACTIVE) {
@ -1084,15 +1078,14 @@ extern bool_t __svc_clean_idle(fd_set *, int, bool_t);
void
my_svc_run(void)
{
size_t nfds;
struct pollfd pollfds[FD_SETSIZE + 1];
int poll_ret, check_ret;
int n;
#ifdef SVC_RUN_DEBUG
int i;
#endif
register struct pollfd *p;
fd_set cleanfds;
struct pollfd *p;
size_t nfds;
#ifdef SVC_RUN_DEBUG
size_t i;
#endif
int n, poll_ret, check_ret;
for (;;) {
p = pollfds;
@ -1110,7 +1103,8 @@ my_svc_run(void)
poll_ret = 0;
#ifdef SVC_RUN_DEBUG
if (debugging) {
fprintf(stderr, "polling for read on fd < ");
fprintf(stderr, "%s: polling for read on fd < ",
__func__);
for (i = 0, p = pollfds; i < nfds; i++, p++)
if (p->events)
fprintf(stderr, "%d ", p->fd);
@ -1137,6 +1131,13 @@ my_svc_run(void)
* that it was set by the signal handlers (or any
* other outside event) and not caused by poll().
*/
#ifdef SVC_RUN_DEBUG
if (debugging) {
fprintf(stderr, "%s: poll returned %d: %m\n",
__func__, poll_ret);
}
#endif
/* FALLTHROUGH */
case 0:
cleanfds = svc_fdset;
__svc_clean_idle(&cleanfds, 30, FALSE);
@ -1144,10 +1145,12 @@ my_svc_run(void)
default:
#ifdef SVC_RUN_DEBUG
if (debugging) {
fprintf(stderr, "poll returned read fds < ");
fprintf(stderr, "%s: poll returned read fds < ",
__func__);
for (i = 0, p = pollfds; i < nfds; i++, p++)
if (p->revents)
fprintf(stderr, "%d ", p->fd);
fprintf(stderr, "%d (%#x)",
p->fd, p->revents);
fprintf(stderr, ">\n");
}
#endif
@ -1165,7 +1168,8 @@ my_svc_run(void)
}
#ifdef SVC_RUN_DEBUG
if (debugging) {
fprintf(stderr, "svc_maxfd now %u\n", svc_maxfd);
fprintf(stderr, "%s: svc_maxfd now %u\n", __func__,
svc_maxfd);
}
#endif
}
@ -1187,9 +1191,9 @@ check_rmtcalls(struct pollfd *pfds, int nfds)
ncallbacks_found++;
#ifdef DEBUG_RMTCALL
if (debugging)
fprintf(stderr,
"my_svc_run: polled on forwarding fd %d, netid %s - calling handle_reply\n",
pfds[j].fd, xprt->xp_netid);
fprintf(stderr, "%s: polled on forwarding "
"fd %d, netid %s - calling handle_reply\n",
__func__, pfds[j].fd, xprt->xp_netid);
#endif
handle_reply(pfds[j].fd, xprt);
pfds[j].revents = 0;
@ -1251,27 +1255,26 @@ handle_reply(int fd, SVCXPRT *xprt)
} while (inlen < 0 && errno == EINTR);
if (inlen < 0) {
if (debugging)
fprintf(stderr,
"handle_reply: recvfrom returned %d, errno %d\n", inlen, errno);
fprintf(stderr, "%s: recvfrom returned %d: %m\n",
__func__, inlen);
goto done;
}
reply_msg.acpted_rply.ar_verf = _null_auth;
reply_msg.acpted_rply.ar_results.where = 0;
reply_msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
xdrmem_create(&reply_xdrs, buffer, (u_int)inlen, XDR_DECODE);
if (!xdr_replymsg(&reply_xdrs, &reply_msg)) {
if (debugging)
(void) fprintf(stderr,
"handle_reply: xdr_replymsg failed\n");
fprintf(stderr, "%s: xdr_replymsg failed\n", __func__);
goto done;
}
fi = forward_find(reply_msg.rm_xid);
#ifdef SVC_RUN_DEBUG
if (debugging) {
fprintf(stderr, "handle_reply: reply xid: %d fi addr: %p\n",
reply_msg.rm_xid, fi);
fprintf(stderr, "%s: reply xid: %d fi addr: %p\n",
__func__, reply_msg.rm_xid, fi);
}
#endif
if (fi == NULL) {
@ -1280,8 +1283,8 @@ handle_reply(int fd, SVCXPRT *xprt)
_seterr_reply(&reply_msg, &reply_error);
if (reply_error.re_status != RPC_SUCCESS) {
if (debugging)
(void) fprintf(stderr, "handle_reply: %s\n",
clnt_sperrno(reply_error.re_status));
fprintf(stderr, "%s: %s\n", __func__,
clnt_sperrno(reply_error.re_status));
send_svcsyserr(xprt, fi);
goto done;
}
@ -1297,31 +1300,32 @@ handle_reply(int fd, SVCXPRT *xprt)
uaddr = taddr2uaddr(rpcbind_get_conf("udp"),
svc_getrpccaller(xprt));
if (debugging) {
fprintf(stderr, "handle_reply: forwarding address %s to %s\n",
a.rmt_uaddr, uaddr ? uaddr : "unknown");
fprintf(stderr, "%s: forwarding address %s to %s\n",
__func__, a.rmt_uaddr, uaddr ? uaddr : rpcbind_unknown);
}
free(uaddr);
#endif
svc_sendreply(xprt, (xdrproc_t) xdr_rmtcall_result, (char *) &a);
svc_sendreply(xprt, (xdrproc_t)xdr_rmtcall_result, &a);
done:
free(buffer);
if (reply_msg.rm_xid == 0) {
#ifdef SVC_RUN_DEBUG
if (debugging) {
fprintf(stderr, "handle_reply: NULL xid on exit!\n");
fprintf(stderr, "%s: NULL xid on exit!\n", __func__);
}
#endif
} else
(void) free_slot_by_xid(reply_msg.rm_xid);
(void)free_slot_by_xid(reply_msg.rm_xid);
}
static void
find_versions(rpcprog_t prog, char *netid, rpcvers_t *lowvp, rpcvers_t *highvp)
find_versions(rpcprog_t prog, const char *netid, rpcvers_t *lowvp,
rpcvers_t *highvp)
{
register rpcblist_ptr rbl;
unsigned int lowv = 0;
unsigned int highv = 0;
rpcblist_ptr rbl;
rpcvers_t lowv = 0;
rpcvers_t highv = 0;
for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) {
if ((rbl->rpcb_map.r_prog != prog) ||
@ -1355,8 +1359,8 @@ find_versions(rpcprog_t prog, char *netid, rpcvers_t *lowvp, rpcvers_t *highvp)
static rpcblist_ptr
find_service(rpcprog_t prog, rpcvers_t vers, char *netid)
{
register rpcblist_ptr hit = NULL;
register rpcblist_ptr rbl;
rpcblist_ptr hit = NULL;
rpcblist_ptr rbl;
for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) {
if ((rbl->rpcb_map.r_prog != prog) ||
@ -1380,9 +1384,9 @@ getowner(SVCXPRT *transp, char *owner, size_t ownersize)
uid_t uid;
if (__rpc_get_local_uid(transp, &uid) < 0)
strlcpy(owner, "unknown", ownersize);
strlcpy(owner, rpcbind_unknown, ownersize);
else if (uid == 0)
strlcpy(owner, "superuser", ownersize);
strlcpy(owner, rpcbind_superuser, ownersize);
else
snprintf(owner, ownersize, "%d", uid);
@ -1420,9 +1424,9 @@ add_pmaplist(RPCB *arg)
/*
* add to END of list
*/
pml = malloc(sizeof (struct pmaplist));
pml = malloc(sizeof(*pml));
if (pml == NULL) {
(void) syslog(LOG_ERR, "rpcbind: no memory!\n");
syslog(LOG_ERR, "%s: %m", __func__);
return (1);
}
pml->pml_map = pmap;
@ -1434,7 +1438,7 @@ add_pmaplist(RPCB *arg)
/* Attach to the end of the list */
for (fnd = list_pml; fnd->pml_next; fnd = fnd->pml_next)
;
continue;
fnd->pml_next = pml;
}
return (0);

View file

@ -111,36 +111,37 @@ static int terminate_wfd;
#ifdef WARMSTART
/* Local Variable */
static int warmstart = 0; /* Grab an old copy of registrations. */
static int warmstart = 0; /* Grab an old copy of registrations */
#endif
#ifdef PORTMAP
struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
char *udptrans; /* Name of UDP transport */
char *tcptrans; /* Name of TCP transport */
char *udp_uaddr; /* Universal UDP address */
char *tcp_uaddr; /* Universal TCP address */
const char *udptrans; /* Name of UDP transport */
const char *tcptrans; /* Name of TCP transport */
const char *udp_uaddr; /* Universal UDP address */
const char *tcp_uaddr; /* Universal TCP address */
#endif
static char servname[] = "rpcbind";
static char superuser[] = "superuser";
static char nlname[] = "netlink";
static const char servname[] = "rpcbind";
const char rpcbind_superuser[] = "superuser";
const char rpcbind_unknown[] = "unknown";
static const char nlname[] = "netlink";
static struct netconfig netlink_nconf = {
.nc_netid = nlname,
static const struct netconfig netlink_nconf = {
.nc_netid = __UNCONST(nlname),
.nc_semantics = NC_TPI_CLTS,
};
static struct t_bind netlink_taddr = {
static const struct t_bind netlink_taddr = {
.addr = {
.maxlen = sizeof(nlname),
.len = sizeof(nlname),
.buf = nlname,
.buf = __UNCONST(nlname),
},
};
static int init_transport(struct netconfig *);
static void rbllist_add(rpcprog_t, rpcvers_t, struct netconfig *,
struct netbuf *);
static int init_transport(const struct netconfig *);
static void rbllist_add(rpcprog_t, rpcvers_t, const struct netconfig *,
struct netbuf *);
static void cleanup_pidfile(void);
static void terminate(int);
static void parseargs(int, char *[]);
@ -192,7 +193,7 @@ main(int argc, char *argv[])
fprintf(stderr, "Sorry. You are not superuser\n");
exit(1);
}
nc_handle = setnetconfig(); /* open netconfig file */
nc_handle = setnetconfig(); /* open netconfig file */
if (nc_handle == NULL) {
syslog(LOG_ERR, "could not read /etc/netconfig");
exit(1);
@ -216,7 +217,7 @@ main(int argc, char *argv[])
while ((nconf = getnetconfig(nc_handle))) {
if (nconf->nc_flag & NC_VISIBLE) {
if (ipv6_only == 1 && strcmp(nconf->nc_protofmly,
if (ipv6_only == 1 && strcmp(nconf->nc_protofmly,
"inet") == 0) {
/* DO NOTHING */
} else
@ -296,7 +297,7 @@ main(int argc, char *argv[])
* Returns 0 if succeeds, else fails
*/
static int
init_transport(struct netconfig *nconf)
init_transport(const struct netconfig *nconf)
{
int fd = -1;
struct t_bind taddr;
@ -308,8 +309,8 @@ init_transport(struct netconfig *nconf)
int addrlen;
int nhostsbak;
int bound;
struct sockaddr *sa;
u_int32_t host_addr[4]; /* IPv4 or IPv6 */
struct sockaddr *sa;
struct sockaddr_un sun;
mode_t oldmask;
bool local, netlink;
@ -321,17 +322,17 @@ init_transport(struct netconfig *nconf)
if ((nconf->nc_semantics != NC_TPI_CLTS) &&
(nconf->nc_semantics != NC_TPI_COTS) &&
(nconf->nc_semantics != NC_TPI_COTS_ORD))
return (1); /* not my type */
#ifdef ND_DEBUG
return (1); /* not my type */
#ifdef RPCBIND_DEBUG
if (debugging) {
int i;
char **s;
unsigned int i;
char **s;
(void)fprintf(stderr, "%s: %ld lookup routines :\n",
nconf->nc_netid, nconf->nc_nlookups);
for (i = 0, s = nconf->nc_lookups; i < nconf->nc_nlookups;
i++, s++)
fprintf(stderr, "[%d] - %s\n", i, *s);
(void)fprintf(stderr, "%s: %ld lookup routines :\n",
nconf->nc_netid, nconf->nc_nlookups);
for (i = 0, s = nconf->nc_lookups; i < nconf->nc_nlookups;
i++, s++)
(void)fprintf(stderr, "[%d] - %s\n", i, *s);
}
#endif
@ -339,224 +340,223 @@ init_transport(struct netconfig *nconf)
* XXX - using RPC library internal functions.
*/
if (local) {
/*
* For other transports we call this later, for each socket we
* like to bind.
*/
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
int non_fatal = 0;
if (errno == EAFNOSUPPORT)
non_fatal = 1;
syslog(non_fatal?LOG_DEBUG:LOG_ERR, "cannot create socket for %s",
nconf->nc_netid);
return (1);
}
/*
* For other transports we call this later, for each socket we
* like to bind.
*/
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
syslog(errno == EAFNOSUPPORT ? LOG_DEBUG : LOG_ERR,
"cannot create socket for %s",
nconf->nc_netid);
return (1);
}
}
if (!__rpc_nconf2sockinfo(nconf, &si)) {
syslog(LOG_ERR, "cannot get information for %s",
nconf->nc_netid);
return (1);
syslog(LOG_ERR, "cannot get information for %s",
nconf->nc_netid);
return (1);
}
if (local) {
memset(&sun, 0, sizeof sun);
sun.sun_family = AF_LOCAL;
unlink(_PATH_RPCBINDSOCK);
strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
sun.sun_len = SUN_LEN(&sun);
addrlen = sizeof (struct sockaddr_un);
sa = (struct sockaddr *)&sun;
memset(&sun, 0, sizeof sun);
sun.sun_family = AF_LOCAL;
unlink(_PATH_RPCBINDSOCK);
strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
sun.sun_len = SUN_LEN(&sun);
addrlen = sizeof (struct sockaddr_un);
sa = (struct sockaddr *)&sun;
} else if (!netlink) {
/* Get rpcbind's address on this transport */
memset(&hints, 0, sizeof hints);
hints.ai_flags = AI_PASSIVE;
hints.ai_family = si.si_af;
hints.ai_socktype = si.si_socktype;
hints.ai_protocol = si.si_proto;
/* Get rpcbind's address on this transport */
memset(&hints, 0, sizeof hints);
hints.ai_flags = AI_PASSIVE;
hints.ai_family = si.si_af;
hints.ai_socktype = si.si_socktype;
hints.ai_protocol = si.si_proto;
}
if (!local && !netlink) {
/*
* If no hosts were specified, just bind to INADDR_ANY.
* Otherwise make sure 127.0.0.1 is added to the list.
*/
nhostsbak = nhosts + 1;
hosts = realloc(hosts, nhostsbak * sizeof(char *));
if (nhostsbak == 1)
hosts[0] = "*";
else {
if (hints.ai_family == AF_INET && nobind_localhost == 0) {
hosts[nhostsbak - 1] = "127.0.0.1";
} else if (hints.ai_family == AF_INET6 && nobind_localhost == 0) {
hosts[nhostsbak - 1] = "::1";
} else
return 1;
}
/*
* Bind to specific IPs if asked to
*/
bound = 0;
while (nhostsbak > 0) {
--nhostsbak;
/*
* XXX - using RPC library internal functions.
* If no hosts were specified, just bind to INADDR_ANY.
* Otherwise make sure 127.0.0.1 is added to the list.
*/
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
int non_fatal = 0;
if (errno == EAFNOSUPPORT &&
nconf->nc_semantics != NC_TPI_CLTS)
non_fatal = 1;
syslog(non_fatal ? LOG_DEBUG : LOG_ERR,
"cannot create socket for %s", nconf->nc_netid);
return (1);
nhostsbak = nhosts + 1;
hosts = realloc(hosts, nhostsbak * sizeof(char *));
if (nhostsbak == 1)
hosts[0] = "*";
else {
if (hints.ai_family == AF_INET &&
!nobind_localhost) {
hosts[nhostsbak - 1] = "127.0.0.1";
} else if (hints.ai_family == AF_INET6 &&
!nobind_localhost) {
hosts[nhostsbak - 1] = "::1";
} else
return 1;
}
switch (hints.ai_family) {
case AF_INET:
if (inet_pton(AF_INET, hosts[nhostsbak],
host_addr) == 1) {
hints.ai_flags &= AI_NUMERICHOST;
} else {
/*
* Bind to specific IPs if asked to
*/
bound = 0;
while (nhostsbak > 0) {
--nhostsbak;
/*
* Skip if we have an AF_INET6 address.
* XXX - using RPC library internal functions.
*/
if (inet_pton(AF_INET6,
hosts[nhostsbak], host_addr) == 1) {
close(fd);
continue;
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
int non_fatal = 0;
if (errno == EAFNOSUPPORT &&
nconf->nc_semantics != NC_TPI_CLTS)
non_fatal = 1;
syslog(non_fatal ? LOG_DEBUG : LOG_ERR,
"cannot create socket for %s", nconf->nc_netid);
return (1);
}
}
break;
case AF_INET6:
if (inet_pton(AF_INET6, hosts[nhostsbak],
host_addr) == 1) {
hints.ai_flags &= AI_NUMERICHOST;
} else {
switch (hints.ai_family) {
case AF_INET:
if (inet_pton(AF_INET, hosts[nhostsbak],
host_addr) == 1) {
hints.ai_flags &= AI_NUMERICHOST;
} else {
/*
* Skip if we have an AF_INET6 address.
*/
if (inet_pton(AF_INET6,
hosts[nhostsbak], host_addr) == 1) {
close(fd);
continue;
}
}
break;
case AF_INET6:
if (inet_pton(AF_INET6, hosts[nhostsbak],
host_addr) == 1) {
hints.ai_flags &= AI_NUMERICHOST;
} else {
/*
* Skip if we have an AF_INET address.
*/
if (inet_pton(AF_INET, hosts[nhostsbak],
host_addr) == 1) {
close(fd);
continue;
}
}
if (setsockopt(fd, IPPROTO_IPV6,
IPV6_V6ONLY, &on, sizeof on) < 0) {
syslog(LOG_ERR,
"can't set v6-only binding for "
"ipv6 socket: %m");
continue;
}
break;
default:
break;
}
/*
* Skip if we have an AF_INET address.
* If no hosts were specified, just bind to INADDR_ANY
*/
if (inet_pton(AF_INET, hosts[nhostsbak],
host_addr) == 1) {
close(fd);
if (strcmp("*", hosts[nhostsbak]) == 0)
hosts[nhostsbak] = NULL;
if ((aicode = getaddrinfo(hosts[nhostsbak], servname, &hints,
&res)) != 0) {
syslog(LOG_ERR, "cannot get local address for %s: %s",
nconf->nc_netid, gai_strerror(aicode));
continue;
}
}
if (setsockopt(fd, IPPROTO_IPV6,
IPV6_V6ONLY, &on, sizeof on) < 0) {
syslog(LOG_ERR,
"can't set v6-only binding for "
"ipv6 socket: %m");
continue;
}
break;
default:
break;
}
addrlen = res->ai_addrlen;
sa = (struct sockaddr *)res->ai_addr;
oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
if (bind(fd, sa, addrlen) != 0) {
syslog(LOG_ERR, "cannot bind %s on %s: %m",
(hosts[nhostsbak] == NULL) ? "*" :
hosts[nhostsbak], nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
continue;
} else
bound = 1;
(void)umask(oldmask);
/*
* If no hosts were specified, just bind to INADDR_ANY
*/
if (strcmp("*", hosts[nhostsbak]) == 0)
hosts[nhostsbak] = NULL;
if ((aicode = getaddrinfo(hosts[nhostsbak], servname, &hints,
&res)) != 0) {
syslog(LOG_ERR, "cannot get local address for %s: %s",
nconf->nc_netid, gai_strerror(aicode));
continue;
/* Copy the address */
taddr.addr.len = taddr.addr.maxlen = addrlen;
taddr.addr.buf = malloc(addrlen);
if (taddr.addr.buf == NULL) {
syslog(LOG_ERR,
"cannot allocate memory for %s address",
nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
return 1;
}
memcpy(taddr.addr.buf, sa, addrlen);
#ifdef RPCBIND_DEBUG
if (debugging) {
/*
* for debugging print out our universal
* address
*/
char *uaddr;
struct netbuf nb;
nb.buf = sa;
nb.len = nb.maxlen = sa->sa_len;
uaddr = taddr2uaddr(nconf, &nb);
(void)fprintf(stderr,
"rpcbind : my address is %s\n", uaddr);
(void)free(uaddr);
}
#endif
if (nconf->nc_semantics != NC_TPI_CLTS)
listen(fd, SOMAXCONN);
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
RPC_MAXDATASIZE, RPC_MAXDATASIZE);
}
addrlen = res->ai_addrlen;
sa = (struct sockaddr *)res->ai_addr;
} else if (local) {
oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
if (bind(fd, sa, addrlen) != 0) {
syslog(LOG_ERR, "cannot bind %s on %s: %m",
(hosts[nhostsbak] == NULL) ? "*" :
hosts[nhostsbak], nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
continue;
} else
bound = 1;
(void)umask(oldmask);
if (bind(fd, sa, addrlen) < 0) {
syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
return 1;
}
(void) umask(oldmask);
/* Copy the address */
taddr.addr.len = taddr.addr.maxlen = addrlen;
taddr.addr.buf = malloc(addrlen);
if (taddr.addr.buf == NULL) {
syslog(LOG_ERR,
"cannot allocate memory for %s address",
nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
return 1;
syslog(LOG_ERR, "cannot allocate memory for %s address",
nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
return 1;
}
memcpy(taddr.addr.buf, sa, addrlen);
#ifdef ND_DEBUG
#ifdef RPCBIND_DEBUG
if (debugging) {
/*
* for debugging print out our universal
* address
*/
char *uaddr;
struct netbuf nb;
/* for debugging print out our universal address */
char *uaddr;
struct netbuf nb;
nb.buf = sa;
nb.len = nb.maxlen = sa->sa_len;
uaddr = taddr2uaddr(nconf, &nb);
(void)fprintf(stderr,
"rpcbind : my address is %s\n", uaddr);
(void)free(uaddr);
}
nb.buf = sa;
nb.len = nb.maxlen = sa->sa_len;
uaddr = taddr2uaddr(nconf, &nb);
(void)fprintf(stderr, "rpcbind : my address is %s\n",
uaddr);
(void)free(uaddr);
}
#endif
if (nconf->nc_semantics != NC_TPI_CLTS)
listen(fd, SOMAXCONN);
listen(fd, SOMAXCONN);
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
RPC_MAXDATASIZE, RPC_MAXDATASIZE);
}
} else if (local) {
oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
if (bind(fd, sa, addrlen) < 0) {
syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
return 1;
}
(void) umask(oldmask);
/* Copy the address */
taddr.addr.len = taddr.addr.maxlen = addrlen;
taddr.addr.buf = malloc(addrlen);
if (taddr.addr.buf == NULL) {
syslog(LOG_ERR, "cannot allocate memory for %s address",
nconf->nc_netid);
if (res != NULL)
freeaddrinfo(res);
return 1;
}
memcpy(taddr.addr.buf, sa, addrlen);
#ifdef ND_DEBUG
if (debugging) {
/* for debugging print out our universal address */
char *uaddr;
struct netbuf nb;
nb.buf = sa;
nb.len = nb.maxlen = sa->sa_len;
uaddr = taddr2uaddr(nconf, &nb);
(void) fprintf(stderr, "rpcbind : my address is %s\n",
uaddr);
(void) free(uaddr);
}
#endif
if (nconf->nc_semantics != NC_TPI_CLTS)
listen(fd, SOMAXCONN);
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
RPC_MAXDATASIZE, RPC_MAXDATASIZE);
} else {
assert(netlink);
taddr = netlink_taddr;
@ -581,7 +581,7 @@ init_transport(struct netconfig *nconf)
if (!svc_register(my_xprt, PMAPPROG, PMAPVERS,
pmap_service, 0)) {
syslog(LOG_ERR, "could not register on %s",
nconf->nc_netid);
nconf->nc_netid);
goto error;
}
pml = malloc(sizeof (struct pmaplist));
@ -597,7 +597,7 @@ init_transport(struct netconfig *nconf)
free(pml);
pml = NULL;
syslog(LOG_ERR,
"cannot have more than one TCP transport");
"cannot have more than one TCP transport");
goto error;
}
tcptrans = strdup(nconf->nc_netid);
@ -609,7 +609,7 @@ init_transport(struct netconfig *nconf)
} else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
if (udptrans[0]) {
syslog(LOG_ERR,
"cannot have more than one UDP transport");
"cannot have more than one UDP transport");
goto error;
}
udptrans = strdup(nconf->nc_netid);
@ -626,9 +626,9 @@ init_transport(struct netconfig *nconf)
list_pml = pml;
/* Add version 3 information */
pml = malloc(sizeof (struct pmaplist));
pml = malloc(sizeof(*pml));
if (pml == NULL) {
syslog(LOG_ERR, "no memory!");
syslog(LOG_ERR, "%m");
exit(1);
}
pml->pml_map = list_pml->pml_map;
@ -637,9 +637,9 @@ init_transport(struct netconfig *nconf)
list_pml = pml;
/* Add version 4 information */
pml = malloc (sizeof (struct pmaplist));
pml = malloc(sizeof(*pml));
if (pml == NULL) {
syslog(LOG_ERR, "no memory!");
syslog(LOG_ERR, "%m");
exit(1);
}
pml->pml_map = list_pml->pml_map;
@ -655,7 +655,7 @@ init_transport(struct netconfig *nconf)
/* version 3 registration */
if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS, rpcb_service_3, NULL)) {
syslog(LOG_ERR, "could not register %s version 3",
nconf->nc_netid);
nconf->nc_netid);
goto error;
}
rbllist_add(RPCBPROG, RPCBVERS, nconf, &taddr.addr);
@ -663,24 +663,24 @@ init_transport(struct netconfig *nconf)
/* version 4 registration */
if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS4, rpcb_service_4, NULL)) {
syslog(LOG_ERR, "could not register %s version 4",
nconf->nc_netid);
nconf->nc_netid);
goto error;
}
rbllist_add(RPCBPROG, RPCBVERS4, nconf, &taddr.addr);
/* decide if bound checking works for this transport */
status = add_bndlist(nconf, &taddr.addr);
#ifdef BIND_DEBUG
#ifdef RPCBIND_DEBUG
if (debugging) {
if (status < 0) {
fprintf(stderr, "Error in finding bind status for %s\n",
nconf->nc_netid);
nconf->nc_netid);
} else if (status == 0) {
fprintf(stderr, "check binding for %s\n",
nconf->nc_netid);
nconf->nc_netid);
} else if (status > 0) {
fprintf(stderr, "No check binding for %s\n",
nconf->nc_netid);
nconf->nc_netid);
}
}
#endif
@ -690,15 +690,15 @@ init_transport(struct netconfig *nconf)
if (!netlink && nconf->nc_semantics == NC_TPI_CLTS) {
status = create_rmtcall_fd(nconf);
#ifdef BIND_DEBUG
#ifdef RPCBIND_DEBUG
if (debugging) {
if (status < 0) {
fprintf(stderr,
"Could not create rmtcall fd for %s\n",
nconf->nc_netid);
nconf->nc_netid);
} else {
fprintf(stderr, "rmtcall fd for %s is %d\n",
nconf->nc_netid, status);
nconf->nc_netid, status);
}
}
#endif
@ -761,13 +761,13 @@ listen_addr(const struct sockaddr *sa)
continue;
switch (sa->sa_family) {
case AF_INET:
if (memcmp(&SA2SINADDR(sa), &SA2SINADDR(bound_sa[i]),
if (memcmp(&SA2SINADDR(sa), &SA2SINADDR(bound_sa[i]),
sizeof(struct in_addr)) == 0)
return (1);
break;
#ifdef INET6
case AF_INET6:
if (memcmp(&SA2SIN6ADDR(sa), &SA2SIN6ADDR(bound_sa[i]),
if (memcmp(&SA2SIN6ADDR(sa), &SA2SIN6ADDR(bound_sa[i]),
sizeof(struct in6_addr)) == 0)
return (1);
break;
@ -780,8 +780,8 @@ listen_addr(const struct sockaddr *sa)
}
static void
rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
struct netbuf *addr)
rbllist_add(rpcprog_t prog, rpcvers_t vers, const struct netconfig *nconf,
struct netbuf *addr)
{
rpcblist_ptr rbl;
@ -795,7 +795,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;
}
@ -928,9 +928,9 @@ void
reap(int dummy __unused)
{
int save_errno = errno;
while (wait3(NULL, WNOHANG, NULL) > 0)
;
;
errno = save_errno;
}

View file

@ -80,14 +80,17 @@ extern int rpcbindlockfd;
#ifdef PORTMAP
extern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
extern char *udptrans; /* Name of UDP transport */
extern char *tcptrans; /* Name of TCP transport */
extern char *udp_uaddr; /* Universal UDP address */
extern char *tcp_uaddr; /* Universal TCP address */
extern const char *udptrans; /* Name of UDP transport */
extern const char *tcptrans; /* Name of TCP transport */
extern const char *udp_uaddr; /* Universal UDP address */
extern const char *tcp_uaddr; /* Universal TCP address */
#endif
int add_bndlist(struct netconfig *, struct netbuf *);
bool_t is_bound(char *, char *);
extern const char rpcbind_superuser[];
extern const char rpcbind_unknown[];
int add_bndlist(const struct netconfig *, struct netbuf *);
bool_t is_bound(const char *, const char *);
char *mergeaddr(SVCXPRT *, char *, char *, char *);
struct netconfig *rpcbind_get_conf(const char *);
@ -95,9 +98,10 @@ void rpcbs_init(void);
void rpcbs_procinfo(rpcvers_t, rpcproc_t);
void rpcbs_set(rpcvers_t, bool_t);
void rpcbs_unset(rpcvers_t, bool_t);
void rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, char *, char *);
void rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, const char *,
const char *);
void rpcbs_rmtcall(rpcvers_t, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t,
char *, rpcblist_ptr);
char *, rpcblist_ptr);
void *rpcbproc_getstat(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
void rpcb_service_3(struct svc_req *, SVCXPRT *);
@ -106,20 +110,16 @@ void rpcb_service_4(struct svc_req *, SVCXPRT *);
/* Common functions shared between versions */
void *rpcbproc_set_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
void *rpcbproc_unset_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
bool_t map_set(RPCB *, char *);
bool_t map_unset(RPCB *, char *);
bool_t map_set(RPCB *, const char *);
bool_t map_unset(RPCB *, const char *);
void delete_prog(unsigned int);
void *rpcbproc_getaddr_com(RPCB *, struct svc_req *, SVCXPRT *, rpcvers_t,
rpcvers_t);
void *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
void *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
SVCXPRT *, rpcvers_t);
void *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
rpcvers_t);
int create_rmtcall_fd(struct netconfig *);
void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
rpcvers_t);
rpcvers_t);
void *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
void *rpcbproc_uaddr2taddr_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
void *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
int create_rmtcall_fd(const struct netconfig *);
void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t, rpcvers_t);
void my_svc_run(void);
void rpcbind_abort(void);
@ -156,4 +156,6 @@ struct sockaddr *local_sa(int);
#define SA2SIN6ADDR(sa) (SA2SIN6(sa)->sin6_addr)
#endif
#define __UNCONST(a) __DECONST(void *, (a))
#endif /* rpcbind_h */

View file

@ -87,7 +87,7 @@ write_struct(char *filename, xdrproc_t structproc, void *list)
return (FALSE);
}
}
(void) umask(omask);
(void)umask(omask);
xdrstdio_create(&xdrs, fp, XDR_ENCODE);
if (structproc(&xdrs, list) == FALSE) {
@ -143,9 +143,9 @@ error: fprintf(stderr, "rpcbind: will start from scratch\n");
void
write_warmstart(void)
{
(void) write_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &list_rbl);
(void)write_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &list_rbl);
#ifdef PORTMAP
(void) write_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &list_pml);
(void)write_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &list_pml);
#endif
}
@ -166,13 +166,13 @@ read_warmstart(void)
ok2 = read_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &tmp_pmapl);
#endif
if (ok2 == FALSE) {
xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&tmp_rpcbl);
xdr_free((xdrproc_t)xdr_rpcblist_ptr, &tmp_rpcbl);
return;
}
xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&list_rbl);
xdr_free((xdrproc_t)xdr_rpcblist_ptr, &list_rbl);
list_rbl = tmp_rpcbl;
#ifdef PORTMAP
xdr_free((xdrproc_t) xdr_pmaplist_ptr, (char *)&list_pml);
xdr_free((xdrproc_t)xdr_pmaplist_ptr, &list_pml);
list_pml = tmp_pmapl;
#endif
}