statd.c (14982) | statd.c (30376) |
---|---|
1/* 2 * Copyright (c) 1995 3 * A.R. Gordon (andrew.gordon@net-tel.co.uk). All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 | 1/* 2 * Copyright (c) 1995 3 * A.R. Gordon (andrew.gordon@net-tel.co.uk). All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 |
34#ifndef lint 35static const char rcsid[] = 36 "$Id$"; 37#endif /* not lint */ |
|
34 35/* main() function for status monitor daemon. Some of the code in this */ 36/* file was generated by running rpcgen /usr/include/rpcsvc/sm_inter.x */ 37/* The actual program logic is in the file procs.c */ 38 | 38 39/* main() function for status monitor daemon. Some of the code in this */ 40/* file was generated by running rpcgen /usr/include/rpcsvc/sm_inter.x */ 41/* The actual program logic is in the file procs.c */ 42 |
43#include <err.h> |
|
39#include <stdio.h> | 44#include <stdio.h> |
45#include <stdlib.h> |
|
40#include <rpc/rpc.h> | 46#include <rpc/rpc.h> |
47#include <rpc/pmap_clnt.h> |
|
41#include <syslog.h> 42#include <sys/types.h> 43#include <sys/wait.h> 44#include <signal.h> 45#include "statd.h" 46 | 48#include <syslog.h> 49#include <sys/types.h> 50#include <sys/wait.h> 51#include <signal.h> 52#include "statd.h" 53 |
47#ifndef lint 48static char rcsid[] = "$id: $"; 49#endif /* not lint */ 50 | |
51int debug = 0; /* Controls syslog() calls for debug messages */ 52 53extern void sm_prog_1(struct svc_req *rqstp, SVCXPRT *transp); 54static void handle_sigchld(); | 54int debug = 0; /* Controls syslog() calls for debug messages */ 55 56extern void sm_prog_1(struct svc_req *rqstp, SVCXPRT *transp); 57static void handle_sigchld(); |
58static void usage __P((void)); |
|
55 | 59 |
60int |
|
56main(int argc, char **argv) 57{ 58 SVCXPRT *transp; 59 struct sigaction sa; 60 61 if (argc > 1) 62 { 63 if (strcmp(argv[1], "-d")) | 61main(int argc, char **argv) 62{ 63 SVCXPRT *transp; 64 struct sigaction sa; 65 66 if (argc > 1) 67 { 68 if (strcmp(argv[1], "-d")) |
64 { 65 fprintf(stderr, "Usage: rpc.statd [-d]\n"); 66 exit(1); 67 } | 69 usage(); |
68 debug = 1; 69 } 70 71 (void)pmap_unset(SM_PROG, SM_VERS); 72 73 transp = svcudp_create(RPC_ANYSOCK); 74 if (transp == NULL) | 70 debug = 1; 71 } 72 73 (void)pmap_unset(SM_PROG, SM_VERS); 74 75 transp = svcudp_create(RPC_ANYSOCK); 76 if (transp == NULL) |
75 { 76 fprintf(stderr, "cannot create udp service.\n"); 77 exit(1); 78 } | 77 errx(1, "cannot create udp service"); |
79 if (!svc_register(transp, SM_PROG, SM_VERS, sm_prog_1, IPPROTO_UDP)) | 78 if (!svc_register(transp, SM_PROG, SM_VERS, sm_prog_1, IPPROTO_UDP)) |
80 { 81 fprintf(stderr, "unable to register (SM_PROG, SM_VERS, udp).\n"); 82 exit(1); 83 } | 79 errx(1, "unable to register (SM_PROG, SM_VERS, udp)"); |
84 85 transp = svctcp_create(RPC_ANYSOCK, 0, 0); 86 if (transp == NULL) | 80 81 transp = svctcp_create(RPC_ANYSOCK, 0, 0); 82 if (transp == NULL) |
87 { 88 fprintf(stderr, "cannot create tcp service.\n"); 89 exit(1); 90 } 91 if (!svc_register(transp, SM_PROG, SM_VERS, sm_prog_1, IPPROTO_TCP)) { 92 fprintf(stderr, "unable to register (SM_PROG, SM_VERS, tcp).\n"); 93 exit(1); 94 } | 83 errx(1, "cannot create tcp service"); 84 if (!svc_register(transp, SM_PROG, SM_VERS, sm_prog_1, IPPROTO_TCP)) 85 errx(1, "unable to register (SM_PROG, SM_VERS, tcp)"); |
95 init_file("/var/db/statd.status"); 96 97 /* Note that it is NOT sensible to run this program from inetd - the */ 98 /* protocol assumes that it will run immediately at boot time. */ 99 daemon(0, 0); 100 openlog("rpc.statd", 0, LOG_DAEMON); 101 if (debug) syslog(LOG_INFO, "Starting - debug enabled"); 102 else syslog(LOG_INFO, "Starting"); --- 8 unchanged lines hidden (view full) --- 111 /* Initialisation now complete - start operating */ 112 notify_hosts(); /* Forks a process (if necessary) to do the */ 113 /* SM_NOTIFY calls, which may be slow. */ 114 115 svc_run(); /* Should never return */ 116 exit(1); 117} 118 | 86 init_file("/var/db/statd.status"); 87 88 /* Note that it is NOT sensible to run this program from inetd - the */ 89 /* protocol assumes that it will run immediately at boot time. */ 90 daemon(0, 0); 91 openlog("rpc.statd", 0, LOG_DAEMON); 92 if (debug) syslog(LOG_INFO, "Starting - debug enabled"); 93 else syslog(LOG_INFO, "Starting"); --- 8 unchanged lines hidden (view full) --- 102 /* Initialisation now complete - start operating */ 103 notify_hosts(); /* Forks a process (if necessary) to do the */ 104 /* SM_NOTIFY calls, which may be slow. */ 105 106 svc_run(); /* Should never return */ 107 exit(1); 108} 109 |
110static void 111usage() 112{ 113 fprintf(stderr, "usage: rpc.statd [-d]\n"); 114 exit(1); 115} |
|
119 120/* handle_sigchld ---------------------------------------------------------- */ 121/* 122 Purpose: Catch SIGCHLD and collect process status 123 Retruns: Nothing. 124 Notes: No special action required, other than to collect the 125 process status and hence allow the child to die: 126 we only use child processes for asynchronous transmission --- 17 unchanged lines hidden --- | 116 117/* handle_sigchld ---------------------------------------------------------- */ 118/* 119 Purpose: Catch SIGCHLD and collect process status 120 Retruns: Nothing. 121 Notes: No special action required, other than to collect the 122 process status and hence allow the child to die: 123 we only use child processes for asynchronous transmission --- 17 unchanged lines hidden --- |