diff -ru rxvt-2.7.10.orig/autoconf/Make.common.in rxvt-2.7.10/autoconf/Make.common.in --- rxvt-2.7.10.orig/autoconf/Make.common.in Fri Nov 30 12:22:56 2001 +++ rxvt-2.7.10/autoconf/Make.common.in Sun Dec 7 16:11:24 2003 @@ -52,11 +52,11 @@ # Flags & libs # add -DBINDIR=\""$(bindir)/"\" to CPPFLAGS, if we need to spawn a program -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ @LIBSPT_CFLAGS@ CPPFLAGS = @CPPFLAGS@ @XPM_CPPFLAGS@ LDFLAGS = @LDFLAGS@ DEFS = @DEFS@ -LIBS = @LIBS@ +LIBS = @LIBS@ @LIBSPT_LIBS@ DINCLUDE = @DINCLUDE@ DLIB = @DLIB@ diff -ru rxvt-2.7.10.orig/autoconf/config.h.in rxvt-2.7.10/autoconf/config.h.in --- rxvt-2.7.10.orig/autoconf/config.h.in Thu Feb 20 09:35:55 2003 +++ rxvt-2.7.10/autoconf/config.h.in Sun Dec 7 16:10:49 2003 @@ -291,6 +291,9 @@ /* Define for this pty type */ #undef PTYS_ARE__GETPTY +/* Define if you want to use libspt */ +#undef USE_LIBSPT + /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE diff -ru rxvt-2.7.10.orig/autoconf/configure.in rxvt-2.7.10/autoconf/configure.in --- rxvt-2.7.10.orig/autoconf/configure.in Fri Mar 7 11:32:27 2003 +++ rxvt-2.7.10/autoconf/configure.in Sun Dec 7 16:11:24 2003 @@ -309,6 +309,14 @@ AC_DEFINE(TTY_256COLOR, 1, Define if you want 256 colour support) fi]) +AC_ARG_ENABLE(libspt, + [ --enable-libspt enable libspt support (experimental)], + [if test x$enableval = xyes; then + AC_DEFINE(USE_LIBSPT) + LIBSPT_CFLAGS="`libspt-config --cflags`" + LIBSPT_LIBS="`libspt-config --libs`" + fi]) + AC_ARG_WITH(term, [ --with-term=NAME set the terminal to NAME (default \"xterm\")], [if test x$withval != x; then @@ -1152,6 +1160,7 @@ AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(X_CFLAGS) +AC_SUBST(LIBSPT_CFLAGS) dnl# Attack the libs if test x$rxvt_cv_rpath = xyes -o x$rxvt_cv_R = xyes; then @@ -1165,6 +1174,7 @@ AC_SUBST(LIBS) AC_SUBST(X_LIBS) AC_SUBST(X_EXTRA_LIBS) +AC_SUBST(LIBSPT_LIBS) if test x$support_addstrings = xyes; then OBJSTRINGS="strings.o" diff -ru rxvt-2.7.10.orig/src/init.c rxvt-2.7.10/src/init.c --- rxvt-2.7.10.orig/src/init.c Wed Dec 4 14:21:39 2002 +++ rxvt-2.7.10/src/init.c Sun Dec 7 16:43:27 2003 @@ -1241,6 +1241,7 @@ { int i, cfd; +#ifndef USE_LIBSPT /* need connection between libspt and agent */ /* * Close all unused file descriptors * We don't want them, we don't need them. @@ -1262,6 +1263,7 @@ continue; close(i); } +#endif /* !USE_LIBSPT */ if ((r->Xfd < STDERR_FILENO + 1 #ifdef FD_SETSIZE || r->Xfd > FD_SETSIZE @@ -1271,6 +1273,24 @@ r->Xfd = STDERR_FILENO + 1; } +#ifdef USE_LIBSPT + int res; + res = spt_open_pty(&r->h->spth, &cfd, NULL, NULL); + if (res != SPT_E_NONE && res != SPT_E_CHOWN_FAIL) { + rxvt_print_error("can't open pseudo-tty"); + return -1; + } + fcntl(cfd, F_SETFL, O_NDELAY); + + if ((r->tty_fd = spt_open_slave(r->h->spth)) < 0) { + spt_close_pty(r->h->spth); + rxvt_print_error("can't open slave tty"); + return -1; + } + spt_init_slavefd(r->h->spth, r->tty_fd); + spt_termios_fd_default(r->tty_fd); /* both get and set are done here */ + +#else /* !USE_LIBSPT */ /* get master (pty) */ if ((cfd = rxvt_get_pty(&(r->tty_fd), &(r->h->ttydev))) < 0) { rxvt_print_error("can't open pseudo-tty"); @@ -1295,6 +1315,7 @@ } } rxvt_get_ttymode(&(r->h->tio)); +#endif /* !USE_LIBSPT */ /* install exit handler for cleanup */ #ifdef HAVE_ATEXIT @@ -1323,12 +1344,33 @@ rxvt_print_error("can't fork"); return -1; case 0: +#ifdef USE_LIBSPT + spt_detach_handle(r->h->spth); + /* no communication with agent here; now close them */ + r->h->spth = NULL; /* just in case */ + for (i = 0; i < r->num_fds; i++) { + if (i == STDERR_FILENO || i == r->tty_fd +#ifdef __sgi /* Alex Coventry says we need 4 & 7 too */ + || i == 4 || i == 7 +#endif + ) + continue; + close(i); + } +#else close(cfd); /* only keep r->tty_fd and STDERR open */ close(r->Xfd); +#endif #ifdef __QNX__ rxvt_run_child(r, argv); #else - if (rxvt_control_tty(r->tty_fd, r->h->ttydev) < 0) + if ( +#ifdef USE_LIBSPT + spt_detach_ctty() || spt_set_ctty2(r->tty_fd) +#else + rxvt_control_tty(r->tty_fd, r->h->ttydev) < 0 +#endif + ) rxvt_print_error("could not obtain control of tty"); else { /* Reopen stdin, stdout and stderr over the tty file descriptor */ @@ -1364,7 +1406,13 @@ #endif r->num_fds++; /* counts from 0 */ +#ifdef USE_LIBSPT + spt_utmp_set_host(r->h->spth, r->h->rs[Rs_display_name]); + spt_utmp_set_pid(r->h->spth, r->h->cmd_pid); + spt_login_utmp(r->h->spth); +#else rxvt_privileged_utmp(r, SAVE); +#endif return cfd; } @@ -1381,7 +1429,9 @@ { char *login; +#ifndef USE_LIBSPT SET_TTYMODE(STDIN_FILENO, &(r->h->tio)); /* init terminal attributes */ +#endif if (r->Options & Opt_console) { /* be virtual console, fail silently */ #ifdef TIOCCONS @@ -1489,6 +1539,7 @@ return -1; } +#ifndef USE_LIBSPT /* ------------------------------------------------------------------------- * * GET TTY CURRENT STATE * * ------------------------------------------------------------------------- */ @@ -1680,5 +1731,6 @@ # endif /* HAVE_TERMIOS_H */ #endif /* DEBUG_TTYMODE */ } +#endif /* !USE_LIBSPT */ /*----------------------- end-of-file (C source) -----------------------*/ diff -ru rxvt-2.7.10.orig/src/logging.c rxvt-2.7.10/src/logging.c --- rxvt-2.7.10.orig/src/logging.c Mon Dec 16 09:33:04 2002 +++ rxvt-2.7.10/src/logging.c Sun Dec 7 16:11:24 2003 @@ -41,6 +41,7 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ +#ifndef USE_LIBSPT #include "logging.h" #ifdef UTMP_SUPPORT @@ -426,3 +427,4 @@ /* ------------------------------------------------------------------------- */ #endif /* UTMP_SUPPORT */ +#endif /* !USE_LIBSPT */ diff -ru rxvt-2.7.10.orig/src/main.c rxvt-2.7.10/src/main.c --- rxvt-2.7.10.orig/src/main.c Thu Oct 24 10:52:33 2002 +++ rxvt-2.7.10/src/main.c Sun Dec 7 16:11:24 2003 @@ -67,8 +67,10 @@ * 1. write utmp entries on some systems * 2. chown tty on some systems */ +#ifndef USE_LIBSPT rxvt_privileges(r, SAVE); rxvt_privileges(r, IGNORE); +#endif rxvt_init_secondary(r); @@ -192,8 +194,15 @@ #ifdef DEBUG_SCREEN rxvt_scr_release(r); #endif +#ifdef USE_LIBSPT + if (r->h->spth && r->h->cmd_pid > 0) { + spt_logout_utmp(r->h->spth); + spt_close_pty(r->h->spth); + } +#else rxvt_privileged_ttydev(r, RESTORE); rxvt_privileged_utmp(r, RESTORE); +#endif #ifdef USE_XIM if (r->h->Input_Context != NULL) { XDestroyIC(r->h->Input_Context); @@ -255,6 +264,7 @@ exit(EXIT_FAILURE); /* NOTREACHED */ } +#ifndef USE_LIBSPT /* ------------------------------------------------------------------------- * * PRIVILEGED OPERATIONS * * ------------------------------------------------------------------------- */ @@ -381,6 +391,7 @@ # endif } #endif +#endif /* !USE_LIBSPT */ /*----------------------------------------------------------------------*/ /* diff -ru rxvt-2.7.10.orig/src/ptytty.c rxvt-2.7.10/src/ptytty.c --- rxvt-2.7.10.orig/src/ptytty.c Thu Sep 19 16:40:39 2002 +++ rxvt-2.7.10/src/ptytty.c Sun Dec 7 16:11:24 2003 @@ -50,6 +50,9 @@ # include /* for I_PUSH */ #endif +#ifdef USE_LIBSPT +# include +#endif #ifdef DEBUG_TTY # define D_TTY(x) fprintf x ; fputc('\n', stderr) ; fflush(stderr) @@ -57,6 +60,7 @@ # define D_TTY(x) #endif +#ifndef USE_LIBSPT /* ------------------------------------------------------------------------- * * GET PSEUDO TELETYPE - MASTER AND SLAVE * * ------------------------------------------------------------------------- */ @@ -189,6 +193,7 @@ #endif return -1; } +#endif /* !USE_LIBSPT */ /*----------------------------------------------------------------------*/ /* @@ -201,6 +206,7 @@ return open(ttydev, O_RDWR | O_NOCTTY, 0); } +#ifndef USE_LIBSPT /*----------------------------------------------------------------------*/ /* * Make our tty a controlling tty so that /dev/tty points to us @@ -290,4 +296,5 @@ #endif /* ! __QNX__ */ return 0; } +#endif /* !USE_LIBSPT */ /*----------------------- end-of-file (C source) -----------------------*/ diff -ru rxvt-2.7.10.orig/src/rxvt.h rxvt-2.7.10/src/rxvt.h --- rxvt-2.7.10.orig/src/rxvt.h Fri Mar 7 10:17:18 2003 +++ rxvt-2.7.10/src/rxvt.h Sun Dec 7 16:12:19 2003 @@ -34,6 +34,10 @@ typedef char *XPointer; #endif +#ifdef USE_LIBSPT +# include +typedef struct ttymode_t_dummy_for_prototype ttymode_t; +#else /* !USE_LIBSPT */ #ifdef HAVE_TERMIOS_H # include typedef struct termios ttymode_t; @@ -47,6 +51,7 @@ int local; } ttymode_t; #endif +#endif /* !USE_LIBSPT */ #ifdef GREEK_SUPPORT # include "grkelot.h" @@ -803,6 +808,7 @@ #define rxvt_Gr_ButtonPress(x,y) rxvt_Gr_ButtonReport (r, 'P',(x),(y)) #define rxvt_Gr_ButtonRelease(x,y) rxvt_Gr_ButtonReport (r, 'R',(x),(y)) +#ifndef USE_LIBSPT #ifdef UTMP_SUPPORT # if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) # undef HAVE_UTMPX_H @@ -820,6 +826,7 @@ # include # endif #endif +#endif /* USE_LIBSPT */ #ifdef DEBUG_CMD # define D_CMD(x) fprintf x ; fputc('\n', stderr) @@ -1007,7 +1014,12 @@ /* ---------- */ Cursor cursor_leftptr; /* ---------- */ +#ifdef USE_LIBSPT + spt_handle *spth; +#endif +#ifndef USE_LIBSPT const char *ttydev; /* pty/tty name */ +#endif #ifndef NO_BACKSPACE_KEY const char *key_backspace; #endif @@ -1031,6 +1043,7 @@ int graphics_up; struct grwin_t *gr_root; #endif +#ifndef USE_LIBSPT ttymode_t tio; #ifdef UTMP_SUPPORT # ifdef HAVE_STRUCT_UTMP @@ -1044,6 +1057,7 @@ # endif int utmp_pos; #endif +#endif /* !USE_LIBSPT */ row_col_t oldcursor; #ifdef XPM_BACKGROUND bgPixmap_t bgPixmap;