]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Check for non-posix utmpxname in configure
authorNatanael Copa <ncopa@alpinelinux.org>
Wed, 29 Jan 2014 14:23:48 +0000 (14:23 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 29 Jan 2014 16:15:52 +0000 (16:15 +0000)
utmpx.h is specified in POSIX but utmpxname is not so we check for
utmpxname in configure script.

This fixes the following compile error with musl libc:
lxcutmp.c: In function 'utmp_get_runlevel':
lxcutmp.c:249:2: error: implicit declaration of function 'utmpxname' [-Werror=implicit-function-declaration]
  if (!access(path, F_OK) && !utmpxname(path))
    ^

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
configure.ac
src/lxc/lxcutmp.c

index f6c95c1e6c5ce1b8d76c2dcfcefc33d36fabe3ca..c9d1f06f73f5f46c39f1e3d2874c65c1b4a37f76 100644 (file)
@@ -521,7 +521,7 @@ AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr])
 AC_CHECK_LIB(pthread, main)
 AC_CHECK_FUNCS(pthread_atfork)
 AC_CHECK_LIB(util, openpty)
-AC_CHECK_FUNCS([openpty hasmntopt setmntent endmntent])
+AC_CHECK_FUNCS([openpty hasmntopt setmntent endmntent utmpxname])
 AC_CHECK_FUNCS([getline],
        AM_CONDITIONAL(HAVE_GETLINE, true)
        AC_DEFINE(HAVE_GETLINE,1,[Have getline]),
index 6c9e6f2b95b849d054b056a68280b47b5954d822..15dd71cccbbad93044ae19ae28edc971b93a6497 100644 (file)
@@ -68,6 +68,10 @@ static int timerfd_settime (int __ufd, int __flags,
 #endif
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
+#ifndef HAVE_UTMPXNAME
+#include <utmp.h>
+#endif
+
 #else
 #include <utmp.h>
 
@@ -75,18 +79,6 @@ static int timerfd_settime (int __ufd, int __flags,
 #define RUN_LVL 1
 #endif
 
-static int utmpxname(const char *file) {
-       int result;
-       result = utmpname(file);
-
-#ifdef IS_BIONIC
-       /* Yeah bionic is that weird */
-       result = result - 1;
-#endif
-
-       return result;
-}
-
 static void setutxent(void) {
        return setutent();
 }
@@ -104,6 +96,21 @@ static void endutxent (void) {
 #endif
 }
 #endif
+
+#ifndef HAVE_UTMPXNAME
+static int utmpxname(const char *file) {
+       int result;
+       result = utmpname(file);
+
+#ifdef IS_BIONIC
+       /* Yeah bionic is that weird */
+       result = result - 1;
+#endif
+
+       return result;
+}
+#endif
+
 #undef __USE_GNU
 
 /* This file watches the /var/run/utmp file in the container