1 /* $NetBSD: rusersd.c,v 1.16 2006/05/09 20:18:07 mrg Exp $ */
4 * Copyright (c) 1993 John Brezak
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
33 __RCSID("$NetBSD: rusersd.c,v 1.16 2006/05/09 20:18:07 mrg Exp $");
38 #include <sys/socket.h>
42 #include <rpcsvc/rusers.h> /* New version */
43 #include <rpcsvc/rnusers.h> /* Old version */
45 #include "rusers_proc.h"
50 static void cleanup(int) __dead
;
57 (void) rpcb_unset(RUSERSPROG
, RUSERSVERS_3
, NULL
);
58 (void) rpcb_unset(RUSERSPROG
, RUSERSVERS_IDLE
, NULL
);
64 main(int argc
, char *argv
[])
67 struct sockaddr_storage from
;
71 * See if inetd started us
73 fromlen
= sizeof(from
);
74 if (getsockname(0, (struct sockaddr
*)(void *)&from
, &fromlen
) == -1)
80 (void)rpcb_unset(RUSERSPROG
, RUSERSVERS_3
, NULL
);
81 (void)rpcb_unset(RUSERSPROG
, RUSERSVERS_IDLE
, NULL
);
83 (void)signal(SIGINT
, cleanup
);
84 (void)signal(SIGTERM
, cleanup
);
85 (void)signal(SIGHUP
, cleanup
);
88 openlog("rpc.rusersd", LOG_PID
, LOG_DAEMON
);
91 transp
= svc_dg_create(0, 0, 0);
93 syslog(LOG_ERR
, "cannot create udp service.");
96 if (!svc_reg(transp
, RUSERSPROG
, RUSERSVERS_3
, rusers_service
,
98 syslog(LOG_ERR
, "unable to register "
99 "(RUSERSPROG, RUSERSVERS_3).");
102 if (!svc_reg(transp
, RUSERSPROG
, RUSERSVERS_IDLE
,
103 rusers_service
, NULL
)) {
104 syslog(LOG_ERR
, "unable to register "
105 "(RUSERSPROG, RUSERSVERS_IDLE).");
109 if (!svc_create(rusers_service
, RUSERSPROG
, RUSERSVERS_3
,
111 syslog(LOG_ERR
, "unable to create "
112 "(RUSERSPROG, RUSERSVERS_3).");
115 if (!svc_create(rusers_service
, RUSERSPROG
, RUSERSVERS_IDLE
,
117 syslog(LOG_ERR
, "unable to create "
118 "(RUSERSPROG, RUSERSVERS_IDLE).");
124 syslog(LOG_ERR
, "svc_run returned");