Deleted Added
full compact
ypxfrd_main.c (24428) ypxfrd_main.c (30378)
1/*
2 * Copyright (c) 1995, 1996
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

--- 14 unchanged lines hidden (view full) ---

23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
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.
1/*
2 * Copyright (c) 1995, 1996
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

--- 14 unchanged lines hidden (view full) ---

23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
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: ypxfrd_main.c,v 1.4 1997/03/11 15:56:48 peter Exp $
33 */
34
31 */
32
33#ifndef lint
34static const char rcsid[] =
35 "$Id$";
36#endif /* not lint */
37
35#include "ypxfrd.h"
38#include "ypxfrd.h"
39#include <err.h>
40#include <fcntl.h>
36#include <stdio.h>
37#include <stdlib.h> /* getenv, exit */
38#include <unistd.h>
39#include <rpc/pmap_clnt.h> /* for pmap_unset */
40#include <string.h> /* strcmp */
41#include <signal.h>
42#include <sys/ttycom.h> /* TIOCNOTTY */
43#ifdef __cplusplus

--- 11 unchanged lines hidden (view full) ---

55#define SIG_PF void(*)(int)
56#endif
57
58#ifdef DEBUG
59#define RPC_SVC_FG
60#endif
61
62#define _RPCSVC_CLOSEDOWN 120
41#include <stdio.h>
42#include <stdlib.h> /* getenv, exit */
43#include <unistd.h>
44#include <rpc/pmap_clnt.h> /* for pmap_unset */
45#include <string.h> /* strcmp */
46#include <signal.h>
47#include <sys/ttycom.h> /* TIOCNOTTY */
48#ifdef __cplusplus

--- 11 unchanged lines hidden (view full) ---

60#define SIG_PF void(*)(int)
61#endif
62
63#ifdef DEBUG
64#define RPC_SVC_FG
65#endif
66
67#define _RPCSVC_CLOSEDOWN 120
63#ifndef lint
64static const char rcsid[] = "$Id: ypxfrd_main.c,v 1.4 1997/03/11 15:56:48 peter Exp $";
65#endif /* not lint */
66int _rpcpmstart; /* Started by a port monitor ? */
67static int _rpcfdtype;
68 /* Whether Stream or Datagram ? */
69 /* States a server can be in wrt request */
70
71#define _IDLE 0
72#define _SERVED 1
73#define _SERVING 2

--- 5 unchanged lines hidden (view full) ---

79
80static
81void _msgout(char* msg)
82{
83#ifdef RPC_SVC_FG
84 if (_rpcpmstart)
85 syslog(LOG_ERR, msg);
86 else
68int _rpcpmstart; /* Started by a port monitor ? */
69static int _rpcfdtype;
70 /* Whether Stream or Datagram ? */
71 /* States a server can be in wrt request */
72
73#define _IDLE 0
74#define _SERVED 1
75#define _SERVING 2

--- 5 unchanged lines hidden (view full) ---

81
82static
83void _msgout(char* msg)
84{
85#ifdef RPC_SVC_FG
86 if (_rpcpmstart)
87 syslog(LOG_ERR, msg);
88 else
87 (void) fprintf(stderr, "%s\n", msg);
89 warnx("%s", msg);
88#else
89 syslog(LOG_ERR, msg);
90#endif
91}
92
93static void
94closedown(int sig)
95{

--- 43 unchanged lines hidden (view full) ---

139 readfds = svc_fds;
140#endif /* def FD_SETSIZE */
141 switch (select(fd_setsize, &readfds, NULL, NULL,
142 (struct timeval *)0)) {
143 case -1:
144 if (errno == EINTR) {
145 continue;
146 }
90#else
91 syslog(LOG_ERR, msg);
92#endif
93}
94
95static void
96closedown(int sig)
97{

--- 43 unchanged lines hidden (view full) ---

141 readfds = svc_fds;
142#endif /* def FD_SETSIZE */
143 switch (select(fd_setsize, &readfds, NULL, NULL,
144 (struct timeval *)0)) {
145 case -1:
146 if (errno == EINTR) {
147 continue;
148 }
147 perror("svc_run: - select failed");
149 warn("svc_run: - select failed");
148 return;
149 case 0:
150 continue;
151 default:
152 svc_getreqset(&readfds);
153 if (forked && pid != getpid())
154 exit(0);
155 }

--- 16 unchanged lines hidden (view full) ---

172 } else {
173 (void) pmap_unset(YPXFRD_FREEBSD_PROG, YPXFRD_FREEBSD_VERS);
174 exit(0);
175 }
176}
177
178void usage()
179{
150 return;
151 case 0:
152 continue;
153 default:
154 svc_getreqset(&readfds);
155 if (forked && pid != getpid())
156 exit(0);
157 }

--- 16 unchanged lines hidden (view full) ---

174 } else {
175 (void) pmap_unset(YPXFRD_FREEBSD_PROG, YPXFRD_FREEBSD_VERS);
176 exit(0);
177 }
178}
179
180void usage()
181{
180 fprintf(stderr, "%s [-p path]\n", progname);
182 fprintf(stderr, "usage: rpc.ypxfrd [-p path]\n");
181 exit(0);
182}
183
183 exit(0);
184}
185
186int
184main(argc, argv)
185 int argc;
186 char *argv[];
187{
187main(argc, argv)
188 int argc;
189 char *argv[];
190{
188 register SVCXPRT *transp;
191 register SVCXPRT *transp = NULL;
189 int sock;
192 int sock;
190 int proto;
193 int proto = 0;
191 struct sockaddr_in saddr;
192 int asize = sizeof (saddr);
193 int ch;
194
195 while ((ch = getopt(argc, argv, "p:h")) != -1) {
196 switch(ch) {
197 case 'p':
198 yp_dir = optarg;

--- 19 unchanged lines hidden (view full) ---

218 proto = 0;
219 openlog("rpc.ypxfrd", LOG_PID, LOG_DAEMON);
220 } else {
221#ifndef RPC_SVC_FG
222 int size;
223 int pid, i;
224
225 pid = fork();
194 struct sockaddr_in saddr;
195 int asize = sizeof (saddr);
196 int ch;
197
198 while ((ch = getopt(argc, argv, "p:h")) != -1) {
199 switch(ch) {
200 case 'p':
201 yp_dir = optarg;

--- 19 unchanged lines hidden (view full) ---

221 proto = 0;
222 openlog("rpc.ypxfrd", LOG_PID, LOG_DAEMON);
223 } else {
224#ifndef RPC_SVC_FG
225 int size;
226 int pid, i;
227
228 pid = fork();
226 if (pid < 0) {
227 perror("cannot fork");
228 exit(1);
229 }
229 if (pid < 0)
230 err(1, "fork");
230 if (pid)
231 exit(0);
232 size = getdtablesize();
233 for (i = 0; i < size; i++)
234 (void) close(i);
235 i = open("/dev/console", 2);
236 (void) dup2(i, 1);
237 (void) dup2(i, 2);

--- 59 unchanged lines hidden ---
231 if (pid)
232 exit(0);
233 size = getdtablesize();
234 for (i = 0; i < size; i++)
235 (void) close(i);
236 i = open("/dev/console", 2);
237 (void) dup2(i, 1);
238 (void) dup2(i, 2);

--- 59 unchanged lines hidden ---