]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: add detection of openpty function
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 7 Jan 2020 16:19:52 +0000 (16:19 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 17 Jan 2020 09:59:08 +0000 (09:59 +0000)
All UNIX platforms we care about have openpty() in the libutil
library. Use of pty.h must also be made conditional, excluding
Win32.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
build-aux/syntax-check.mk
configure.ac
src/util/Makefile.inc.am
src/util/virfile.c

index 1fd11093d8751663fbfb13544dcdd8ac6e6d0c22..687a4ef368a193f01981dfa868adfc26879f6fbb 100644 (file)
@@ -2342,3 +2342,6 @@ exclude_file_name_regexp--sc_prohibit_strcmp = \
 
 exclude_file_name_regexp--sc_prohibit_backslash_alignment = \
   ^build-aux/syntax-check\.mk$$
+
+exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
+  ^src/util/virfile\.c$$
index 8837928358c1242df9428f08cf611c195a013f52..b28ed4a6dcd5c091ba86a7cf3b05c0c5e3834da4 100644 (file)
@@ -383,10 +383,13 @@ dnl Availability of various common headers (non-fatal if missing).
 AC_CHECK_HEADERS([\
   ifaddrs.h \
   libtasn1.h \
+  util.h \
+  libutil.h \
   linux/magic.h \
   mntent.h \
   net/ethernet.h \
   netinet/tcp.h \
+  pty.h \
   pwd.h \
   stdarg.h \
   syslog.h \
@@ -430,6 +433,7 @@ dnl header could be found.
 AM_CONDITIONAL([HAVE_LIBTASN1], [test "x$ac_cv_header_libtasn1_h" = "xyes"])
 
 AC_CHECK_LIB([intl],[gettext],[])
+AC_CHECK_LIB([util],[openpty],[])
 
 
 dnl
index dfa83478537db17264cdbb63044f1c14c7ddd046..23de4a6375f2cfb7c7f4d25a2927ae90e3b8adbe 100644 (file)
@@ -282,6 +282,7 @@ libvirt_util_la_CFLAGS = \
        $(NULL)
 libvirt_util_la_LIBADD = \
        -lm \
+       $(OPENPTY_LIBS) \
        $(CAPNG_LIBS) \
        $(YAJL_LIBS) \
        $(LIBNL_LIBS) \
index 6eaabf5371d94fbaed92a6b526b7f1eb26d92578..8bd03f8176be2a579f2b9472163b749b530a65ee 100644 (file)
 
 #include <passfd.h>
 #include <fcntl.h>
-#include <pty.h>
+#include <termios.h>
+#ifdef HAVE_PTY_H
+/* Linux openpty */
+# include <pty.h>
+#endif /* !HAVE_PTY_H */
+#ifdef HAVE_UTIL_H
+/* macOS openpty */
+# include <util.h>
+#endif /* !HAVE_LIBUTIL_H */
+#ifdef HAVE_LIBUTIL_H
+/* FreeBSD openpty */
+# include <libutil.h>
+#endif /* !HAVE_LIBUTIL_H */
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/socket.h>