Bug 63697

Summary: setnetgrent() returns wrong status value when netgroup exists
Product: [Retired] Red Hat Linux Reporter: Need Real Name <michael.gerdts>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: drepper, fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-04-19 11:49:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2002-04-17 15:24:47 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.0 (X11; Linux i686; U;) Gecko/20020326

Description of problem:
setnetgrent() has behavior that is inconsistent with setnetgrent() on Solaris. 
From the Solaris 8 man page getnetgrent(3C):

     The functions setnetgrent() and endnetgrent() return 0  upon
     success.



Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
Compile netgrouptest.c (gcc -o netgrouptest netgrouptest.c):

#include <netdb.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[]) {
	char *machine, *user, *domain;
	int rv;
	int i;
    char opt;
    int show_host = 0, show_user = 0;

	for ( i = 1 ; i < argc ; i++ ) {
		if ( (rv = setnetgrent(argv[i])) != 0 ) {
			printf("%s: setnetgrent(%s): %s\n", argv[0], argv[i], strerror(errno));
		} else {
			printf("%s: setnetgrent(%s): OK\n", argv[0], argv[i]);
        }
    }
	return 0;
}



Actual Results:  % ./netgrouptest desktops slfjslfjslfj
./netgrouptest: setnetgrent(desktops): No such file or directory
./netgrouptest: setnetgrent(slfjslfjslfj): OK


Expected Results:  % ./netgrouptest desktops slfjslfjslfj
./netgrouptest: setnetgrent(desktops): No such file or directory
./netgrouptest: setnetgrent(slfjslfjslfj): ????

The ???? denotes an unknown condition.  The Solaris man page does not define
what is returned when setnetgrent() fails.  Solaris 8 returns 0 in both cases.

Additional info:

Comment 1 Jakub Jelinek 2002-04-19 11:49:18 UTC
But glibc documents the current behaviour:
     When the call is successful (i.e., when a netgroup with this name
     exists) the return value is `1'.  When the return value is `0' no
     netgroup of this name is known or some other error occurred.
Note that e.g. AIX/BSD/Darwin don't return anything from setnetgrent and endnetgrent,
so relying on specific return value without checking it in configury
is wrong anyway.

Comment 2 Need Real Name 2002-04-19 12:16:35 UTC
Very well.  After going through the pain of using info, I found that this is
indeed documented.  We really need info2man or a hack on man that will bring up
the appropriate info node (as a man page rather than in info) as part of its
search path.