AM_CONDITIONAL(USE_SLANG, test "x$use_slang" = xyes)
+AC_ARG_WITH([utempter],
+ AS_HELP_STRING([--with-utempter], [compile script(1) with libutempter]),
+ [], with_utempter=no
+)
+
+if test "x$with_utempter" = xyes; then
+ UTIL_CHECK_LIB(utempter, utempter_add_record)
+ if test "x$have_utempter" = xno; then
+ AC_MSG_ERROR([utempter selected but libutempter not found])
+ fi
+else
+ AM_CONDITIONAL(HAVE_UTEMPTER, false)
+fi
+
+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _XOPEN_SOURCE
#include <unistd.h>
EXTRA_DIST += README.cal README.ddate README.namei README.namei2
mcookie_SOURCES = mcookie.c ../lib/md5.c
+script_LDADD =
usrbin_exec_SCRIPTS = chkdupexe
endif
if HAVE_UTIL
-script_LDADD = -lutil
+script_LDADD += -lutil
+endif
+
+if HAVE_UTEMPTER
+script_LDADD += -lutempter
endif
if HAVE_NCURSES
#include "nls.h"
-
#ifdef HAVE_LIBUTIL
#include <pty.h>
#endif
+#ifdef HAVE_LIBUTEMPTER
+#include <utempter.h>
+#endif
+
void finish(int);
void done(void);
void fail(void);
char *shell;
FILE *fscript;
-int master;
+int master = -1;
int slave;
int child;
int subchild;
printf(_("Script started, file is %s\n"), fname);
fixtty();
+#ifdef HAVE_LIBUTEMPTER
+ utempter_add_record(master, NULL);
+#endif
/* setup SIGCHLD handler */
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
(void) dup2(slave, 2);
(void) close(slave);
+ master = -1;
+
shname = strrchr(shell, '/');
if (shname)
shname++;
}
(void) fclose(fscript);
(void) close(master);
+
+ master = -1;
} else {
(void) tcsetattr(0, TCSADRAIN, &tt);
if (!qflg)
printf(_("Script done, file is %s\n"), fname);
+#ifdef HAVE_LIBUTEMPTER
+ if (master >= 0)
+ utempter_remove_record(master);
+#endif
}
if(eflg) {
return;
}
(void) close(master);
+ master = -1;
}
}
}
+ master = -1;
fprintf(stderr, _("Out of pty's\n"));
fail();
#endif /* not HAVE_LIBUTIL */