-- William Pursell
>From c146c3609d24f6b81713124e9b465ea3dac23b17 Mon Sep 17 00:00:00 2001 From: William Pursell <[EMAIL PROTECTED]> Date: Mon, 6 Oct 2008 20:24:08 +0100 Subject: [PATCH] Adding 2nd portion of new configure.ac
--- src/configure.ac | 350 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 350 insertions(+), 0 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 0001c39..8dcb848 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -398,3 +398,353 @@ dnl may need LIBS="$LIBS -lsocket" here dnl AC_CHECKING(sockets) +AC_TRY_RUN([ +/* For select - According to POSIX 1003.1-2001 */ +#include <sys/select.h> + +/* For select - According to earlier standards */ +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> + +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/socket.h> +#include <sys/un.h> + +char *son = "/tmp/conftest$$"; + +main() +{ + int s1, s2, l; + struct sockaddr_un a; + fd_set f; + + (void)alarm(5); + if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + exit(1); + a.sun_family = AF_UNIX; + strcpy(a.sun_path, son); + (void) unlink(son); + if (bind(s1, (struct sockaddr *) &a, strlen(son)+2) == -1) + exit(1); + if (listen(s1, 2)) + exit(1); + if (fork() == 0) + { + if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + kill(getppid(), 3); + (void)connect(s2, (struct sockaddr *)&a, strlen(son) + 2); + if (write(s2, "HELLO", 5) == -1) + kill(getppid(), 3); + exit(0); + } + l = sizeof(a); + close(0); + if (accept(s1, &a, &l)) + exit(1); + FD_SET(0, &f); + if (select(1, &f, 0, 0, 0) == -1) + exit(1); + exit(0); +} +], AC_MSG_NOTICE(- your sockets are usable) + sock=1, +AC_MSG_NOTICE(- your sockets are not usable)) +rm -f /tmp/conftest* + +if test -n "$sock"; then +AC_CHECKING(socket implementation) +AC_TRY_RUN([ +/* For select - According to POSIX 1003.1-2001 */ +#include <sys/select.h> + +/* For select - According to earlier standards */ +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> + +#include <sys/stat.h> +#include <sys/socket.h> +#include <sys/un.h> + +char *son = "/tmp/conftest$$"; + +main() +{ + int s; + struct stat stb; + struct sockaddr_un a; + if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + exit(0); + a.sun_family = AF_UNIX; + strcpy(a.sun_path, son); + (void) unlink(son); + if (bind(s, (struct sockaddr *) &a, strlen(son)+2) == -1) + exit(0); + if (stat(son, &stb)) + exit(1); + close(s); + exit(0); +} +],AC_MSG_NOTICE(- you are normal), +AC_MSG_NOTICE(- unix domain sockets are not kept in the filesystem) +AC_DEFINE(SOCK_NOT_IN_FS) socknofs=1) +rm -f /tmp/conftest* +fi + + +dnl +dnl **** choose sockets or fifos **** +dnl +if test -n "$fifo"; then + if test -n "$sock"; then + if test -n "$nore"; then + AC_MSG_NOTICE(- hmmm... better take the fifos) + AC_DEFINE(NAMEDPIPE) + elif test -n "$fifobr"; then + AC_MSG_NOTICE(- as your fifos are broken lets use the sockets.) + else + AC_MSG_NOTICE(- both sockets and fifos usable. let's take sockets.) + fi + else + AC_MSG_NOTICE(- using named pipes, of course) + AC_DEFINE(NAMEDPIPE) + fi +elif test -n "$sock"; then + AC_MSG_NOTICE(- using unix-domain sockets, of course) +else + AC_MSG_ERROR(you have neither usable sockets nor usable pipes -> no screen) +fi + +dnl +dnl **** check the select implementation **** +dnl + +AC_CHECKING(select return value) +AC_TRY_RUN([ +/* For select - According to POSIX 1003.1-2001 */ +#include <sys/select.h> + +/* For select - According to earlier standards */ +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> + +#include <sys/stat.h> +#include <fcntl.h> + +char *nam = "/tmp/conftest$$"; + +#ifdef NAMEDPIPE + +#ifndef O_NONBLOCK +#define O_NONBLOCK O_NDELAY +#endif +#ifndef S_IFIFO +#define S_IFIFO 0010000 +#endif + + +main() +{ + fd_set f; + +#ifdef __FreeBSD__ +/* From Andrew A. Chernov ([EMAIL PROTECTED]): + * opening RDWR fifo fails in BSD 4.4, but select return values are + * right. + */ + exit(0); +#endif + (void)alarm(5); +#ifdef POSIX + if (mkfifo(nam, 0777)) +#else + if (mknod(nam, S_IFIFO|0777, 0)) +#endif + exit(1); + close(0); + if (open(nam, O_RDWR | O_NONBLOCK)) + exit(1); + if (write(0, "TEST", 4) == -1) + exit(1); + +#else + +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> + +main() +{ + int s1, s2, l; + struct sockaddr_un a; + fd_set f; + + (void)alarm(5); + if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + exit(1); + a.sun_family = AF_UNIX; + strcpy(a.sun_path, nam); + (void) unlink(nam); + if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1) + exit(1); + if (listen(s1, 2)) + exit(1); + if (fork() == 0) + { + if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + kill(getppid(), 3); + (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2); + if (write(s2, "HELLO", 5) == -1) + kill(getppid(), 3); + exit(0); + } + l = sizeof(a); + close(0); + if (accept(s1, (struct sockaddr *)&a, &l)) + exit(1); +#endif + + + FD_SET(0, &f); + if (select(1, &f, 0, 0, 0) == -1) + exit(1); + if (select(1, &f, &f, 0, 0) != 2) + exit(1); + exit(0); +} +],AC_MSG_NOTICE(- select is ok), +AC_MSG_NOTICE(- select can't count) +AC_DEFINE(SELECT_BROKEN)) + +dnl +dnl **** termcap or terminfo **** +dnl +AC_CHECKING(for tgetent) +AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, +olibs="$LIBS" +LIBS="-lcurses $olibs" +AC_CHECKING(libcurses) +AC_TRY_LINK(,[ +#ifdef __hpux +__sorry_hpux_libcurses_is_totally_broken_in_10_10(); +#else +tgetent((char *)0, (char *)0); +#endif +],, +LIBS="-ltermcap $olibs" +AC_CHECKING(libtermcap) +AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, +LIBS="-ltermlib $olibs" +AC_CHECKING(libtermlib) +AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, +LIBS="-lncursesw $olibs" +AC_CHECKING(libncursesw) +AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, +LIBS="-lncurses $olibs" +AC_CHECKING(libncurses) +AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, +AC_MSG_ERROR(!!! no tgetent - no screen))))))) + +AC_TRY_RUN([ +main() +{ + exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1); +}], AC_MSG_NOTICE(- you use the termcap database), +AC_MSG_NOTICE(- you use the terminfo database) +AC_DEFINE(TERMINFO)) +AC_CHECKING(ospeed) +AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED)) + +dnl +dnl **** PTY specific things **** +dnl +AC_CHECKING(for /dev/ptc) +if test -r /dev/ptc; then +AC_DEFINE(HAVE_DEV_PTC) +fi + +AC_CHECKING(for SVR4 ptys) +sysvr4ptys= +if test -c /dev/ptmx ; then +AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS) +sysvr4ptys=1]) +fi + +AC_CHECK_FUNCS(getpt) + +dnl check for openpty() +if test -z "$sysvr4ptys"; then +AC_CHECK_FUNCS(openpty,, +[AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])]) +fi + +AC_CHECKING(for ptyranges) +if test -d /dev/ptym ; then +pdir='/dev/ptym' +else +pdir='/dev' +fi +dnl SCO uses ptyp%d +AC_EGREP_CPP(yes, +[#ifdef M_UNIX + yes; +#endif +], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`) +dnl if test -c /dev/ptyp19; then +dnl ptys=`echo /dev/ptyp??` +dnl else +dnl ptys=`echo $pdir/pty??` +dnl fi +if test "$ptys" != "$pdir/pty??" ; then +p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'` +p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'` +AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0") +AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1") +fi + +dnl **** pty mode/group handling **** +dnl +dnl support provided by Luke Mewburn <[EMAIL PROTECTED]>, 931222 +AC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ]) +AC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ]) +test -n "$ptymode" || ptymode=0620 +if test -n "$ptygrp" ; then +AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) +AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) +else + +AC_CHECKING(default tty permissions/group) +rm -f conftest_grp +AC_TRY_RUN([ +#include <sys/types.h> +#include <sys/stat.h> +#include <stdio.h> +main() +{ + struct stat sb; + char *x,*ttyname(); + int om, m; + FILE *fp; + + if (!(x = ttyname(0))) exit(1); + if (stat(x, &sb)) exit(1); + om = sb.st_mode; + if (om & 002) exit(0); + m = system("mesg y"); + if (m == -1 || m == 127) exit(1); + if (stat(x, &sb)) exit(1); + m = sb.st_mode; + if (chmod(x, om)) exit(1); + if (m & 002) exit(0); + if (sb.st_gid == getgid()) exit(1); + if (!(fp=fopen("conftest_grp", "w"))) + exit(1); + fprintf(fp, "%d\n", sb.st_gid); + fclose(fp); + exit(0); +} +],[ + if test -f conftest_grp; then -- 1.6.0.2.GIT