Hi Jason,
Jason McIntyre wrote on Sun, Jul 05, 2009 at 05:46:06PM +0100:
> On Tue, Jun 30, 2009 at 08:56:36AM -0300, Joao Salvatti wrote:
>> Isn't the header file <sys/types.h> absent in the manual page
>> authenticate(3)?
Yes, it is absent, but grepping /usr/share/man/cat3 for "types.h"
tells me that sys/types.h is not mentioned in a single section 3
manual page.
>> The use of its functions, such as auth_userokay(),
>> will never compile without the inclusion of that header.
Right, even without actually using any of the functions,
including either <login_cap.h> or <bsd_auth.h> without including
<sys/types.h> will make your program not compile.
The header <login_cap.h> uses quad_t and uid_t.
The type quad_t is a non-POSIX type defined in <sys/types.h>.
The type uid_t is required by POSIX in <sys/types.h>.
The header <bsd_auth.h> uses size_t.
The type size_t is required by POSIX in <sys/types.h>.
> no one has replied to this yet, i think. so, the man page is right or
> wrong? any takers?
I guess the manual is fine, but i'm not sure these two header files
are correct. Lots of other header files include <sys/types.h>,
both some traditional BSD headers like <db.h> and some POSIX headers
like <fcntl.h>.
Probably, this went unnoticed because most programs including
the headers <login_cap.h> and <bsd_auth.h> also include some
of the other headers including <sys/types.h>, like <pwd.h>,
<stdio.h>, <stdlib.h> and <unistd.h>...
If i understand correctly, headers using types from <sys/types.h>
ought to include <sys/types.h>
- unconditionally, if they are POSIX headers and the use of the
type is mandated by POSIX
- protected by __BSD_VISIBLE or the appropriate feature macro
like __XPG_VISIBLE, if they are POSIX headers and if the use
is not mandated by POSIX, but by a lesser standard
- protected by __BSD_VISIBLE only, if they are POSIX headers and
if the use is not mandated by a standard
- unconditionally, if they are not POSIX headers
Here, the latter case applies, so i suggest the following diff.
Feel free to apply the cluestick in case i got this wrong...
Yours,
Ingo
Index: bsd_auth.h
===================================================================
RCS file: /cvs/src/include/bsd_auth.h,v
retrieving revision 1.9
diff -u -p -r1.9 bsd_auth.h
--- bsd_auth.h 6 Jan 2006 18:53:04 -0000 1.9
+++ bsd_auth.h 5 Jul 2009 19:51:35 -0000
@@ -52,6 +52,8 @@ typedef enum {
} auth_item_t;
#include <sys/cdefs.h>
+#include <sys/types.h>
+
__BEGIN_DECLS
struct passwd;
struct login_cap;
Index: login_cap.h
===================================================================
RCS file: /cvs/src/include/login_cap.h,v
retrieving revision 1.13
diff -u -p -r1.13 login_cap.h
--- login_cap.h 28 Jan 2005 17:17:22 -0000 1.13
+++ login_cap.h 5 Jul 2009 19:51:35 -0000
@@ -88,6 +88,8 @@ typedef struct login_cap {
} login_cap_t;
#include <sys/cdefs.h>
+#include <sys/types.h>
+
__BEGIN_DECLS
struct passwd;