yp_main.c (14240) | yp_main.c (14262) |
---|---|
1/* 2 * Copyright (c) 1995 3 * Bill Paul <wpaul@ctr.columbia.edu>. 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 1/* 2 * Copyright (c) 1995 3 * Bill Paul <wpaul@ctr.columbia.edu>. 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $Id: yp_main.c,v 1.2 1995/12/23 21:35:32 wpaul Exp $ | 32 * $Id: yp_main.c,v 1.1 1996/02/25 19:29:34 wpaul Exp $ |
33 */ 34 35/* 36 * ypserv startup function. 37 * We need out own main() since we have to do some additional work 38 * that rpcgen won't do for us. Most of this file was generated using 39 * rpcgen.new, and later modified. 40 */ --- 19 unchanged lines hidden (view full) --- 60#include <errno.h> 61 62#ifndef SIG_PF 63#define SIG_PF void(*)(int) 64#endif 65 66#define _RPCSVC_CLOSEDOWN 120 67#ifndef lint | 33 */ 34 35/* 36 * ypserv startup function. 37 * We need out own main() since we have to do some additional work 38 * that rpcgen won't do for us. Most of this file was generated using 39 * rpcgen.new, and later modified. 40 */ --- 19 unchanged lines hidden (view full) --- 60#include <errno.h> 61 62#ifndef SIG_PF 63#define SIG_PF void(*)(int) 64#endif 65 66#define _RPCSVC_CLOSEDOWN 120 67#ifndef lint |
68static char rcsid[] = "$Id: yp_main.c,v 1.2 1995/12/23 21:35:32 wpaul Exp $"; | 68static char rcsid[] = "$Id: yp_main.c,v 1.1 1996/02/25 19:29:34 wpaul Exp $"; |
69#endif /* not lint */ 70int _rpcpmstart; /* Started by a port monitor ? */ 71static int _rpcfdtype; 72 /* Whether Stream or Datagram ? */ 73 /* States a server can be in wrt request */ 74 75#define _IDLE 0 76#define _SERVED 1 77#define _SERVING 2 78 | 69#endif /* not lint */ 70int _rpcpmstart; /* Started by a port monitor ? */ 71static int _rpcfdtype; 72 /* Whether Stream or Datagram ? */ 73 /* States a server can be in wrt request */ 74 75#define _IDLE 0 76#define _SERVED 1 77#define _SERVING 2 78 |
79extern void ypprog_1 __P((struct svc_req, register SVCXPRT)); |
|
79extern void ypprog_2 __P((struct svc_req, register SVCXPRT)); 80extern int _rpc_dtablesize __P((void)); 81extern int _rpcsvcstate; /* Set when a request is serviced */ 82char *progname = "ypserv"; 83char *yp_dir = _PATH_YP; 84int debug = 0; 85int do_dns = 0; | 80extern void ypprog_2 __P((struct svc_req, register SVCXPRT)); 81extern int _rpc_dtablesize __P((void)); 82extern int _rpcsvcstate; /* Set when a request is serviced */ 83char *progname = "ypserv"; 84char *yp_dir = _PATH_YP; 85int debug = 0; 86int do_dns = 0; |
86int sunos_4_kludge = 0; | |
87 88static 89void _msgout(char* msg) 90{ 91 if (debug) { 92 if (_rpcpmstart) 93 syslog(LOG_ERR, msg); 94 else --- 38 unchanged lines hidden (view full) --- 133 exit(0); 134 } 135 } 136} 137 138static void unregister() 139{ 140 (void) pmap_unset(YPPROG, YPVERS); | 87 88static 89void _msgout(char* msg) 90{ 91 if (debug) { 92 if (_rpcpmstart) 93 syslog(LOG_ERR, msg); 94 else --- 38 unchanged lines hidden (view full) --- 133 exit(0); 134 } 135 } 136} 137 138static void unregister() 139{ 140 (void) pmap_unset(YPPROG, YPVERS); |
141 if (sunos_4_kludge) 142 (void) pmap_unset(YPPROG, 1); | 141 (void) pmap_unset(YPPROG, YPOLDVERS); |
143} 144 145static void reaper(sig) 146 int sig; 147{ 148 int status; 149 150 if (sig == SIGHUP) { --- 7 unchanged lines hidden (view full) --- 158 } else { 159 unregister(); 160 exit(0); 161 } 162} 163 164static void usage() 165{ | 142} 143 144static void reaper(sig) 145 int sig; 146{ 147 int status; 148 149 if (sig == SIGHUP) { --- 7 unchanged lines hidden (view full) --- 157 } else { 158 unregister(); 159 exit(0); 160 } 161} 162 163static void usage() 164{ |
166 fprintf(stderr, "Usage: %s [-h] [-d] [-n] [-k] [-p path]\n", progname); | 165 fprintf(stderr, "Usage: %s [-h] [-d] [-n] [-p path]\n", progname); |
167 exit(1); 168} 169 170static void 171closedown(int sig) 172{ 173 if (_rpcsvcstate == _IDLE) { 174 extern fd_set svc_fdset; --- 28 unchanged lines hidden (view full) --- 203{ 204 register SVCXPRT *transp = NULL; 205 int sock; 206 int proto = 0; 207 struct sockaddr_in saddr; 208 int asize = sizeof (saddr); 209 int ch; 210 | 166 exit(1); 167} 168 169static void 170closedown(int sig) 171{ 172 if (_rpcsvcstate == _IDLE) { 173 extern fd_set svc_fdset; --- 28 unchanged lines hidden (view full) --- 202{ 203 register SVCXPRT *transp = NULL; 204 int sock; 205 int proto = 0; 206 struct sockaddr_in saddr; 207 int asize = sizeof (saddr); 208 int ch; 209 |
211 while ((ch = getopt(argc, argv, "hdnkp:")) != EOF) { | 210 while ((ch = getopt(argc, argv, "hdnp:")) != EOF) { |
212 switch(ch) { 213 case 'd': 214 debug = ypdb_debug = 1; 215 break; 216 case 'n': 217 do_dns = 1; 218 break; | 211 switch(ch) { 212 case 'd': 213 debug = ypdb_debug = 1; 214 break; 215 case 'n': 216 do_dns = 1; 217 break; |
219 case 'k': 220 sunos_4_kludge = 1; 221 break; | |
222 case 'p': 223 yp_dir = optarg; 224 break; 225 case 'h': 226 default: 227 usage(); 228 } 229 } --- 17 unchanged lines hidden (view full) --- 247 if (daemon(0,0)) { 248 perror("cannot fork"); 249 exit(1); 250 } 251 openlog(progname, LOG_PID, LOG_DAEMON); 252 } 253 sock = RPC_ANYSOCK; 254 (void) pmap_unset(YPPROG, YPVERS); | 218 case 'p': 219 yp_dir = optarg; 220 break; 221 case 'h': 222 default: 223 usage(); 224 } 225 } --- 17 unchanged lines hidden (view full) --- 243 if (daemon(0,0)) { 244 perror("cannot fork"); 245 exit(1); 246 } 247 openlog(progname, LOG_PID, LOG_DAEMON); 248 } 249 sock = RPC_ANYSOCK; 250 (void) pmap_unset(YPPROG, YPVERS); |
255 if (sunos_4_kludge) 256 (void) pmap_unset(YPPROG, 1); | 251 (void) pmap_unset(YPPROG, 1); |
257 } 258 | 252 } 253 |
259 if (sunos_4_kludge && ((_rpcfdtype == 0)||(_rpcfdtype == SOCK_DGRAM))) { | 254 if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) { |
260 transp = svcudp_create(sock); 261 if (transp == NULL) { 262 _msgout("cannot create udp service."); 263 exit(1); 264 } 265 if (!_rpcpmstart) 266 proto = IPPROTO_UDP; | 255 transp = svcudp_create(sock); 256 if (transp == NULL) { 257 _msgout("cannot create udp service."); 258 exit(1); 259 } 260 if (!_rpcpmstart) 261 proto = IPPROTO_UDP; |
267 if (!svc_register(transp, YPPROG, 1, ypprog_2, proto)) { 268 _msgout("unable to register (YPPROG, OLDYPVERS, udp)."); | 262 if (!svc_register(transp, YPPROG, YPOLDVERS, ypprog_1, proto)) { 263 _msgout("unable to register (YPPROG, YPOLDVERS, udp)."); |
269 exit(1); 270 } | 264 exit(1); 265 } |
271 } 272 273 if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) { 274 transp = svcudp_create(sock); 275 if (transp == NULL) { 276 _msgout("cannot create udp service."); 277 exit(1); 278 } 279 if (!_rpcpmstart) 280 proto = IPPROTO_UDP; | |
281 if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) { 282 _msgout("unable to register (YPPROG, YPVERS, udp)."); 283 exit(1); 284 } 285 } 286 287 if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) { 288 transp = svctcp_create(sock, 0, 0); 289 if (transp == NULL) { 290 _msgout("cannot create tcp service."); 291 exit(1); 292 } 293 if (!_rpcpmstart) 294 proto = IPPROTO_TCP; | 266 if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) { 267 _msgout("unable to register (YPPROG, YPVERS, udp)."); 268 exit(1); 269 } 270 } 271 272 if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) { 273 transp = svctcp_create(sock, 0, 0); 274 if (transp == NULL) { 275 _msgout("cannot create tcp service."); 276 exit(1); 277 } 278 if (!_rpcpmstart) 279 proto = IPPROTO_TCP; |
280 if (!svc_register(transp, YPPROG, YPOLDVERS, ypprog_1, proto)) { 281 _msgout("unable to register (YPPROG, YPOLDVERS, tcp)."); 282 exit(1); 283 } |
|
295 if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) { 296 _msgout("unable to register (YPPROG, YPVERS, tcp)."); 297 exit(1); 298 } 299 } 300 301 if (transp == (SVCXPRT *)NULL) { 302 _msgout("could not create a handle"); --- 20 unchanged lines hidden --- | 284 if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) { 285 _msgout("unable to register (YPPROG, YPVERS, tcp)."); 286 exit(1); 287 } 288 } 289 290 if (transp == (SVCXPRT *)NULL) { 291 _msgout("could not create a handle"); --- 20 unchanged lines hidden --- |