RPCGEN modification for use with inetd(8)
Danny Backx
dannyb at kulcs.uucp
Thu Jun 16 21:00:50 AEST 1988
The RPCGEN compiler provided with SUNRPC 3.9 does not allow writing servers
suitable for use with inetd(8).
The changes that have to be applied to rpcgen's output are minimal, though.
(See the manual pages for inetd).
The diffs provided here are minimal changes to the original rpcgen,
in order to generate C programs for use with inetd directly.
An option "-i" is added to rpcgen. If invoked, the generated programs are
slightly different.
No fundamentals in rpcgen's internals are changed. (Only a few printf's).
The diffs are listed below.
I used this for making a TCP-based server.
If you do this, beware !
Your server should contain code to kill itself after it has provided you
with the last answer.
In my case, this means that the end of one of my service routines
looks like this:
%% #ifdef INETD
%% alarm(5);
%% signal(SIGALRM, exit);
%% #endif INETD
%%
%% res = 1 ;
%% return &res ;
%% }
<<< diff for rpc_main.c >>>
53a54
> int iflag;
64a66
> static int inetd = 0;
75c77
< "usage: %s infile\n", cmdname);
---
> "usage: %s [-i] infile\n", cmdname);
77c79
< " %s [-c | -h | -l | -m] [-o outfile] [infile]\n",
---
> " %s [-i] [-c | -h | -l | -m] [-o outfile] [infile]\n",
80c82
< " %s [-s udp|tcp]* [-o outfile] [infile]\n",
---
> " %s [-i] [-s udp|tcp]* [-o outfile] [infile]\n",
83a86,87
> if (cmd.iflag)
> inetd = 1;
285c289
< write_most();
---
> write_most(inetd);
337c341
< write_register(argv[i + 1]);
---
> write_register(argv[i + 1], inetd);
369a374
> flag['i'] = 0;
383a389
> case 'i':
424a431
> cmd->iflag = flag['i'];
<<< diff for rpc_svcout.c >>>
54c54,55
< write_most()
---
> write_most(inetd)
> int inetd;
74a76,79
>
> if (inetd)
> return; /* only 'pmap_unset' behind this */
>
91c96
< write_register(transp)
---
> write_register(transp, inetd)
92a98
> int inetd;
99c105,108
< f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
---
> if (inetd)
> f_print(fout, "\t%s = svc%s_create(0", TRANSP, transp);
> else
> f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
119,120c128,132
< f_print(fout, ", IPPROTO_%s)) {\n",
< streq(transp, "udp") ? "UDP" : "TCP");
---
> if (inetd)
> f_print(fout, ", 0)) {\n");
> else
> f_print(fout, ", IPPROTO_%s)) {\n",
> streq(transp, "udp") ? "UDP" : "TCP");
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Danny Backx | mail: Katholieke Universiteit Leuven
Tel: +32 16 200656 x 3544 | Dept. Computer Science
E-mail: dannyb at kulcs.UUCP | Celestijnenlaan 200 A
... mcvax!prlb2!kulcs!dannyb | B-3030 Leuven
dannyb at blekul60.BITNET | Belgium
More information about the Comp.sources.bugs
mailing list