diff options
author | alfred <alfred@FreeBSD.org> | 2002-07-15 18:51:57 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-07-15 18:51:57 +0000 |
commit | 83a53d0868085db818fddd8cb38eecc0c39cad8d (patch) | |
tree | a7c706e5ad9f636ce740a033b0fa75319465add7 /libexec | |
parent | 08255d70df400237c666515b55e2726296ded480 (diff) | |
download | FreeBSD-src-83a53d0868085db818fddd8cb38eecc0c39cad8d.zip FreeBSD-src-83a53d0868085db818fddd8cb38eecc0c39cad8d.tar.gz |
Port to TI/RPC and/or IPV6.
Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rpc.rquotad/rquotad.c | 42 | ||||
-rw-r--r-- | libexec/rpc.rstatd/rstatd.c | 66 | ||||
-rw-r--r-- | libexec/rpc.rusersd/rusersd.c | 48 | ||||
-rw-r--r-- | libexec/rpc.rwalld/rwalld.c | 46 | ||||
-rw-r--r-- | libexec/rpc.sprayd/sprayd.c | 32 |
5 files changed, 125 insertions, 109 deletions
diff --git a/libexec/rpc.rquotad/rquotad.c b/libexec/rpc.rquotad/rquotad.c index ba9f42a..acc1e64 100644 --- a/libexec/rpc.rquotad/rquotad.c +++ b/libexec/rpc.rquotad/rquotad.c @@ -32,9 +32,9 @@ static const char rcsid[] = #include <ufs/ufs/quota.h> #include <rpc/rpc.h> -#include <rpc/pmap_clnt.h> #include <rpcsvc/rquota.h> #include <arpa/inet.h> +#include <netdb.h> void rquota_service(struct svc_req *request, SVCXPRT *transp); void sendquota(struct svc_req *request, SVCXPRT *transp); @@ -60,7 +60,7 @@ int from_inetd = 1; void cleanup(int sig) { - (void) pmap_unset(RQUOTAPROG, RQUOTAVERS); + (void) rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL); exit(0); } @@ -68,22 +68,19 @@ int main(int argc, char *argv[]) { SVCXPRT *transp; - int sock = 0; - int proto = 0; - struct sockaddr_in from; + int ok; + struct sockaddr_storage from; int fromlen; fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; - sock = RPC_ANYSOCK; - proto = IPPROTO_UDP; } if (!from_inetd) { daemon(0, 0); - (void) pmap_unset(RQUOTAPROG, RQUOTAVERS); + (void) rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); @@ -93,13 +90,19 @@ main(int argc, char *argv[]) openlog("rpc.rquotad", LOG_CONS|LOG_PID, LOG_DAEMON); /* create and register the service */ - transp = svcudp_create(sock); - if (transp == NULL) { - syslog(LOG_ERR, "couldn't create udp service"); - exit(1); - } - if (!svc_register(transp, RQUOTAPROG, RQUOTAVERS, rquota_service, proto)) { - syslog(LOG_ERR, "unable to register (RQUOTAPROG, RQUOTAVERS, %s)", proto?"udp":"(inetd)"); + if (from_inetd) { + transp = svc_tli_create(0, NULL, NULL, 0, 0); + if (transp == NULL) { + syslog(LOG_ERR, "couldn't create udp service."); + exit(1); + } + ok = svc_reg(transp, RQUOTAPROG, RQUOTAVERS, + rquota_service, NULL); + } else + ok = svc_create(rquota_service, + RQUOTAPROG, RQUOTAVERS, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (RQUOTAPROG, RQUOTAVERS, %s)", (!from_inetd)?"udp":"(inetd)"); exit(1); } @@ -184,14 +187,15 @@ sendquota(struct svc_req *request, SVCXPRT *transp) void printerr_reply(SVCXPRT *transp) /* when a reply to a request failed */ { - char *name; - struct sockaddr_in *caller; + char name[INET6_ADDRSTRLEN]; + struct sockaddr *caller; int save_errno; save_errno = errno; - caller = svc_getcaller(transp); - name = (char *)inet_ntoa(caller->sin_addr); + caller = (struct sockaddr *)svc_getrpccaller(transp)->buf; + getnameinfo(caller, caller->sa_len, name, sizeof (name), + NULL, 0, NI_NUMERICHOST); errno = save_errno; if (errno == 0) syslog(LOG_ERR, "couldn't send reply to %s", name); diff --git a/libexec/rpc.rstatd/rstatd.c b/libexec/rpc.rstatd/rstatd.c index 35650d9..e8aea46 100644 --- a/libexec/rpc.rstatd/rstatd.c +++ b/libexec/rpc.rstatd/rstatd.c @@ -40,7 +40,6 @@ static const char rcsid[] = #include <rpc/rpc.h> #include <signal.h> #include <syslog.h> -#include <rpc/pmap_clnt.h> #include <rpcsvc/rstat.h> extern void rstat_service(struct svc_req *, SVCXPRT *); @@ -51,9 +50,9 @@ int closedown = 20; /* how long to wait before going dormant */ void cleanup(int sig __unused) { - (void) pmap_unset(RSTATPROG, RSTATVERS_TIME); - (void) pmap_unset(RSTATPROG, RSTATVERS_SWTCH); - (void) pmap_unset(RSTATPROG, RSTATVERS_ORIG); + (void) rpcb_unset(RSTATPROG, RSTATVERS_TIME, NULL); + (void) rpcb_unset(RSTATPROG, RSTATVERS_SWTCH, NULL); + (void) rpcb_unset(RSTATPROG, RSTATVERS_ORIG, NULL); exit(0); } @@ -61,9 +60,8 @@ int main(int argc, char *argv[]) { SVCXPRT *transp; - int sock = 0; - int proto = 0; - struct sockaddr_in from; + int ok; + struct sockaddr_storage from; int fromlen; if (argc == 2) @@ -77,16 +75,14 @@ main(int argc, char *argv[]) fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; - sock = RPC_ANYSOCK; - proto = IPPROTO_UDP; } if (!from_inetd) { daemon(0, 0); - (void)pmap_unset(RSTATPROG, RSTATVERS_TIME); - (void)pmap_unset(RSTATPROG, RSTATVERS_SWTCH); - (void)pmap_unset(RSTATPROG, RSTATVERS_ORIG); + (void)rpcb_unset(RSTATPROG, RSTATVERS_TIME, NULL); + (void)rpcb_unset(RSTATPROG, RSTATVERS_SWTCH, NULL); + (void)rpcb_unset(RSTATPROG, RSTATVERS_ORIG, NULL); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); @@ -95,22 +91,40 @@ main(int argc, char *argv[]) openlog("rpc.rstatd", LOG_CONS|LOG_PID, LOG_DAEMON); - transp = svcudp_create(sock); - if (transp == NULL) { - syslog(LOG_ERR, "cannot create udp service"); - exit(1); + if (from_inetd) { + transp = svc_tli_create(0, NULL, NULL, 0, 0); + if (transp == NULL) { + syslog(LOG_ERR, "cannot create udp service."); + exit(1); + } + ok = svc_reg(transp, RSTATPROG, RSTATVERS_TIME, + rstat_service, NULL); + } else + ok = svc_create(rstat_service, + RSTATPROG, RSTATVERS_TIME, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_TIME, %s)", (!from_inetd)?"udp":"(inetd)"); + exit(1); } - if (!svc_register(transp, RSTATPROG, RSTATVERS_TIME, rstat_service, proto)) { - syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_TIME, %s)", proto?"udp":"(inetd)"); - exit(1); + if (from_inetd) + ok = svc_reg(transp, RSTATPROG, RSTATVERS_SWTCH, + rstat_service, NULL); + else + ok = svc_create(rstat_service, + RSTATPROG, RSTATVERS_SWTCH, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_SWTCH, %s)", (!from_inetd)?"udp":"(inetd)"); + exit(1); } - if (!svc_register(transp, RSTATPROG, RSTATVERS_SWTCH, rstat_service, proto)) { - syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_SWTCH, %s)", proto?"udp":"(inetd)"); - exit(1); - } - if (!svc_register(transp, RSTATPROG, RSTATVERS_ORIG, rstat_service, proto)) { - syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, %s)", proto?"udp":"(inetd)"); - exit(1); + if (from_inetd) + ok = svc_reg(transp, RSTATPROG, RSTATVERS_ORIG, + rstat_service, NULL); + else + ok = svc_create(rstat_service, + RSTATPROG, RSTATVERS_ORIG, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, %s)", (!from_inetd)?"udp":"(inetd)"); + exit(1); } svc_run(); diff --git a/libexec/rpc.rusersd/rusersd.c b/libexec/rpc.rusersd/rusersd.c index fc4640f..9ffc4b3 100644 --- a/libexec/rpc.rusersd/rusersd.c +++ b/libexec/rpc.rusersd/rusersd.c @@ -38,7 +38,7 @@ static const char rcsid[] = #include <stdlib.h> #include <rpc/rpc.h> -#include <rpc/pmap_clnt.h> +#include <sys/socket.h> #include <signal.h> #include <syslog.h> #define utmp rutmp @@ -52,8 +52,8 @@ int from_inetd = 1; void cleanup(int sig __unused) { - (void) pmap_unset(RUSERSPROG, RUSERSVERS_IDLE); - (void) pmap_unset(RUSERSPROG, RUSERSVERS_ORIG); + (void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL); + (void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL); exit(0); } @@ -61,9 +61,8 @@ int main(int argc, char *argv[]) { SVCXPRT *transp; - int sock = 0; - int proto = 0; - struct sockaddr_in from; + int ok; + struct sockaddr_storage from; int fromlen; /* @@ -72,15 +71,13 @@ main(int argc, char *argv[]) fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; - sock = RPC_ANYSOCK; - proto = IPPROTO_UDP; } if (!from_inetd) { daemon(0, 0); - (void) pmap_unset(RUSERSPROG, RUSERSVERS_IDLE); - (void) pmap_unset(RUSERSPROG, RUSERSVERS_ORIG); + (void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL); + (void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); @@ -89,18 +86,29 @@ main(int argc, char *argv[]) openlog("rpc.rusersd", LOG_CONS|LOG_PID, LOG_DAEMON); - transp = svcudp_create(sock); - if (transp == NULL) { - syslog(LOG_ERR, "cannot create udp service"); + if (from_inetd) { + transp = svc_tli_create(0, NULL, NULL, 0, 0); + if (transp == NULL) { + syslog(LOG_ERR, "cannot create udp service."); + exit(1); + } + ok = svc_reg(transp, RUSERSPROG, RUSERSVERS_IDLE, + rusers_service, NULL); + } else + ok = svc_create(rusers_service, + RUSERSPROG, RUSERSVERS_IDLE, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_IDLE, %s)", (!from_inetd)?"udp":"(inetd)"); exit(1); } - if (!svc_register(transp, RUSERSPROG, RUSERSVERS_IDLE, rusers_service, proto)) { - syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_IDLE, %s)", proto?"udp":"(inetd)"); - exit(1); - } - - if (!svc_register(transp, RUSERSPROG, RUSERSVERS_ORIG, rusers_service, proto)) { - syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_ORIG, %s)", proto?"udp":"(inetd)"); + if (from_inetd) + ok = svc_reg(transp, RUSERSPROG, RUSERSVERS_ORIG, + rusers_service, NULL); + else + ok = svc_create(rusers_service, + RUSERSPROG, RUSERSVERS_ORIG, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_ORIG, %s)", (!from_inetd)?"udp":"(inetd)"); exit(1); } diff --git a/libexec/rpc.rwalld/rwalld.c b/libexec/rpc.rwalld/rwalld.c index c186a47..2984717 100644 --- a/libexec/rpc.rwalld/rwalld.c +++ b/libexec/rpc.rwalld/rwalld.c @@ -41,7 +41,6 @@ static const char rcsid[] = #include <syslog.h> #include <arpa/inet.h> #include <rpc/rpc.h> -#include <rpc/pmap_clnt.h> #include <rpcsvc/rwall.h> #include <sys/socket.h> #include <sys/types.h> @@ -66,10 +65,8 @@ int main(int argc, char *argv[]) { SVCXPRT *transp; - int s, salen; - struct sockaddr_in sa; - int sock = 0; - int proto = 0; + int ok, salen; + struct sockaddr_storage sa; if (argc == 2 && !strcmp(argv[1], "-n")) nodaemon = 1; @@ -90,42 +87,33 @@ main(int argc, char *argv[]) salen = sizeof(sa); if (getsockname(0, (struct sockaddr *)&sa, &salen) < 0) { from_inetd = 0; - sock = RPC_ANYSOCK; - proto = IPPROTO_UDP; } if (!from_inetd) { if (!nodaemon) possess(); - (void)pmap_unset(WALLPROG, WALLVERS); - if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) - err(1, "socket"); - bzero(&sa, sizeof sa); - if (bind(s, (struct sockaddr *)&sa, sizeof sa) < 0) - err(1, "bind"); - - salen = sizeof sa; - if (getsockname(s, (struct sockaddr *)&sa, &salen)) - err(1, "getsockname"); - - pmap_set(WALLPROG, WALLVERS, IPPROTO_UDP, ntohs(sa.sin_port)); - if (dup2(s, 0) < 0) - err(1, "dup2"); - (void)pmap_unset(WALLPROG, WALLVERS); + (void)rpcb_unset(WALLPROG, WALLVERS, NULL); } (void)signal(SIGCHLD, killkids); openlog("rpc.rwalld", LOG_CONS|LOG_PID, LOG_DAEMON); - transp = svcudp_create(sock); - if (transp == NULL) { - syslog(LOG_ERR, "cannot create udp service"); - exit(1); - } - if (!svc_register(transp, WALLPROG, WALLVERS, wallprog_1, proto)) { - syslog(LOG_ERR, "unable to register (WALLPROG, WALLVERS, %s)", proto?"udp":"(inetd)"); + /* create and register the service */ + if (from_inetd) { + transp = svc_tli_create(0, NULL, NULL, 0, 0); + if (transp == NULL) { + syslog(LOG_ERR, "couldn't create udp service."); + exit(1); + } + ok = svc_reg(transp, WALLPROG, WALLVERS, + wallprog_1, NULL); + } else + ok = svc_create(wallprog_1, + WALLPROG, WALLVERS, "udp"); + if (!ok) { + syslog(LOG_ERR, "unable to register (WALLPROG, WALLVERS, %s)", (!from_inetd)?"udp":"(inetd)"); exit(1); } svc_run(); diff --git a/libexec/rpc.sprayd/sprayd.c b/libexec/rpc.sprayd/sprayd.c index fd45939..20210d9 100644 --- a/libexec/rpc.sprayd/sprayd.c +++ b/libexec/rpc.sprayd/sprayd.c @@ -34,7 +34,6 @@ static const char rcsid[] = #endif /* not lint */ #include <rpc/rpc.h> -#include <rpc/pmap_clnt.h> #include <rpcsvc/spray.h> #include <signal.h> #include <stdio.h> @@ -63,7 +62,7 @@ static int from_inetd = 1; void cleanup(int sig __unused) { - (void) pmap_unset(SPRAYPROG, SPRAYVERS); + (void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL); exit(0); } @@ -77,9 +76,8 @@ int main(int argc, char *argv[]) { SVCXPRT *transp; - int sock = 0; - int proto = 0; - struct sockaddr_in from; + int ok; + struct sockaddr_storage from; int fromlen; /* @@ -88,14 +86,12 @@ main(int argc, char *argv[]) fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; - sock = RPC_ANYSOCK; - proto = IPPROTO_UDP; } if (!from_inetd) { daemon(0, 0); - (void) pmap_unset(SPRAYPROG, SPRAYVERS); + (void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); @@ -107,15 +103,21 @@ main(int argc, char *argv[]) openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON); - transp = svcudp_create(sock); - if (transp == NULL) { - syslog(LOG_ERR, "cannot create udp service"); - return 1; - } - if (!svc_register(transp, SPRAYPROG, SPRAYVERS, spray_service, proto)) { + if (from_inetd) { + transp = svc_tli_create(0, NULL, NULL, 0, 0); + if (transp == NULL) { + syslog(LOG_ERR, "cannot create udp service."); + exit(1); + } + ok = svc_reg(transp, SPRAYPROG, SPRAYVERS, + spray_service, NULL); + } else + ok = svc_create(spray_service, + SPRAYPROG, SPRAYVERS, "udp"); + if (!ok) { syslog(LOG_ERR, "unable to register (SPRAYPROG, SPRAYVERS, %s)", - proto ? "udp" : "(inetd)"); + (!from_inetd)?"udp":"(inetd)"); return 1; } |