Warner Losh <i...@village.org> writes:
> Or getservbyname (which is really what you'd want to change).  I have
> patches to inetd that I've enclosed here.  They are gorss, but the
> code itself doesn't lend itself to non-gross patches w/o some rework,
> which I was too lazy to do this morning.

Or you might as well fix it for RPCs at the same time.

/assar

--- inetd.c.orig        Mon Aug  2 22:35:28 1999
+++ inetd.c     Mon Aug  2 22:41:52 1999
@@ -830,34 +830,50 @@
                        continue;
                }
                if (!sep->se_rpc) {
+                       int port;
+
                        sp = getservbyname(sep->se_service, sep->se_proto);
                        if (sp == 0) {
-                               syslog(LOG_ERR, "%s/%s: unknown service",
+                               port = htons(strtol (sep->se_service,
+                                                    NULL, 0));
+                               if (port == 0) {
+                                       syslog(LOG_ERR,
+                                              "%s/%s: unknown service",
                                sep->se_service, sep->se_proto);
                                sep->se_checked = 0;
                                continue;
                        }
-                       if (sp->s_port != sep->se_ctrladdr.sin_port) {
+                       } else
+                               port = sp->s_port;
+                       if (port != sep->se_ctrladdr.sin_port) {
                                sep->se_ctrladdr.sin_family = AF_INET;
                                sep->se_ctrladdr.sin_addr = bind_address;
-                               sep->se_ctrladdr.sin_port = sp->s_port;
+                               sep->se_ctrladdr.sin_port = port;
                                if (sep->se_fd >= 0)
                                        close_sep(sep);
                        }
                } else {
+                       int rpc_number;
+
                        rpc = getrpcbyname(sep->se_service);
                        if (rpc == 0) {
-                               syslog(LOG_ERR, "%s/%s unknown RPC service.",
+                               rpc_number = strtol (sep->se_service,
+                                                    NULL, 0);
+                               if (rpc_number == 0) {
+                                       syslog(LOG_ERR,
+                                              "%s/%s unknown RPC service.",
                                        sep->se_service, sep->se_proto);
                                if (sep->se_fd != -1)
                                        (void) close(sep->se_fd);
                                sep->se_fd = -1;
                                        continue;
                        }
-                       if (rpc->r_number != sep->se_rpc_prog) {
+                       } else
+                               rpc_number = sep->se_rpc_prog;
+                       if (rpc_number != sep->se_rpc_prog) {
                                if (sep->se_rpc_prog)
                                        unregisterrpc(sep);
-                               sep->se_rpc_prog = rpc->r_number;
+                               sep->se_rpc_prog = rpc_number;
                                if (sep->se_fd != -1)
                                        (void) close(sep->se_fd);
                                sep->se_fd = -1;


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to