]> andersk Git - test.git/commitdiff
Added support for systems that have utmpx.h, but don't implement updwtmpx().
authorMarkus Gutschke <markus@shellinabox.com>
Thu, 8 Jul 2010 17:54:15 +0000 (17:54 +0000)
committerMarkus Gutschke <markus@shellinabox.com>
Thu, 8 Jul 2010 17:54:15 +0000 (17:54 +0000)
ChangeLog
config.h
config.h.in
configure
configure.ac
demo/vt100.js
shellinabox/launcher.c
shellinabox/shell_in_a_box.js
shellinabox/vt100.js

index 4a63b5cff0a717b5e3e43b2878272a340a952797..fe29b31e354e15c77057d49ed7d84051889f43cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-08  Markus Gutschke  <markus@shellinabox.com>
+
+       * Added support for systems that have utmpx.h, but don't implement
+       updwtmpx().
+
 2010-07-02  Markus Gutschke  <markus@shellinabox.com>
 
        * Fixed a NULL pointer dereference that can occur when hostnames
index 34d2cd643fdd602f960a071189c237025cfe7f8d..df0cfbbb0c8142207c8e3149a404c857c9eb3677 100644 (file)
--- a/config.h
+++ b/config.h
 /* Define to 1 if you have the <unistd.h> header file. */
 #define HAVE_UNISTD_H 1
 
+/* Define to 1 if you have support for updwtmp */
+#define HAVE_UPDWTMP 1
+
+/* Define to 1 if you have support for updwtmpx */
+#define HAVE_UPDWTMPX 1
+
 /* Define to 1 if you have the <util.h> header file. */
 /* #undef HAVE_UTIL_H */
 
 #define STDC_HEADERS 1
 
 /* Most recent revision number in the version control system */
-#define VCS_REVISION "206"
+#define VCS_REVISION "207"
 
 /* Version number of package */
 #define VERSION "2.10"
index 7366ec364cb30044713a67214eab2e4cbd2ab7d9..483b00e74abf29f2d882b867426c50fa11696029 100644 (file)
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have support for updwtmp */
+#undef HAVE_UPDWTMP
+
+/* Define to 1 if you have support for updwtmpx */
+#undef HAVE_UPDWTMPX
+
 /* Define to 1 if you have the <util.h> header file. */
 #undef HAVE_UTIL_H
 
index 18d7ee8bba876e24189537518522cffb72f3ad35..75ae8f9cf7ebdffdce0788d5cd003f143a6b2ea3 100755 (executable)
--- a/configure
+++ b/configure
@@ -2328,7 +2328,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-VCS_REVISION=206
+VCS_REVISION=207
 
 
 cat >>confdefs.h <<_ACEOF
@@ -10729,6 +10729,43 @@ if ac_fn_c_try_link "$LINENO"; then :
 
 $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
 
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <utmp.h>
+int
+main ()
+{
+updwtmp(0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+$as_echo "#define HAVE_UPDWTMP 1" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <utmpx.h>
+int
+main ()
+{
+updwtmpx(0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+$as_echo "#define HAVE_UPDWTMPX 1" >>confdefs.h
+
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
index b1dbc317845a2623fac6ac43694b28ca357209ba..77c23c35fd31e8972ca8b3151fab528084cb7616 100644 (file)
@@ -2,7 +2,7 @@ AC_PREREQ(2.57)
 
 dnl This is the one location where the authoritative version number is stored
 AC_INIT(shellinabox, 2.10, markus@shellinabox.com)
-VCS_REVISION=206
+VCS_REVISION=207
 AC_SUBST(VCS_REVISION)
 AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
                    [Most recent revision number in the version control system])
@@ -61,6 +61,16 @@ AC_TRY_LINK([#include <math.h>],
             [AC_DEFINE(HAVE_ISNAN, 1,
                        Define to 1 if you have support for isnan)])
 
+dnl Even if utmpx.h exists, not all systems have support for updwtmpx()
+AC_TRY_LINK([#include <utmp.h>],
+            [updwtmp(0, 0);],
+            [AC_DEFINE(HAVE_UPDWTMP, 1,
+                       Define to 1 if you have support for updwtmp)])
+AC_TRY_LINK([#include <utmpx.h>],
+            [updwtmpx(0, 0);],
+            [AC_DEFINE(HAVE_UPDWTMPX, 1,
+                       Define to 1 if you have support for updwtmpx)])
+
 dnl On some systems, calling /bin/login does not work. Disable the LOGIN
 dnl feature, if the user tells us that it does not do the right thing.
 AC_ARG_ENABLE(login,
index d62cba0a45ccab992db4e10e810cbc94bedcda93..2a382ac7d6710a5a7b1252ac38b0cc15903c31ee 100644 (file)
@@ -1955,7 +1955,7 @@ VT100.prototype.toggleBell = function() {
 };
 
 VT100.prototype.about = function() {
-  alert("VT100 Terminal Emulator " + "2.10 (revision 206)" +
+  alert("VT100 Terminal Emulator " + "2.10 (revision 207)" +
         "\nCopyright 2008-2010 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com");
 };
index f3aff9e7dd00d3bfda43e80244cbe1d2c5fa8048..4ff1c5a6e99768a111d64d902e9bfe461ad3cb89 100644 (file)
@@ -495,6 +495,33 @@ struct Utmp *newUtmp(int useLogin, const char *ptyPath,
   return utmp;
 }
 
+#if defined(HAVE_UPDWTMP) && !defined(HAVE_UPDWTMPX)
+#define min(a,b) ({ typeof(a) _a=(a); typeof(b) _b=(b); _a < _b ? _a : _b; })
+#define updwtmpx x_updwtmpx
+
+static void updwtmpx(const char *wtmpx_file, const struct utmpx *utx) {
+  struct utmp ut   = { 0 };
+  ut.ut_type       = utx->ut_type;
+  ut.ut_pid        = utx->ut_pid;
+  ut.ut_session    = utx->ut_session;
+  ut.ut_tv.tv_sec  = utx->ut_tv.tv_sec;
+  ut.ut_tv.tv_usec = utx->ut_tv.tv_usec;
+  memcpy(&ut.ut_line, &utx->ut_line,
+         min(sizeof(ut.ut_line), sizeof(utx->ut_line)));
+  memcpy(&ut.ut_id, &utx->ut_id,
+         min(sizeof(ut.ut_id), sizeof(utx->ut_id)));
+  memcpy(&ut.ut_user, &utx->ut_user,
+         min(sizeof(ut.ut_user), sizeof(utx->ut_user)));
+  memcpy(&ut.ut_host, &utx->ut_host,
+         min(sizeof(ut.ut_host), sizeof(utx->ut_host)));
+  memcpy(&ut.ut_exit, &utx->ut_exit,
+         min(sizeof(ut.ut_exit), sizeof(utx->ut_exit)));
+  memcpy(&ut.ut_addr_v6, &utx->ut_addr_v6,
+         min(sizeof(ut.ut_addr_v6), sizeof(utx->ut_addr_v6)));
+  updwtmp(wtmpx_file, &ut);
+}
+#endif
+
 void destroyUtmp(struct Utmp *utmp) {
   if (utmp) {
     if (utmp->pty >= 0) {
@@ -518,9 +545,12 @@ void destroyUtmp(struct Utmp *utmp) {
       setutxent();
       pututxline(&utmp->utmpx);
       endutxent();
+
+#if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX)
       if (!utmp->useLogin) {
         updwtmpx("/var/log/wtmp", &utmp->utmpx);
       }
+#endif
       
       // Switch back to the lower privileges
       check(!setresgid(r_gid, e_gid, s_gid));
@@ -1043,7 +1073,10 @@ static pam_handle_t *internalLogin(struct Service *service, struct Utmp *utmp,
     setutxent();
     pututxline(&utmp->utmpx);
     endutxent();
+
+#if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX)
     updwtmpx("/var/log/wtmp", &utmp->utmpx);
+#endif
   }
 #endif
 
@@ -1339,11 +1372,14 @@ static void childProcess(struct Service *service, int width, int height,
   }
   pututxline(&utmpx);
   endutxent();
+
+#if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX)
   if (!utmp->useLogin) {
     memset(&utmpx.ut_user, 0, sizeof(utmpx.ut_user));
     strncat(&utmpx.ut_user[0], "LOGIN", sizeof(utmpx.ut_user));
     updwtmpx("/var/log/wtmp", &utmpx);
   }
+#endif
 #endif
 
   // Create session. We might have to fork another process as PAM wants us
index cd07767d6da712ae88163c3f65534576cb9362d7..4cc7b5dd6e63d74e4e6d3f40fc73a91de0c4f6b8 100644 (file)
@@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
 };
 
 ShellInABox.prototype.about = function() {
-  alert("Shell In A Box version " + "2.10 (revision 206)" +
+  alert("Shell In A Box version " + "2.10 (revision 207)" +
         "\nCopyright 2008-2010 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com" +
         (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
index d62cba0a45ccab992db4e10e810cbc94bedcda93..2a382ac7d6710a5a7b1252ac38b0cc15903c31ee 100644 (file)
@@ -1955,7 +1955,7 @@ VT100.prototype.toggleBell = function() {
 };
 
 VT100.prototype.about = function() {
-  alert("VT100 Terminal Emulator " + "2.10 (revision 206)" +
+  alert("VT100 Terminal Emulator " + "2.10 (revision 207)" +
         "\nCopyright 2008-2010 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com");
 };
This page took 0.059956 seconds and 5 git commands to generate.