Bug 63697 - setnetgrent() returns wrong status value when netgroup exists
setnetgrent() returns wrong status value when netgroup exists
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.2
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-04-17 11:24 EDT by Need Real Name
Modified: 2007-04-18 12:42 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-04-19 07:49:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2002-04-17 11:24:47 EDT
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 07:49:18 EDT
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 08:16:35 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.