From 61ec5fb1a640125853bf14d3f8d850f39713d7da Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 22 Mar 2009 11:47:29 -1000 Subject: [PATCH] Fix some namespace issues with grp.h and pwd.h. * [1] endpwent, getpwent, setgrent, and setpwent are XSI extensions. * Change setgrent's prototype to match SuS. * SuS requires that gid_t be defined in grp.h and pwd.h, and uid_t be in pwd.h. [1] Obtained-from: FreeBSD --- include/grp.h | 15 ++++++++++----- include/pwd.h | 20 ++++++++++++++++---- lib/libc/gen/getgrent.3 | 14 +++----------- lib/libc/gen/getgrent.c | 4 +--- sys/sys/types.h | 6 ++++++ 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/include/grp.h b/include/grp.h index e6feac5e7a..9dbebf4961 100644 --- a/include/grp.h +++ b/include/grp.h @@ -36,17 +36,23 @@ * SUCH DAMAGE. * * @(#)grp.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD: src/include/grp.h,v 1.18 2003/04/17 14:15:25 nectar Exp $ + * $FreeBSD: src/include/grp.h,v 1.19 2009/03/14 19:05:18 das Exp $ * $DragonFly: src/include/grp.h,v 1.5 2008/04/19 10:08:05 swildner Exp $ */ #ifndef _GRP_H_ #define _GRP_H_ +#include #include #define _PATH_GROUP "/etc/group" +#ifndef _GID_T_DECLARED +typedef __uint32_t gid_t; +#define _GID_T_DECLARED +#endif + #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED @@ -59,8 +65,6 @@ struct group { char **gr_mem; /* group members */ }; -#include - __BEGIN_DECLS #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE void endgrent(void); @@ -71,9 +75,10 @@ struct group *getgrnam(const char *); #if __BSD_VISIBLE const char *group_from_gid(gid_t, int); #endif +#if __BSD_VISIBLE || __XSI_VISIBLE +void setgrent(void); +#endif #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE -/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */ -int setgrent(void); int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); int getgrnam_r(const char *, struct group *, char *, size_t, diff --git a/include/pwd.h b/include/pwd.h index 148b8b8e6f..4f0d3bed5d 100644 --- a/include/pwd.h +++ b/include/pwd.h @@ -36,20 +36,31 @@ * SUCH DAMAGE. * * @(#)pwd.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD: src/include/pwd.h,v 1.16 2005/01/26 17:26:54 nectar Exp $ + * $FreeBSD: src/include/pwd.h,v 1.17 2009/03/14 19:13:01 das Exp $ * $DragonFly: src/include/pwd.h,v 1.2 2003/11/14 01:01:43 dillon Exp $ */ #ifndef _PWD_H_ #define _PWD_H_ +#include #include +#ifndef _GID_T_DECLARED +typedef __uint32_t gid_t; +#define _GID_T_DECLARED +#endif + #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif +#ifndef _UID_T_DECLARED +typedef __uint32_t uid_t; +#define _UID_T_DECLARED +#endif + #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED @@ -138,16 +149,17 @@ struct passwd { #define _PWF_NIS 0x2000 #define _PWF_HESIOD 0x3000 -#include - __BEGIN_DECLS struct passwd *getpwnam(const char *); struct passwd *getpwuid(uid_t); -#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500 +#if __XSI_VISIBLE >= 500 void endpwent(void); struct passwd *getpwent(void); void setpwent(void); +#endif + +#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500 int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); int getpwuid_r(uid_t, struct passwd *, char *, size_t, diff --git a/lib/libc/gen/getgrent.3 b/lib/libc/gen/getgrent.3 index 2133c258e5..c883f4de97 100644 --- a/lib/libc/gen/getgrent.3 +++ b/lib/libc/gen/getgrent.3 @@ -61,7 +61,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 @@ -189,11 +189,9 @@ is set to .Dv NULL and the return value is 0, no matching entry exists.) .Pp -The functions +The .Fn setgroupent -and -.Fn setgrent -return the value 1 if successful, otherwise the value +function returns the value 1 if successful, otherwise the value 0 is returned. The .Fn endgrent @@ -224,12 +222,6 @@ and .Fn endgrent functions conform to .St -p1003.1-96 . -The -.Fn setgrent -function differs from that standard in that its return type is -.Vt int -rather than -.Vt void . .Sh HISTORY The functions .Fn endgrent , diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 9a32c38cfe..8b22035d60 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -532,12 +532,10 @@ out: return (rv); } -/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */ -int +void setgrent(void) { _nsdispatch(NULL, setgrent_dtab, NSDB_GROUP, "setgrent", defaultsrc, 0); - return (1); } diff --git a/sys/sys/types.h b/sys/sys/types.h index 12b43d1931..373dc2bd15 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -86,7 +86,10 @@ typedef __uint32_t u_daddr_t; /* unsigned disk address */ typedef __uint32_t fixpt_t; /* fixed point number */ typedef __uint64_t fsblkcnt_t; /* filesystem block count */ typedef __uint64_t fsfilcnt_t; /* filesystem file count */ +#ifndef _GID_T_DECLARED typedef __uint32_t gid_t; /* group id */ +#define _GID_T_DECLARED +#endif typedef __int64_t id_t; /* general id, can hold gid/pid/uid_t */ typedef __uint32_t in_addr_t; /* base type for internet address */ typedef __uint16_t in_port_t; @@ -99,7 +102,10 @@ typedef __pid_t pid_t; /* process id */ typedef __pid_t lwpid_t; /* light weight process id */ typedef quad_t rlim_t; /* resource limit */ typedef __int32_t segsz_t; /* segment size */ +#ifndef _UID_T_DECLARED typedef __uint32_t uid_t; /* user id */ +#define _UID_T_DECLARED +#endif typedef long suseconds_t; /* microseconds (signed) */ typedef __uint32_t useconds_t; /* microseconds (unsigned) */ -- 2.11.4.GIT