From: Natanael Copa Date: Wed, 29 Jan 2014 14:23:48 +0000 (+0000) Subject: Check for non-posix utmpxname in configure X-Git-Tag: lxc-1.0.0.beta4~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b6d8b712b867ab352598ed4b73e80e54a8c915a;p=thirdparty%2Flxc.git Check for non-posix utmpxname in configure 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 Acked-by: Serge E. Hallyn --- diff --git a/configure.ac b/configure.ac index f6c95c1e6..c9d1f06f7 100644 --- a/configure.ac +++ b/configure.ac @@ -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]), diff --git a/src/lxc/lxcutmp.c b/src/lxc/lxcutmp.c index 6c9e6f2b9..15dd71ccc 100644 --- a/src/lxc/lxcutmp.c +++ b/src/lxc/lxcutmp.c @@ -68,6 +68,10 @@ static int timerfd_settime (int __ufd, int __flags, #endif #ifdef HAVE_UTMPX_H #include +#ifndef HAVE_UTMPXNAME +#include +#endif + #else #include @@ -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