Commit b55b763c authored by William Jon McCann's avatar William Jon McCann Committed by William Jon McCann

Add support for non POSIX getpwnam_r

2007-08-22  William Jon McCann  <mccann@jhu.edu>

	* configure.ac:
	* daemon/gdm-session-worker.c:
	(gdm_session_worker_give_user_credentials):
	Add support for non POSIX getpwnam_r


svn path=/branches/mccann-gobject/; revision=5180
parent b7378f6e
2007-08-22 William Jon McCann <mccann@jhu.edu>
* configure.ac:
* daemon/gdm-session-worker.c:
(gdm_session_worker_give_user_credentials):
Add support for non POSIX getpwnam_r
2007-08-21 William Jon McCann <mccann@jhu.edu>
* daemon/gdm-display-factory.c:
......
......@@ -277,20 +277,6 @@ AC_CHECK_FUNC(inet_aton,,[
AC_CHECK_LIB(resolv,inet_aton, [
EXTRA_CHOOSER_LIBS="$EXTRA_CHOOSER_LIBS -lresolv"])])
AC_MSG_CHECKING(if utmpx structure has ut_syslen field)
AC_TRY_COMPILE([
#include <utmpx.h>],[
struct utmpx record;
record.ut_syslen = sizeof (record.ut_host);
],
have_ut_syslen=yes,
have_ut_syslen=no
)
if test x$have_ut_syslen = xyes; then
AC_DEFINE(HAVE_UT_SYSLEN)
fi
AC_MSG_RESULT($have_ut_syslen)
COMMON_GNOME_LIBS="libgdmcommon-ui.a"
AC_SUBST(COMMON_GNOME_LIBS)
......@@ -458,6 +444,57 @@ AC_CHECK_HEADERS(sys/sockio.h, [
AC_CHECK_HEADERS(libgen.h, [
AC_DEFINE(HAVE_LIBGEN_H)])
#
# Checking for a posix version of getpwnam_r
# if we are cross compiling and can not run the test
# assume getpwnam_r is the posix version
# it is up to the person cross compiling to change
# this behavior if desired
#
AC_LANG_PUSH(C)
AC_CACHE_CHECK([for posix getpwnam_r],
ac_cv_func_posix_getpwnam_r,
[AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[
#include <errno.h>
#include <pwd.h>
]],
[[
char buffer[10000];
struct passwd pwd, *pwptr = &pwd;
int error;
errno = 0;
error = getpwnam_r ("", &pwd, buffer,
sizeof (buffer), &pwptr);
return (error < 0 && errno == ENOSYS)
|| error == ENOSYS;
]])],
[ac_cv_func_posix_getpwnam_r=yes],
[ac_cv_func_posix_getpwnam_r=no],
[ac_cv_func_posix_getpwnam_r=yes]
)])
AC_LANG_POP(C)
if test "$ac_cv_func_posix_getpwnam_r" = yes; then
AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
[Have POSIX function getpwnam_r])
else
AC_CACHE_CHECK([for nonposix getpwnam_r],
ac_cv_func_nonposix_getpwnam_r,
[AC_TRY_LINK([#include <pwd.h>],
[char buffer[10000];
struct passwd pwd;
getpwnam_r ("", &pwd, buffer,
sizeof (buffer));],
[ac_cv_func_nonposix_getpwnam_r=yes],
[ac_cv_func_nonposix_getpwnam_r=no])])
if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
[Have non-POSIX function getpwnam_r])
fi
fi
#
# Check for utmp stuff
#
......@@ -467,6 +504,20 @@ AC_CHECK_LIB(util,login)
AC_CHECK_LIB(util,logout)
GDM_CHECK_UTMP
AC_MSG_CHECKING(if utmpx structure has ut_syslen field)
AC_TRY_COMPILE([
#include <utmpx.h>],[
struct utmpx record;
record.ut_syslen = sizeof (record.ut_host);
],
have_ut_syslen=yes,
have_ut_syslen=no
)
if test x$have_ut_syslen = xyes; then
AC_DEFINE(HAVE_UT_SYSLEN)
fi
AC_MSG_RESULT($have_ut_syslen)
#
# Xdmcp checking
#
......
......@@ -48,7 +48,7 @@ typedef struct
} GdmProductSlaveClass;
GType gdm_product_slave_get_type (void);
GdmSlave * gdm_product_slave_new (const char *id);
GdmSlave * gdm_product_slave_new (const char *id);
G_END_DECLS
......
......@@ -107,8 +107,6 @@ enum {
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
static void gdm_session_worker_class_init (GdmSessionWorkerClass *klass);
static void gdm_session_worker_init (GdmSessionWorker *session_worker);
static void gdm_session_worker_finalize (GObject *object);
......@@ -979,11 +977,12 @@ static gboolean
gdm_session_worker_give_user_credentials (GdmSessionWorker *worker,
GError **error)
{
int error_code;
struct passwd *passwd_entry, passwd_buffer;
char *aux_buffer;
long required_aux_buffer_size;
gsize aux_buffer_size;
int error_code;
struct passwd *passwd_entry;
struct passwd passwd_buffer;
char *aux_buffer;
long required_aux_buffer_size;
gsize aux_buffer_size;
aux_buffer = NULL;
aux_buffer_size = 0;
......@@ -1012,11 +1011,19 @@ gdm_session_worker_give_user_credentials (GdmSessionWorker *worker,
* by a PAM module
*/
passwd_entry = NULL;
errno = getpwnam_r (worker->priv->username,
#ifdef HAVE_POSIX_GETPWNAM_R
errno = getpwnam_r (worker->priv->username,
&passwd_buffer,
aux_buffer,
aux_buffer,
(size_t) aux_buffer_size,
&passwd_entry);
&passwd_entry);
#else
passwd_entry = getpwnam_r (worker->priv->username,
&passwd_buffer,
aux_buffer,
(size_t) aux_buffer_size);
errno = 0;
#endif /* !HAVE_POSIX_GETPWNAM_R */
if (errno != 0) {
error_code = PAM_SYSTEM_ERR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment