--- libptytty/ptytty.m4 2006/01/22 00:58:18 1.2 +++ libptytty/ptytty.m4 2007/05/07 13:46:06 1.9 @@ -17,6 +17,10 @@ getpt \ posix_openpt \ isastream \ + setuid \ + seteuid \ + setreuid \ + setresuid \ ) have_clone=no @@ -76,6 +80,38 @@ AC_DEFUN([UTMP_CHECK], [ +support_utmp=yes +support_wtmp=yes +support_lastlog=yes + +AC_ARG_ENABLE(utmp, + [ --enable-utmp enable utmp (utmpx) support], + [if test x$enableval = xyes -o x$enableval = xno; then + support_utmp=$enableval + fi]) + +AC_ARG_ENABLE(wtmp, + [ --enable-wtmp enable wtmp (wtmpx) support (requires --enable-utmp)], + [if test x$enableval = xyes -o x$enableval = xno; then + support_wtmp=$enableval + fi]) + +AC_ARG_ENABLE(lastlog, + [ --enable-lastlog enable lastlog support (requires --enable-utmp)], + [if test x$enableval = xyes -o x$enableval = xno; then + support_lastlog=$enableval + fi]) + +if test x$support_utmp = xyes; then + AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support) +fi +if test x$support_wtmp = xyes; then + AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled) +fi +if test x$support_lastlog = xyes; then + AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled) +fi + AC_CHECK_FUNCS( \ ttyslot \ updwtmp \ @@ -178,6 +214,7 @@ dnl# find utmp AC_CACHE_CHECK(where utmp is located, path_utmp, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include #include #include #include @@ -214,6 +251,7 @@ dnl# a day newer, then dump the utmpx. People leave lots of junk around. AC_CACHE_CHECK(where utmpx is located, path_utmpx, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include #include #include #include @@ -259,6 +297,7 @@ dnl# find wtmp AC_CACHE_CHECK(where wtmp is located, path_wtmp, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include #include #ifdef HAVE_UTMP_H #include @@ -295,6 +334,7 @@ dnl# find wtmpx AC_CACHE_CHECK(where wtmpx is located, path_wtmpx, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include #ifdef HAVE_UTMPX_H #include #endif @@ -330,6 +370,7 @@ dnl# find lastlog AC_CACHE_CHECK(where lastlog is located, path_lastlog, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include #include #ifdef HAVE_UTMPX_H #include @@ -373,6 +414,7 @@ dnl# find lastlogx AC_CACHE_CHECK(where lastlogx is located, path_lastlogx, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include #ifdef HAVE_UTMPX_H #include #endif @@ -408,7 +450,7 @@ [ AC_CACHE_CHECK(for unix-compliant filehandle passing ability, can_pass_fds, [AC_TRY_LINK([ -#include // broken bsds (is that redundant) need this +#include // broken bsds (is that redundant?) need this #include #include #include @@ -443,3 +485,33 @@ AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) fi ]) + +AC_DEFUN([TTY_GROUP_CHECK], +[ +AC_CACHE_CHECK([for tty group], tty_group, +[AC_TRY_RUN([ +#include +#include +#include +#include + +main() +{ + struct stat st; + struct group *gr; + char *tty; + gr = getgrnam("tty"); + tty = ttyname(0); + if (gr != 0 + && tty != 0 + && (stat(tty, &st)) == 0 + && st.st_gid == gr->gr_gid) + return 0; + else + return 1; +}], +[tty_group=yes],[tty_group=no],[tty_group=no])]) +if test x$tty_group = xyes; then + AC_DEFINE(TTY_GID_SUPPORT, 1, "") +fi]) +