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>
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]),
#endif
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
+#ifndef HAVE_UTMPXNAME
+#include <utmp.h>
+#endif
+
#else
#include <utmp.h>
#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();
}
#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