NetBSD Problem Report #10275
Received: (qmail 666 invoked from network); 4 Jun 2000 04:46:30 -0000
Message-Id: <200006040437.e544bfa28179@frau-farbissina.shagadelic.org>
Date: Sat, 3 Jun 2000 21:37:41 -0700 (PDT)
From: Jason R Thorpe <thorpej@frau-farbissina.shagadelic.org>
Reply-To: thorpej@frau-farbissina.shagadelic.org
To: gnats-bugs@gnats.netbsd.org
Subject: TI-RPC failure without /etc/netconfig is obtuse
X-Send-Pr-Version: 3.95
>Number: 10275
>Category: lib
>Synopsis: TI-RPC failure without /etc/netconfig is obtuse
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: assar
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Jun 04 04:47:00 +0000 2000
>Closed-Date: Sun Jun 11 16:29:09 +0000 2000
>Last-Modified: Sun Jun 11 16:29:09 +0000 2000
>Originator:
>Release: Sat Jun 3 21:34:02 PDT 2000
>Organization:
6th and Hugo Software
>Environment:
System: NetBSD frau-farbissina 1.4Z NetBSD 1.4Z (FRAU-FARBISSINA) #21: Sat Jun 3 20:05:37 PDT 2000 thorpej@frau-farbissina:/u2/netbsd/src/sys/arch/alpha/compile/FRAU-FARBISSINA alpha
>Description:
The new TI-RPC code works on LP64 systems (albiet lint(1) complains
about several things while building it), tho at first I thought it
didn't, because I had forgotten to install /etc/netconfig.
It might be nice if when /etc/netconfig is missing, instead
of:
frau-farbissina:thorpej 38$ su
clntudp_create: RPC: Unknown protocol
clnttcp_create: RPC: Unknown protocol
clntudp_create: RPC: Unknown protocol
clnttcp_create: RPC: Unknown protocol
clntudp_create: RPC: Unknown protocol
clnttcp_create: RPC: Unknown protocol
su: who are you?
A warning like:
WARNING: /etc/netconfig missing
could be issued, perhaps even with a fallback to some "reasonable"
set of defaults (tho if the warning were there, it would be
immediately obvious how to solve the problem).
Anyhow, it took me by surprise, so I could imagine it could
take others by surprise, too.
>How-To-Repeat:
Attempt to use TI-RPC with a missing /etc/netconfig.
>Fix:
Not provided.
>Release-Note:
>Audit-Trail:
From: Assar Westerlund <assar@sics.se>
To: thorpej@frau-farbissina.shagadelic.org
Cc: fvdl@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: 08 Jun 2000 04:15:56 +0200
Jason R Thorpe <thorpej@frau-farbissina.shagadelic.org> writes:
> >Description:
> The new TI-RPC code works on LP64 systems (albiet lint(1) complains
> about several things while building it), tho at first I thought it
> didn't, because I had forgotten to install /etc/netconfig.
I agree, failing because of lack of a configuration file is not
especially nice behavior.
What about something like the following, or is that too ugly?
/assar
Index: getnetconfig.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/getnetconfig.c,v
retrieving revision 1.1
diff -u -w -u -w -r1.1 getnetconfig.c
--- getnetconfig.c 2000/06/02 23:11:11 1.1
+++ getnetconfig.c 2000/06/08 02:11:14
@@ -171,6 +171,29 @@
#endif
}
+static const char default_netconfig[] =
+"udp6 tpi_clts v inet6 udp - -\n"
+"tcp6 tpi_cots_ord v inet6 tcp - -\n"
+"udp tpi_clts v inet udp - -\n"
+"tcp tpi_cots_ord v inet tcp - -\n"
+"rawip tpi_raw - inet - - -\n"
+"local tpi_cots_ord - loopback - - -\n";
+
+static int
+default_readfn (void *cookie, char *buf, int len)
+{
+ int *pos = (int *)cookie;
+ int rem = sizeof(default_netconfig) - 1 - *pos;
+
+ if (len > rem)
+ len = rem;
+ memcpy (buf, default_netconfig + *pos, len);
+ *pos += len;
+ return len;
+}
+
+static int default_pos;
+
#define nc_error (*(__nc_error()))
/*
* A call to setnetconfig() establishes a /etc/netconfig "session". A session
@@ -206,11 +229,17 @@
* handle without reopening the netconfig db.
*/
ni.ref++;
- if ((nc_file != NULL) || (nc_file = fopen(NETCONFIG, "r")) != NULL) {
+ if (nc_file != NULL) {
+ if((nc_file = fopen(NETCONFIG, "r")) == NULL) {
+ default_pos = 0;
+ nc_file = fropen (&default_pos, default_readfn);
+ }
+ if (nc_file != NULL) {
nc_vars->valid = NC_VALID;
nc_vars->flag = 0;
nc_vars->nc_configs = ni.head;
return ((void *)nc_vars);
+ }
}
ni.ref--;
nc_error = NC_NONETCONFIG;
From: Assar Westerlund <assar@sics.se>
To: thorpej@shagadelic.org
Cc: fvdl@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: 08 Jun 2000 04:15:56 +0200
Jason R Thorpe <thorpej@frau-farbissina.shagadelic.org> writes:
> >Description:
> The new TI-RPC code works on LP64 systems (albiet lint(1) complains
> about several things while building it), tho at first I thought it
> didn't, because I had forgotten to install /etc/netconfig.
I agree, failing because of lack of a configuration file is not
especially nice behavior.
What about something like the following, or is that too ugly?
/assar
Index: getnetconfig.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/getnetconfig.c,v
retrieving revision 1.1
diff -u -w -u -w -r1.1 getnetconfig.c
--- getnetconfig.c 2000/06/02 23:11:11 1.1
+++ getnetconfig.c 2000/06/08 02:11:14
@@ -171,6 +171,29 @@
#endif
}
+static const char default_netconfig[] =
+"udp6 tpi_clts v inet6 udp - -\n"
+"tcp6 tpi_cots_ord v inet6 tcp - -\n"
+"udp tpi_clts v inet udp - -\n"
+"tcp tpi_cots_ord v inet tcp - -\n"
+"rawip tpi_raw - inet - - -\n"
+"local tpi_cots_ord - loopback - - -\n";
+
+static int
+default_readfn (void *cookie, char *buf, int len)
+{
+ int *pos = (int *)cookie;
+ int rem = sizeof(default_netconfig) - 1 - *pos;
+
+ if (len > rem)
+ len = rem;
+ memcpy (buf, default_netconfig + *pos, len);
+ *pos += len;
+ return len;
+}
+
+static int default_pos;
+
#define nc_error (*(__nc_error()))
/*
* A call to setnetconfig() establishes a /etc/netconfig "session". A session
@@ -206,11 +229,17 @@
* handle without reopening the netconfig db.
*/
ni.ref++;
- if ((nc_file != NULL) || (nc_file = fopen(NETCONFIG, "r")) != NULL) {
+ if (nc_file != NULL) {
+ if((nc_file = fopen(NETCONFIG, "r")) == NULL) {
+ default_pos = 0;
+ nc_file = fropen (&default_pos, default_readfn);
+ }
+ if (nc_file != NULL) {
nc_vars->valid = NC_VALID;
nc_vars->flag = 0;
nc_vars->nc_configs = ni.head;
return ((void *)nc_vars);
+ }
}
ni.ref--;
nc_error = NC_NONETCONFIG;
From: Jason R Thorpe <thorpej@zembu.com>
To: Assar Westerlund <assar@sics.se>
Cc: fvdl@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: Wed, 7 Jun 2000 19:22:05 -0700
On Thu, Jun 08, 2000 at 04:15:56AM +0200, Assar Westerlund wrote:
> Jason R Thorpe <thorpej@frau-farbissina.shagadelic.org> writes:
> > >Description:
> > The new TI-RPC code works on LP64 systems (albiet lint(1) complains
> > about several things while building it), tho at first I thought it
> > didn't, because I had forgotten to install /etc/netconfig.
>
> I agree, failing because of lack of a configuration file is not
> especially nice behavior.
>
> What about something like the following, or is that too ugly?
That looks okay to me... maybe it should warn that /etc/netconfig is
not present?
--
-- Jason R. Thorpe <thorpej@zembu.com>
From: Assar Westerlund <assar@sics.se>
To: thorpej@zembu.com
Cc: fvdl@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: 08 Jun 2000 04:31:48 +0200
Jason R Thorpe <thorpej@zembu.com> writes:
> On Thu, Jun 08, 2000 at 04:15:56AM +0200, Assar Westerlund wrote:
> > I agree, failing because of lack of a configuration file is not
> > especially nice behavior.
> >
> > What about something like the following, or is that too ugly?
>
> That looks okay to me... maybe it should warn that /etc/netconfig is
> not present?
That makes sense, otherwise nobody will bother fixing it. How is it
supposed to warning from within rpc*? syslog? There seems to be a
nc_perror there which I can't see any use of, but just writing to
stderr does not strike me as the right thing. Frank?
/assar
From: Frank van der Linden <frank@wins.uva.nl>
To: Assar Westerlund <assar@sics.se>
Cc: thorpej@shagadelic.org, fvdl@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: Thu, 8 Jun 2000 10:05:55 +0200
On Thu, Jun 08, 2000 at 04:15:56AM +0200, Assar Westerlund wrote:
> I agree, failing because of lack of a configuration file is not
> especially nice behavior.
>
> What about something like the following, or is that too ugly?
Err. This would set a disturbing trend. What about getrpcent
and /etc/rpc? What about getservby* and /etc/services? What about
get host name resolving, without DNS, and /etc/hosts? Should
we provide defaults for all of them? They all fail when
the file is not there, after all.
I'm really firmly opposed against this change, because it sets
a bad precedent. Some things need configuration files, and when
they're not there, they will fail. That's not unusual.. no
need to kludge default tables into the library.
Now, if you say that there should be some kind of logged error message,
I could agree to that. From within the RPC library one level up,
not in getnetconfig*
- Frank
From: Assar Westerlund <assar@sics.se>
To: Frank van der Linden <frank@wins.uva.nl>
Cc: thorpej@shagadelic.org, fvdl@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: 10 Jun 2000 09:13:49 +0200
Frank van der Linden <frank@wins.uva.nl> writes:
> Now, if you say that there should be some kind of logged error message,
> I could agree to that. From within the RPC library one level up,
> not in getnetconfig*
Like this then?
/assar
Index: getnetpath.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/getnetpath.c,v
retrieving revision 1.1
diff -u -w -r1.1 getnetpath.c
--- getnetpath.c 2000/06/02 23:11:11 1.1
+++ getnetpath.c 2000/06/10 07:13:13
@@ -46,6 +46,7 @@
#include <netconfig.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#ifdef __weak_alias
__weak_alias(getnetpath,_getnetpath)
@@ -102,6 +103,7 @@
return (NULL);
}
if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) {
+ syslog (LOG_ERR, "rpc: failed to open /etc/netconfig");
return (NULL);
}
np_sessionp->valid = NP_VALID;
@@ -158,6 +160,8 @@
do { /* select next visible network */
if (np_sessionp->nc_handlep == NULL) {
np_sessionp->nc_handlep = setnetconfig();
+ if (np_sessionp->nc_handlep == NULL)
+ syslog (LOG_ERR, "rpc: failed to open /etc/netconfig");
}
if ((ncp = getnetconfig(np_sessionp->nc_handlep)) == NULL) {
return(NULL);
Index: rpc_generic.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/rpc_generic.c,v
retrieving revision 1.1
diff -u -w -r1.1 rpc_generic.c
--- rpc_generic.c 2000/06/02 23:11:13 1.1
+++ rpc_generic.c 2000/06/10 07:13:14
@@ -53,6 +53,7 @@
#include <netconfig.h>
#include <malloc.h>
#include <string.h>
+#include <syslog.h>
#include <rpc/nettype.h>
#include "rpc_com.h"
@@ -251,6 +252,7 @@
void *confighandle;
if (!(confighandle = setnetconfig())) {
+ syslog (LOG_ERR, "rpc: failed to open /etc/netconfig");
return (NULL);
}
while ((nconf = getnetconfig(confighandle))) {
@@ -327,6 +329,7 @@
case _RPC_TCP:
case _RPC_UDP:
if (!(handle->nhandle = setnetconfig())) {
+ syslog (LOG_ERR, "rpc: failed to open /etc/netconfig");
free(handle);
return (NULL);
}
Index: rpcb_clnt.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/rpcb_clnt.c,v
retrieving revision 1.2
diff -u -w -r1.2 rpcb_clnt.c
--- rpcb_clnt.c 2000/06/07 21:46:01 1.2
+++ rpcb_clnt.c 2000/06/10 07:13:14
@@ -67,6 +67,7 @@
#include <string.h>
#include <unistd.h>
#include <netdb.h>
+#include <syslog.h>
#include "rpc_com.h"
@@ -458,6 +459,8 @@
nc_handle = setnetconfig();
if (nc_handle == NULL) {
/* fails to open netconfig file */
+ syslog (LOG_ERR,
+ "rpc: failed to open /etc/netconfig");
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
mutex_unlock(&loopnconf_lock);
return (NULL);
From: Jason R Thorpe <thorpej@zembu.com>
To: Assar Westerlund <assar@sics.se>
Cc: Frank van der Linden <frank@wins.uva.nl>, fvdl@netbsd.org,
gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: Sat, 10 Jun 2000 09:44:46 -0700
On Sat, Jun 10, 2000 at 09:13:49AM +0200, Assar Westerlund wrote:
> Like this then?
Should use _PATH_NETCONFIG I guess... (Is that in <paths.h>?)
--
-- Jason R. Thorpe <thorpej@zembu.com>
From: Assar Westerlund <assar@sics.se>
To: thorpej@zembu.com
Cc: Frank van der Linden <frank@wins.uva.nl>, fvdl@netbsd.org,
gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: 10 Jun 2000 20:14:32 +0200
Jason R Thorpe <thorpej@zembu.com> writes:
> Should use _PATH_NETCONFIG I guess... (Is that in <paths.h>?)
There's a NETCONFIG in <netconfig.h> so I used that instead. Frank,
this ok with you?
/assar
Index: getnetpath.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/getnetpath.c,v
retrieving revision 1.1
diff -u -w -r1.1 getnetpath.c
--- getnetpath.c 2000/06/02 23:11:11 1.1
+++ getnetpath.c 2000/06/10 18:12:54
@@ -46,6 +46,7 @@
#include <netconfig.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#ifdef __weak_alias
__weak_alias(getnetpath,_getnetpath)
@@ -102,6 +103,7 @@
return (NULL);
}
if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) {
+ syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
return (NULL);
}
np_sessionp->valid = NP_VALID;
@@ -158,6 +160,8 @@
do { /* select next visible network */
if (np_sessionp->nc_handlep == NULL) {
np_sessionp->nc_handlep = setnetconfig();
+ if (np_sessionp->nc_handlep == NULL)
+ syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
}
if ((ncp = getnetconfig(np_sessionp->nc_handlep)) == NULL) {
return(NULL);
Index: rpc_generic.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/rpc_generic.c,v
retrieving revision 1.1
diff -u -w -r1.1 rpc_generic.c
--- rpc_generic.c 2000/06/02 23:11:13 1.1
+++ rpc_generic.c 2000/06/10 18:12:54
@@ -53,6 +53,7 @@
#include <netconfig.h>
#include <malloc.h>
#include <string.h>
+#include <syslog.h>
#include <rpc/nettype.h>
#include "rpc_com.h"
@@ -251,6 +252,7 @@
void *confighandle;
if (!(confighandle = setnetconfig())) {
+ syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
return (NULL);
}
while ((nconf = getnetconfig(confighandle))) {
@@ -327,6 +329,7 @@
case _RPC_TCP:
case _RPC_UDP:
if (!(handle->nhandle = setnetconfig())) {
+ syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
free(handle);
return (NULL);
}
Index: rpcb_clnt.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/rpc/rpcb_clnt.c,v
retrieving revision 1.2
diff -u -w -r1.2 rpcb_clnt.c
--- rpcb_clnt.c 2000/06/07 21:46:01 1.2
+++ rpcb_clnt.c 2000/06/10 18:12:54
@@ -67,6 +67,7 @@
#include <string.h>
#include <unistd.h>
#include <netdb.h>
+#include <syslog.h>
#include "rpc_com.h"
@@ -458,6 +459,7 @@
nc_handle = setnetconfig();
if (nc_handle == NULL) {
/* fails to open netconfig file */
+ syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
mutex_unlock(&loopnconf_lock);
return (NULL);
From: Frank van der Linden <frank@wins.uva.nl>
To: Assar Westerlund <assar@sics.se>
Cc: thorpej@zembu.com, gnats-bugs@gnats.netbsd.org
Subject: Re: lib/10275: TI-RPC failure without /etc/netconfig is obtuse
Date: Sun, 11 Jun 2000 14:43:44 +0200
On Sat, Jun 10, 2000 at 08:14:32PM +0200, Assar Westerlund wrote:
> Jason R Thorpe <thorpej@zembu.com> writes:
> > Should use _PATH_NETCONFIG I guess... (Is that in <paths.h>?)
>
> There's a NETCONFIG in <netconfig.h> so I used that instead. Frank,
> this ok with you?
>
> /assar
[...]
That looks fine to me.
- Frank
State-Changed-From-To: open->closed
State-Changed-By: assar
State-Changed-When: Sun Jun 11 09:27:22 PDT 2000
State-Changed-Why:
fixed with lib/libc/rpc/rpcb_clnt.c:1.3 lib/libc/rpc/rpc_generic.c:1.2 lib/libc/rpc/getnetpath.c:1.2
Responsible-Changed-From-To: lib-bug-people->assar
Responsible-Changed-By: assar
Responsible-Changed-When: Sun Jun 11 09:27:22 PDT 2000
Responsible-Changed-Why:
I took care of it
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.