[PATCH] readdir_r getpwnam_r & others
Peter O'Gorman
dbus at mlists.thewrittenword.com
Tue Jul 17 13:30:05 PDT 2007
Hi,
Some more stuff we noticed:
readdir_r returns EBADF at the end of a directory on AIX, also it
returns -1 on solaris 2.6 and 2.6 with largefiles (without
-D_FILE_OFFSET_BITS=64 readdir_r works as expected on solaris). On all
systems I have access to it seems reasonable that, when readdir_r
returns a NULL struct dirent *, to closedir() and continue without
issuing an error.
Note that I said previously that AC_SYS_LARGEFILE makes
-D_POSIX_PTHREAD_SEMANTICS redundant, but that is not actually the
case, it only makes it redundant in the case of file access api's,
not...
getpwnam_r is quite icky - hpux10 has yet another prototype for it:
int getpwnam_r(const char *, struct passwd *, char *, int)
(the other two are already dealt with, and they are:
struct passwd* getpwnam_r(const char *, struct passwd *, char *, int);
and
int getpwnam_r(const char *, struct passwd *, char *, size_t , struct passwd **);
)
Solaris needs -D_POSIX_PTHREAD_SEMANTICS here to get the right getpwnam_r.
We set the ac_c_werror_flag=yes for these configure tests because some
compilers only issued a warning for wrong number of arguments.
HP-UX pathconf("/path",_PC_NAME_MAX) fails when /path is a zfs
filesystem mounted from a solaris10 server with NFSv2. Yes, this is
obscure, but it seems best to have a "reasonable default" in here
rather than failing to start. On every other path hp-ux returns 255,
1024 seems to give a nice wide safety margin.
The sys/poll.h defines on AIX did not match the dbus versions.
Changed // style comment in c file to /* */
Thank you,
Peter
-------------- next part --------------
Index: configure.in
===================================================================
--- configure.in.orig 2006-12-11 19:21:19.000000000 +0000
+++ configure.in 2007-07-13 20:17:26.523712119 +0000
@@ -561,7 +406,31 @@
AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
-AC_CHECK_HEADERS(errno.h)
+AC_CHECK_HEADERS(errno.h sys/select.h)
+
+save_werror_flag="$ac_c_werror_flag"
+ac_c_werror_flag=yes
+AC_CACHE_CHECK([for hpux10 getpwnam_r],
+ ac_cv_func_hpux10_getpwnam_r,
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[
+#include <pwd.h>
+],
+[[
+ char buffer[10000];
+ struct passwd pwd;
+ int error;
+ error = getpwnam_r ("", &pwd, buffer, sizeof(buffer));
+ return error;
+]])],
+ [ac_cv_func_hpux10_getpwnam_r=yes],
+ [ac_cv_func_hpux10_getpwnam_r=no]
+)])
+
+if test "$ac_cv_func_hpux10_getpwnam_r" = yes; then
+ AC_DEFINE(HAVE_HPUX10_GETPWNAM_R,1,
+ [Have HP-UX 10 style getpwnam_r])
+fi
# checking for a posix version of getpwnam_r
# if we are cross compiling and can not run the test
@@ -611,6 +478,8 @@
fi
fi
+ac_c_werror_flag="$save_werror_flag"
+
dnl check for socklen_t
AC_MSG_CHECKING(whether socklen_t is defined)
AC_TRY_COMPILE([
@@ -634,6 +503,25 @@
dnl needed on darwin for NAME_MAX
AC_CHECK_HEADERS(sys/syslimits.h)
+dnl some systems have a readdir_r that only takes 2 arguments
+AC_CHECK_FUNC(readdir_r,[
+save_werror_flag="$ac_c_werror_flag"
+ac_c_werror_flag=yes
+AC_MSG_CHECKING(if readdir_r takes two arguments)
+AC_COMPILE_IFELSE([
+AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <stddef.h>
+#include <dirent.h>
+],[
+ DIR * dir = NULL;
+ struct dirent ent;
+ int result = readdir_r(dir,&ent);])
+],[AC_DEFINE([READDIR_R_2_ARG],1,
+ [Define if readdir_r takes only 2 arguments])
+ AC_MSG_RESULT(yes)],AC_MSG_RESULT(no))
+ac_c_werror_flag="$save_werror_flag"
+], AC_MSG_ERROR(Need readdir_r))
dnl check for flavours of varargs macros (test from GLib)
AC_MSG_CHECKING(for ISO C99 varargs macros in C)
AC_TRY_COMPILE([],[
Index: dbus/dbus-sysdeps-unix.c
===================================================================
--- dbus/dbus-sysdeps-unix.c.orig 2006-12-11 19:21:09.000000000 +0000
+++ dbus/dbus-sysdeps-unix.c 2007-07-16 14:24:15.929744256 +0000
@@ -1207,7 +1211,7 @@
* checks
*/
-#if defined (HAVE_POSIX_GETPWNAM_R) || defined (HAVE_NONPOSIX_GETPWNAM_R)
+#if defined (HAVE_POSIX_GETPWNAM_R) || defined (HAVE_NONPOSIX_GETPWNAM_R) || defined (HAVE_HPUX10_GETPWNAM_R)
{
struct passwd *p;
int result;
@@ -1215,13 +1219,20 @@
struct passwd p_str;
p = NULL;
-#ifdef HAVE_POSIX_GETPWNAM_R
+#if HAVE_HPUX10_GETPWNAM_R
+ if (uid != DBUS_UID_UNSET)
+ result = getpwuid_r (uid, &p_str, buf, sizeof (buf));
+ else
+ result = getpwnam_r (username_c, &p_str, buf, sizeof (buf));
+ if (!result) p = &p_str; else p = NULL;
+#elif HAVE_POSIX_GETPWNAM_R
if (uid != DBUS_UID_UNSET)
result = getpwuid_r (uid, &p_str, buf, sizeof (buf),
&p);
else
result = getpwnam_r (username_c, &p_str, buf, sizeof (buf),
&p);
+
#else
if (uid != DBUS_UID_UNSET)
p = getpwuid_r (uid, &p_str, buf, sizeof (buf));
Index: dbus/dbus-sysdeps.h
===================================================================
--- dbus/dbus-sysdeps.h.orig 2006-12-11 19:21:16.000000000 +0000
+++ dbus/dbus-sysdeps.h 2007-07-12 19:57:26.445335916 +0000
@@ -234,7 +241,21 @@
dbus_int32_t _dbus_atomic_inc (DBusAtomic *atomic);
dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic);
+#ifdef _AIX
+/** There is data to read */
+#define _DBUS_POLLIN 0x0001
+/** There is urgent data to read */
+#define _DBUS_POLLPRI 0x0004
+/** Writing now will not block */
+#define _DBUS_POLLOUT 0x0002
+/** Error condition */
+#define _DBUS_POLLERR 0x4000
+/** Hung up */
+#define _DBUS_POLLHUP 0x2000
+/** Invalid request: fd not open */
+#define _DBUS_POLLNVAL 0x8000
+#else
/** There is data to read */
#define _DBUS_POLLIN 0x0001
/** There is urgent data to read */
@@ -247,7 +268,7 @@
#define _DBUS_POLLHUP 0x0010
/** Invalid request: fd not open */
#define _DBUS_POLLNVAL 0x0020
-
+#endif
/**
* A portable struct pollfd wrapper.
*/
Index: dbus/dbus-sysdeps-util-unix.c
===================================================================
--- dbus/dbus-sysdeps-util-unix.c.orig 2006-12-11 19:21:10.000000000 +0000
+++ dbus/dbus-sysdeps-util-unix.c 2007-07-17 01:24:45.105818694 +0000
@@ -519,7 +519,7 @@
# if defined(NAME_MAX)
name_max = NAME_MAX;
# else
- return FALSE;
+ name_max = 1024;
# endif
# elif defined(MAXNAMELEN)
name_max = MAXNAMELEN;
@@ -575,14 +575,15 @@
}
again:
+ ent=NULL;
+#ifdef READDIR_R_2_ARG
+ err = readdir_r (iter->d, d);
+ if (!err) ent = d; else ent = NULL;
+#else
err = readdir_r (iter->d, d, &ent);
- if (err || !ent)
+#endif
+ if (!ent)
{
- if (err != 0)
- dbus_set_error (error,
- _dbus_error_from_errno (err),
- "%s", _dbus_strerror (err));
-
dbus_free (d);
return FALSE;
}
Index: dbus/dbus-marshal-validate-util.c
===================================================================
--- dbus/dbus-marshal-validate-util.c.orig 2006-12-11 19:21:09.000000000 +0000
+++ dbus/dbus-marshal-validate-util.c 2007-07-12 22:15:14.570375692 +0000
@@ -179,9 +179,9 @@
":abce.freedesktop.blah"
};
const char *invalid_unique_names[] = {
- //":-",
+ /*":-",*/
":!",
- //":0-10",
+ /*":0-10",*/
":blah.",
":blah.",
":blah..org",
More information about the dbus
mailing list