Fix up setgrent(3) to have a POSIX-compliant prototype.

Just like with freelocale(3), I haven't been able to find any piece of
code that actually makes use of this function's return value, both in
base and in ports. The reason for this is that FreeBSD seems to be the
only operating system to have such a prototype. This is why I'm deciding
to not use symbol versioning for this.

It does seem that the pw(8) utility depends on the function's typing and
already had a switch in place to toggle between the FreeBSD and POSIX
variant of this function. Clean this up by always expecting the POSIX
variant.

There is also a single port that has a couple of local declarations of
setgrent(3) that need to be patched up. This is in the process of being
fixed.

PR:		211394 (exp-run)
This commit is contained in:
Ed Schouten 2016-07-31 08:05:15 +00:00
parent 452ccc029f
commit 9c24291370
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=303580
5 changed files with 11 additions and 24 deletions

View file

@ -75,8 +75,7 @@ int pwcache_groupdb(int (*)(int), void (*)(void),
struct group * (*)(gid_t));
#endif
#if __XSI_VISIBLE
/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */
int setgrent(void);
void setgrent(void);
#endif
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
int getgrgid_r(gid_t, struct group *, char *, size_t,

View file

@ -28,7 +28,7 @@
.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
.Dd April 16, 2003
.Dd July 31, 2016
.Dt GETGRENT 3
.Os
.Sh NAME
@ -60,7 +60,7 @@
.Fn getgrgid_r "gid_t gid" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
.Ft int
.Fn setgroupent "int stayopen"
.Ft int
.Ft void
.Fn setgrent void
.Ft void
.Fn endgrent void
@ -188,14 +188,13 @@ is set to
.Dv NULL
and the return value is 0, no matching entry exists.)
.Pp
The functions
The function
.Fn setgroupent
and
.Fn setgrent
return the value 1 if successful, otherwise the value
returns the value 1 if successful, otherwise the value
0 is returned.
The functions
.Fn endgrent
.Fn endgrent ,
.Fn setgrent
and
.Fn setgrfile
have no return value.

View file

@ -533,12 +533,10 @@ getgroupmembership_fallback(void *retval, void *mdata, va_list ap)
return (rv);
}
/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */
int
void
setgrent(void)
{
(void)_nsdispatch(NULL, setgrent_dtab, NSDB_GROUP, "setgrent", defaultsrc, 0);
return (1);
}

View file

@ -130,13 +130,10 @@ vendgrent(void)
}
}
RET_SETGRENT
void
vsetgrent(void)
{
vendgrent();
#if defined(__FreeBSD__)
return 0;
#endif
}
static struct group *

View file

@ -38,12 +38,6 @@
#include <stdbool.h>
#include <stringlist.h>
#if defined(__FreeBSD__)
#define RET_SETGRENT int
#else
#define RET_SETGRENT void
#endif
struct pwf {
int _altdir;
void (*_setpwent)(void);
@ -51,7 +45,7 @@ struct pwf {
struct passwd * (*_getpwent)(void);
struct passwd * (*_getpwuid)(uid_t uid);
struct passwd * (*_getpwnam)(const char * nam);
RET_SETGRENT (*_setgrent)(void);
void (*_setgrent)(void);
void (*_endgrent)(void);
struct group * (*_getgrent)(void);
struct group * (*_getgrgid)(gid_t gid);
@ -141,7 +135,7 @@ struct passwd * vgetpwnam(const char * nam);
struct group * vgetgrent(void);
struct group * vgetgrgid(gid_t gid);
struct group * vgetgrnam(const char * nam);
RET_SETGRENT vsetgrent(void);
void vsetgrent(void);
void vendgrent(void);
void copymkdir(int rootfd, char const * dir, int skelfd, mode_t mode, uid_t uid,