[PATCH app-xdm 22/23] config: use AC_CHECK_FUNCS for mkstemp, getifaddrs ans getspnam
Gaetan Nadon
memsize at videotron.ca
Wed Sep 1 11:04:25 PDT 2010
AC_CHECK_FUNCS adds an AC_DEFINE of HAVE_XXX in addition of checking
for the functions. It has a consistent naming convention.
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
auth.c | 14 +++++++-------
configure.ac | 13 +------------
greet.h | 6 +++---
greeter/greet.c | 4 ++--
greeter/verify.c | 8 ++++----
session.c | 4 ++--
6 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/auth.c b/auth.c
index 1cf03e8..ed3d891 100644
--- a/auth.c
+++ b/auth.c
@@ -318,7 +318,7 @@ MakeServerAuthFile (struct display *d, FILE ** file)
#endif
char cleanname[NAMELEN];
int r;
-#ifdef HAS_MKSTEMP
+#ifdef HAVE_MKSTEMP
int fd;
#endif
struct stat statb;
@@ -368,7 +368,7 @@ MakeServerAuthFile (struct display *d, FILE ** file)
}
snprintf (d->authFile, len, "%s/%s/%s/A%s-XXXXXX",
authDir, authdir1, authdir2, cleanname);
-#ifdef HAS_MKSTEMP
+#ifdef HAVE_MKSTEMP
fd = mkstemp (d->authFile);
if (fd < 0) {
LogError ("cannot make authentication file %s: %s\n",
@@ -809,7 +809,7 @@ DefineLocal (FILE *file, Xauth *auth)
writeAddr (FamilyLocal, len, displayname, file, auth);
}
-#ifdef HAS_GETIFADDRS
+#ifdef HAVE_GETIFADDRS
# include <ifaddrs.h>
static void
@@ -1209,7 +1209,7 @@ DefineSelf (int fd, int file, int auth)
# endif /* SIOCGIFCONF else */
# endif /* WINTCP else */
# endif /* STREAMSCONN && !SYSV_SIOCGIFCONF else */
-#endif /* HAS_GETIFADDRS */
+#endif /* HAVE_GETIFADDRS */
static void
setAuthNumber (Xauth *auth, char *name)
@@ -1313,7 +1313,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify)
int i;
int magicCookie;
int data_len;
-#ifdef HAS_MKSTEMP
+#ifdef HAVE_MKSTEMP
int fd;
#endif
@@ -1348,7 +1348,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify)
if (lockStatus != LOCK_SUCCESS) {
snprintf (backup_name, sizeof(backup_name),
"%s/.XauthXXXXXX", d->userAuthDir);
-#ifdef HAS_MKSTEMP
+#ifdef HAVE_MKSTEMP
fd = mkstemp (backup_name);
if (fd >= 0) {
old = fdopen (fd, "r");
@@ -1378,7 +1378,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify)
if (new != NULL)
(void) fclose (new);
}
-#ifdef HAS_MKSTEMP
+#ifdef HAVE_MKSTEMP
} else {
(void) fclose (old);
#endif
diff --git a/configure.ac b/configure.ac
index 1906d5c..c04c676 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,18 +57,7 @@ AM_CONDITIONAL(HAVE_MKTEMP_COMMAND, test x$MKTEMP_COMMAND != x)
AC_FUNC_FORK
-dnl If you're looking here because you got a message that said
-dnl 'error: possibly undefined macro: AC_DEFINE', the source of
-dnl your problem is not here. You need to upgrade to pkgconfig 0.18
-dnl or later to get an updated pkg.m4 with PKG_CHECK_EXISTS defined.
-dnl See http://www.mail-archive.com/autoconf@gnu.org/msg13413.html
-AC_CHECK_FUNC(mkstemp, AC_DEFINE(HAS_MKSTEMP,1,
- [Define to 1 if you have the 'mkstemp' function.]))
-AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAS_GETIFADDRS,1,
- [Define to 1 if you have the 'getifaddrs' function.]))
-AC_CHECK_FUNC(getspnam, AC_DEFINE(USESHADOW,1,
- [Define to 1 if you have the shadow password functions.]))
-
+AC_CHECK_FUNCS(mkstemp getifaddrs getspnam)
AC_SEARCH_LIBS([setproctitle], [util bsd], [AC_CHECK_FUNCS(setproctitle)])
AC_SEARCH_LIBS([setusercontext], [util], [AC_CHECK_FUNCS(setusercontext)])
diff --git a/greet.h b/greet.h
index bf3ddd1..6b6689e 100644
--- a/greet.h
+++ b/greet.h
@@ -74,7 +74,7 @@ struct dlfuncs {
SETGRENT_TYPE (*_setgrent)(void); /* no longer used */
struct group *(*_getgrent)(void); /* no longer used */
void (*_endgrent)(void); /* no longer used */
-#ifdef USESHADOW
+#ifdef HAVE_GETSPNAM
struct spwd *(*_getspnam)(GETSPNAM_ARGS);
# ifndef QNX4
void (*_endspent)(void);
@@ -158,7 +158,7 @@ extern void (*__xdm_LogOutOfMem)(const char * fmt, ...);
extern void (*__xdm_setgrent)(void);
extern struct group *(*__xdm_getgrent)(void);
extern void (*__xdm_endgrent)(void);
-# ifdef USESHADOW
+# ifdef HAVE_GETSPNAM
extern struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS);
# ifndef QNX4
extern void (*__xdm_endspent)(void);
@@ -200,7 +200,7 @@ extern pam_handle_t **(*__xdm_thepamhp)(void);
# define setgrent (*__xdm_setgrent)
# define getgrent (*__xdm_getgrent)
# define endgrent (*__xdm_endgrent)
-# ifdef USESHADOW
+# ifdef HAVE_GETSPNAM
# define getspnam (*__xdm_getspnam)
# ifndef QNX4
# define endspent (*__xdm_endspent)
diff --git a/greeter/greet.c b/greeter/greet.c
index 6e29b05..d8ebb41 100644
--- a/greeter/greet.c
+++ b/greeter/greet.c
@@ -119,7 +119,7 @@ void (*__xdm_LogOutOfMem)(const char * fmt, ...) = NULL;
void (*__xdm_setgrent)(void) = NULL;
struct group *(*__xdm_getgrent)(void) = NULL;
void (*__xdm_endgrent)(void) = NULL;
-# ifdef USESHADOW
+# ifdef HAVE_GETSPNAM
struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS) = NULL;
# ifndef QNX4
void (*__xdm_endspent)(void) = NULL;
@@ -460,7 +460,7 @@ greet_user_rtn GreetUser(
__xdm_setgrent = dlfuncs->_setgrent;
__xdm_getgrent = dlfuncs->_getgrent;
__xdm_endgrent = dlfuncs->_endgrent;
-# ifdef USESHADOW
+# ifdef HAVE_GETSPNAM
__xdm_getspnam = dlfuncs->_getspnam;
# ifndef QNX4
__xdm_endspent = dlfuncs->_endspent;
diff --git a/greeter/verify.c b/greeter/verify.c
index 6e3f14b..dee035a 100644
--- a/greeter/verify.c
+++ b/greeter/verify.c
@@ -43,7 +43,7 @@ from The Open Group.
#if defined(USE_PAM)
# include <security/pam_appl.h>
# include <stdlib.h>
-#elif defined(USESHADOW)
+#elif defined(HAVE_GETSPNAM)
# include <shadow.h>
# include <errno.h>
#elif defined(USE_BSDAUTH)
@@ -326,7 +326,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
{
struct passwd *p;
# ifndef USE_PAM
-# ifdef USESHADOW
+# ifdef HAVE_GETSPNAM
struct spwd *sp;
# endif
char *user_pass = NULL;
@@ -450,7 +450,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
}
}
# endif
-# ifdef USESHADOW
+# ifdef HAVE_GETSPNAM
errno = 0;
sp = getspnam(greet->name);
if (sp == NULL) {
@@ -461,7 +461,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
# ifndef QNX4
endspent();
# endif /* QNX4 doesn't need endspent() to end shadow passwd ops */
-# endif /* USESHADOW */
+# endif /* HAVE_GETSPNAM */
# if defined(ultrix) || defined(__ultrix__)
if (authenticate_user(p, greet->password, NULL) < 0)
# else
diff --git a/session.c b/session.c
index e0ab4bc..bdafd0b 100644
--- a/session.c
+++ b/session.c
@@ -129,7 +129,7 @@ extern struct group *getgrent(void);
extern void endgrent(void);
#endif
-#ifdef USESHADOW
+#ifdef HAVE_GETSPNAM
# if defined(SVR4)
# include <shadow.h>
# else
@@ -192,7 +192,7 @@ static struct dlfuncs dlfuncs = {
setgrent,
getgrent,
endgrent,
-#ifdef USESHADOW
+#ifdef HAVE_GETSPNAM
getspnam,
# ifndef QNX4
endspent,
--
1.6.0.4
More information about the xorg-devel
mailing list