Port to TI/RPC and/or IPV6.
Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
This commit is contained in:
parent
122b088a2a
commit
af37179b5f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100120
@ -32,9 +32,9 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include <ufs/ufs/quota.h>
|
#include <ufs/ufs/quota.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <rpcsvc/rquota.h>
|
#include <rpcsvc/rquota.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
void rquota_service(struct svc_req *request, SVCXPRT *transp);
|
void rquota_service(struct svc_req *request, SVCXPRT *transp);
|
||||||
void sendquota(struct svc_req *request, SVCXPRT *transp);
|
void sendquota(struct svc_req *request, SVCXPRT *transp);
|
||||||
@ -60,7 +60,7 @@ int from_inetd = 1;
|
|||||||
void
|
void
|
||||||
cleanup(int sig)
|
cleanup(int sig)
|
||||||
{
|
{
|
||||||
(void) pmap_unset(RQUOTAPROG, RQUOTAVERS);
|
(void) rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,22 +68,19 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SVCXPRT *transp;
|
SVCXPRT *transp;
|
||||||
int sock = 0;
|
int ok;
|
||||||
int proto = 0;
|
struct sockaddr_storage from;
|
||||||
struct sockaddr_in from;
|
|
||||||
int fromlen;
|
int fromlen;
|
||||||
|
|
||||||
fromlen = sizeof(from);
|
fromlen = sizeof(from);
|
||||||
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
||||||
from_inetd = 0;
|
from_inetd = 0;
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
proto = IPPROTO_UDP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from_inetd) {
|
if (!from_inetd) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
|
|
||||||
(void) pmap_unset(RQUOTAPROG, RQUOTAVERS);
|
(void) rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL);
|
||||||
|
|
||||||
(void) signal(SIGINT, cleanup);
|
(void) signal(SIGINT, cleanup);
|
||||||
(void) signal(SIGTERM, cleanup);
|
(void) signal(SIGTERM, cleanup);
|
||||||
@ -93,13 +90,19 @@ main(int argc, char *argv[])
|
|||||||
openlog("rpc.rquotad", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("rpc.rquotad", LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
/* create and register the service */
|
/* create and register the service */
|
||||||
transp = svcudp_create(sock);
|
if (from_inetd) {
|
||||||
if (transp == NULL) {
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
||||||
syslog(LOG_ERR, "couldn't create udp service");
|
if (transp == NULL) {
|
||||||
exit(1);
|
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)");
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,14 +187,15 @@ sendquota(struct svc_req *request, SVCXPRT *transp)
|
|||||||
void
|
void
|
||||||
printerr_reply(SVCXPRT *transp) /* when a reply to a request failed */
|
printerr_reply(SVCXPRT *transp) /* when a reply to a request failed */
|
||||||
{
|
{
|
||||||
char *name;
|
char name[INET6_ADDRSTRLEN];
|
||||||
struct sockaddr_in *caller;
|
struct sockaddr *caller;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
|
|
||||||
caller = svc_getcaller(transp);
|
caller = (struct sockaddr *)svc_getrpccaller(transp)->buf;
|
||||||
name = (char *)inet_ntoa(caller->sin_addr);
|
getnameinfo(caller, caller->sa_len, name, sizeof (name),
|
||||||
|
NULL, 0, NI_NUMERICHOST);
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
syslog(LOG_ERR, "couldn't send reply to %s", name);
|
syslog(LOG_ERR, "couldn't send reply to %s", name);
|
||||||
|
@ -40,7 +40,6 @@ static const char rcsid[] =
|
|||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <rpcsvc/rstat.h>
|
#include <rpcsvc/rstat.h>
|
||||||
|
|
||||||
extern void rstat_service(struct svc_req *, SVCXPRT *);
|
extern void rstat_service(struct svc_req *, SVCXPRT *);
|
||||||
@ -51,9 +50,9 @@ int closedown = 20; /* how long to wait before going dormant */
|
|||||||
void
|
void
|
||||||
cleanup(int sig __unused)
|
cleanup(int sig __unused)
|
||||||
{
|
{
|
||||||
(void) pmap_unset(RSTATPROG, RSTATVERS_TIME);
|
(void) rpcb_unset(RSTATPROG, RSTATVERS_TIME, NULL);
|
||||||
(void) pmap_unset(RSTATPROG, RSTATVERS_SWTCH);
|
(void) rpcb_unset(RSTATPROG, RSTATVERS_SWTCH, NULL);
|
||||||
(void) pmap_unset(RSTATPROG, RSTATVERS_ORIG);
|
(void) rpcb_unset(RSTATPROG, RSTATVERS_ORIG, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +60,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SVCXPRT *transp;
|
SVCXPRT *transp;
|
||||||
int sock = 0;
|
int ok;
|
||||||
int proto = 0;
|
struct sockaddr_storage from;
|
||||||
struct sockaddr_in from;
|
|
||||||
int fromlen;
|
int fromlen;
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
@ -77,16 +75,14 @@ main(int argc, char *argv[])
|
|||||||
fromlen = sizeof(from);
|
fromlen = sizeof(from);
|
||||||
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
||||||
from_inetd = 0;
|
from_inetd = 0;
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
proto = IPPROTO_UDP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from_inetd) {
|
if (!from_inetd) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
|
|
||||||
(void)pmap_unset(RSTATPROG, RSTATVERS_TIME);
|
(void)rpcb_unset(RSTATPROG, RSTATVERS_TIME, NULL);
|
||||||
(void)pmap_unset(RSTATPROG, RSTATVERS_SWTCH);
|
(void)rpcb_unset(RSTATPROG, RSTATVERS_SWTCH, NULL);
|
||||||
(void)pmap_unset(RSTATPROG, RSTATVERS_ORIG);
|
(void)rpcb_unset(RSTATPROG, RSTATVERS_ORIG, NULL);
|
||||||
|
|
||||||
(void) signal(SIGINT, cleanup);
|
(void) signal(SIGINT, cleanup);
|
||||||
(void) signal(SIGTERM, cleanup);
|
(void) signal(SIGTERM, cleanup);
|
||||||
@ -95,22 +91,40 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
openlog("rpc.rstatd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("rpc.rstatd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
transp = svcudp_create(sock);
|
if (from_inetd) {
|
||||||
if (transp == NULL) {
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
||||||
syslog(LOG_ERR, "cannot create udp service");
|
if (transp == NULL) {
|
||||||
exit(1);
|
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)) {
|
if (from_inetd)
|
||||||
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_TIME, %s)", proto?"udp":"(inetd)");
|
ok = svc_reg(transp, RSTATPROG, RSTATVERS_SWTCH,
|
||||||
exit(1);
|
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)) {
|
if (from_inetd)
|
||||||
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_SWTCH, %s)", proto?"udp":"(inetd)");
|
ok = svc_reg(transp, RSTATPROG, RSTATVERS_ORIG,
|
||||||
exit(1);
|
rstat_service, NULL);
|
||||||
}
|
else
|
||||||
if (!svc_register(transp, RSTATPROG, RSTATVERS_ORIG, rstat_service, proto)) {
|
ok = svc_create(rstat_service,
|
||||||
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, %s)", proto?"udp":"(inetd)");
|
RSTATPROG, RSTATVERS_ORIG, "udp");
|
||||||
exit(1);
|
if (!ok) {
|
||||||
|
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, %s)", (!from_inetd)?"udp":"(inetd)");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
svc_run();
|
svc_run();
|
||||||
|
@ -38,7 +38,7 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/pmap_clnt.h>
|
#include <sys/socket.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#define utmp rutmp
|
#define utmp rutmp
|
||||||
@ -52,8 +52,8 @@ int from_inetd = 1;
|
|||||||
void
|
void
|
||||||
cleanup(int sig __unused)
|
cleanup(int sig __unused)
|
||||||
{
|
{
|
||||||
(void) pmap_unset(RUSERSPROG, RUSERSVERS_IDLE);
|
(void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
|
||||||
(void) pmap_unset(RUSERSPROG, RUSERSVERS_ORIG);
|
(void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SVCXPRT *transp;
|
SVCXPRT *transp;
|
||||||
int sock = 0;
|
int ok;
|
||||||
int proto = 0;
|
struct sockaddr_storage from;
|
||||||
struct sockaddr_in from;
|
|
||||||
int fromlen;
|
int fromlen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -72,15 +71,13 @@ main(int argc, char *argv[])
|
|||||||
fromlen = sizeof(from);
|
fromlen = sizeof(from);
|
||||||
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
||||||
from_inetd = 0;
|
from_inetd = 0;
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
proto = IPPROTO_UDP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from_inetd) {
|
if (!from_inetd) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
|
|
||||||
(void) pmap_unset(RUSERSPROG, RUSERSVERS_IDLE);
|
(void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
|
||||||
(void) pmap_unset(RUSERSPROG, RUSERSVERS_ORIG);
|
(void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL);
|
||||||
|
|
||||||
(void) signal(SIGINT, cleanup);
|
(void) signal(SIGINT, cleanup);
|
||||||
(void) signal(SIGTERM, cleanup);
|
(void) signal(SIGTERM, cleanup);
|
||||||
@ -89,18 +86,29 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
openlog("rpc.rusersd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("rpc.rusersd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
transp = svcudp_create(sock);
|
if (from_inetd) {
|
||||||
if (transp == NULL) {
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
||||||
syslog(LOG_ERR, "cannot create udp service");
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!svc_register(transp, RUSERSPROG, RUSERSVERS_IDLE, rusers_service, proto)) {
|
if (from_inetd)
|
||||||
syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_IDLE, %s)", proto?"udp":"(inetd)");
|
ok = svc_reg(transp, RUSERSPROG, RUSERSVERS_ORIG,
|
||||||
exit(1);
|
rusers_service, NULL);
|
||||||
}
|
else
|
||||||
|
ok = svc_create(rusers_service,
|
||||||
if (!svc_register(transp, RUSERSPROG, RUSERSVERS_ORIG, rusers_service, proto)) {
|
RUSERSPROG, RUSERSVERS_ORIG, "udp");
|
||||||
syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_ORIG, %s)", proto?"udp":"(inetd)");
|
if (!ok) {
|
||||||
|
syslog(LOG_ERR, "unable to register (RUSERSPROG, RUSERSVERS_ORIG, %s)", (!from_inetd)?"udp":"(inetd)");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ static const char rcsid[] =
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <rpcsvc/rwall.h>
|
#include <rpcsvc/rwall.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -66,10 +65,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SVCXPRT *transp;
|
SVCXPRT *transp;
|
||||||
int s, salen;
|
int ok, salen;
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_storage sa;
|
||||||
int sock = 0;
|
|
||||||
int proto = 0;
|
|
||||||
|
|
||||||
if (argc == 2 && !strcmp(argv[1], "-n"))
|
if (argc == 2 && !strcmp(argv[1], "-n"))
|
||||||
nodaemon = 1;
|
nodaemon = 1;
|
||||||
@ -90,42 +87,33 @@ main(int argc, char *argv[])
|
|||||||
salen = sizeof(sa);
|
salen = sizeof(sa);
|
||||||
if (getsockname(0, (struct sockaddr *)&sa, &salen) < 0) {
|
if (getsockname(0, (struct sockaddr *)&sa, &salen) < 0) {
|
||||||
from_inetd = 0;
|
from_inetd = 0;
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
proto = IPPROTO_UDP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from_inetd) {
|
if (!from_inetd) {
|
||||||
if (!nodaemon)
|
if (!nodaemon)
|
||||||
possess();
|
possess();
|
||||||
|
|
||||||
(void)pmap_unset(WALLPROG, WALLVERS);
|
(void)rpcb_unset(WALLPROG, WALLVERS, NULL);
|
||||||
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)signal(SIGCHLD, killkids);
|
(void)signal(SIGCHLD, killkids);
|
||||||
|
|
||||||
openlog("rpc.rwalld", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("rpc.rwalld", LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
transp = svcudp_create(sock);
|
/* create and register the service */
|
||||||
if (transp == NULL) {
|
if (from_inetd) {
|
||||||
syslog(LOG_ERR, "cannot create udp service");
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
||||||
exit(1);
|
if (transp == NULL) {
|
||||||
}
|
syslog(LOG_ERR, "couldn't create udp service.");
|
||||||
if (!svc_register(transp, WALLPROG, WALLVERS, wallprog_1, proto)) {
|
exit(1);
|
||||||
syslog(LOG_ERR, "unable to register (WALLPROG, WALLVERS, %s)", proto?"udp":"(inetd)");
|
}
|
||||||
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
svc_run();
|
svc_run();
|
||||||
|
@ -34,7 +34,6 @@ static const char rcsid[] =
|
|||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <rpcsvc/spray.h>
|
#include <rpcsvc/spray.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -63,7 +62,7 @@ static int from_inetd = 1;
|
|||||||
void
|
void
|
||||||
cleanup(int sig __unused)
|
cleanup(int sig __unused)
|
||||||
{
|
{
|
||||||
(void) pmap_unset(SPRAYPROG, SPRAYVERS);
|
(void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +76,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SVCXPRT *transp;
|
SVCXPRT *transp;
|
||||||
int sock = 0;
|
int ok;
|
||||||
int proto = 0;
|
struct sockaddr_storage from;
|
||||||
struct sockaddr_in from;
|
|
||||||
int fromlen;
|
int fromlen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -88,14 +86,12 @@ main(int argc, char *argv[])
|
|||||||
fromlen = sizeof(from);
|
fromlen = sizeof(from);
|
||||||
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
|
||||||
from_inetd = 0;
|
from_inetd = 0;
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
proto = IPPROTO_UDP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from_inetd) {
|
if (!from_inetd) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
|
|
||||||
(void) pmap_unset(SPRAYPROG, SPRAYVERS);
|
(void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
|
||||||
|
|
||||||
(void) signal(SIGINT, cleanup);
|
(void) signal(SIGINT, cleanup);
|
||||||
(void) signal(SIGTERM, cleanup);
|
(void) signal(SIGTERM, cleanup);
|
||||||
@ -107,15 +103,21 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
transp = svcudp_create(sock);
|
if (from_inetd) {
|
||||||
if (transp == NULL) {
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
||||||
syslog(LOG_ERR, "cannot create udp service");
|
if (transp == NULL) {
|
||||||
return 1;
|
syslog(LOG_ERR, "cannot create udp service.");
|
||||||
}
|
exit(1);
|
||||||
if (!svc_register(transp, SPRAYPROG, SPRAYVERS, spray_service, proto)) {
|
}
|
||||||
|
ok = svc_reg(transp, SPRAYPROG, SPRAYVERS,
|
||||||
|
spray_service, NULL);
|
||||||
|
} else
|
||||||
|
ok = svc_create(spray_service,
|
||||||
|
SPRAYPROG, SPRAYVERS, "udp");
|
||||||
|
if (!ok) {
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
"unable to register (SPRAYPROG, SPRAYVERS, %s)",
|
"unable to register (SPRAYPROG, SPRAYVERS, %s)",
|
||||||
proto ? "udp" : "(inetd)");
|
(!from_inetd)?"udp":"(inetd)");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,10 +764,10 @@ root_auth(trans, rqstp)
|
|||||||
struct svc_req *rqstp;
|
struct svc_req *rqstp;
|
||||||
{
|
{
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
struct sockaddr_in *remote;
|
struct sockaddr *remote;
|
||||||
|
|
||||||
remote = svc_getcaller(trans);
|
remote = svc_getrpccaller(trans)->buf;
|
||||||
if (remote->sin_family == AF_INET) {
|
if (remote->sa_family != AF_UNIX) {
|
||||||
if (debugging)
|
if (debugging)
|
||||||
fprintf(stderr, "client didn't use AF_UNIX\n");
|
fprintf(stderr, "client didn't use AF_UNIX\n");
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -44,7 +44,6 @@ static const char rcsid[] =
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -71,19 +70,12 @@ main(int argc, char **argv)
|
|||||||
debug = 1;
|
debug = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)pmap_unset(SM_PROG, SM_VERS);
|
(void)rpcb_unset(SM_PROG, SM_VERS, NULL);
|
||||||
|
|
||||||
transp = svcudp_create(RPC_ANYSOCK);
|
if (!svc_create(sm_prog_1, SM_PROG, SM_VERS, "udp"))
|
||||||
if (transp == NULL)
|
|
||||||
errx(1, "cannot create udp service");
|
errx(1, "cannot create udp service");
|
||||||
if (!svc_register(transp, SM_PROG, SM_VERS, sm_prog_1, IPPROTO_UDP))
|
if (!svc_create(sm_prog_1, SM_PROG, SM_VERS, "tcp"))
|
||||||
errx(1, "unable to register (SM_PROG, SM_VERS, udp)");
|
|
||||||
|
|
||||||
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
|
|
||||||
if (transp == NULL)
|
|
||||||
errx(1, "cannot create tcp service");
|
errx(1, "cannot create tcp service");
|
||||||
if (!svc_register(transp, SM_PROG, SM_VERS, sm_prog_1, IPPROTO_TCP))
|
|
||||||
errx(1, "unable to register (SM_PROG, SM_VERS, tcp)");
|
|
||||||
init_file("/var/db/statd.status");
|
init_file("/var/db/statd.status");
|
||||||
|
|
||||||
/* Note that it is NOT sensible to run this program from inetd - the */
|
/* Note that it is NOT sensible to run this program from inetd - the */
|
||||||
|
Loading…
Reference in New Issue
Block a user