Added support for systems that have utmpx.h, but don't implement updwtmpx().
git-svn-id: https://shellinabox.googlecode.com/svn/trunk@207 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
parent
d1df9b6441
commit
83621919cd
9 changed files with 106 additions and 6 deletions
|
@ -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>
|
2010-07-02 Markus Gutschke <markus@shellinabox.com>
|
||||||
|
|
||||||
* Fixed a NULL pointer dereference that can occur when hostnames
|
* Fixed a NULL pointer dereference that can occur when hostnames
|
||||||
|
|
8
config.h
8
config.h
|
@ -106,6 +106,12 @@
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#define HAVE_UNISTD_H 1
|
#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. */
|
/* Define to 1 if you have the <util.h> header file. */
|
||||||
/* #undef HAVE_UTIL_H */
|
/* #undef HAVE_UTIL_H */
|
||||||
|
|
||||||
|
@ -147,7 +153,7 @@
|
||||||
#define STDC_HEADERS 1
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
/* Most recent revision number in the version control system */
|
/* Most recent revision number in the version control system */
|
||||||
#define VCS_REVISION "206"
|
#define VCS_REVISION "207"
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#define VERSION "2.10"
|
#define VERSION "2.10"
|
||||||
|
|
|
@ -105,6 +105,12 @@
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#undef HAVE_UNISTD_H
|
#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. */
|
/* Define to 1 if you have the <util.h> header file. */
|
||||||
#undef HAVE_UTIL_H
|
#undef HAVE_UTIL_H
|
||||||
|
|
||||||
|
|
39
configure
vendored
39
configure
vendored
|
@ -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
|
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||||
|
|
||||||
|
|
||||||
VCS_REVISION=206
|
VCS_REVISION=207
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
@ -10729,6 +10729,43 @@ if ac_fn_c_try_link "$LINENO"; then :
|
||||||
|
|
||||||
$as_echo "#define HAVE_ISNAN 1" >>confdefs.h
|
$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
|
fi
|
||||||
rm -f core conftest.err conftest.$ac_objext \
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
conftest$ac_exeext conftest.$ac_ext
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
|
12
configure.ac
12
configure.ac
|
@ -2,7 +2,7 @@ AC_PREREQ(2.57)
|
||||||
|
|
||||||
dnl This is the one location where the authoritative version number is stored
|
dnl This is the one location where the authoritative version number is stored
|
||||||
AC_INIT(shellinabox, 2.10, markus@shellinabox.com)
|
AC_INIT(shellinabox, 2.10, markus@shellinabox.com)
|
||||||
VCS_REVISION=206
|
VCS_REVISION=207
|
||||||
AC_SUBST(VCS_REVISION)
|
AC_SUBST(VCS_REVISION)
|
||||||
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
|
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
|
||||||
[Most recent revision number in the version control system])
|
[Most recent revision number in the version control system])
|
||||||
|
@ -61,6 +61,16 @@ AC_TRY_LINK([#include <math.h>],
|
||||||
[AC_DEFINE(HAVE_ISNAN, 1,
|
[AC_DEFINE(HAVE_ISNAN, 1,
|
||||||
Define to 1 if you have support for isnan)])
|
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 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.
|
dnl feature, if the user tells us that it does not do the right thing.
|
||||||
AC_ARG_ENABLE(login,
|
AC_ARG_ENABLE(login,
|
||||||
|
|
|
@ -1955,7 +1955,7 @@ VT100.prototype.toggleBell = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
VT100.prototype.about = 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" +
|
"\nCopyright 2008-2010 by Markus Gutschke\n" +
|
||||||
"For more information check http://shellinabox.com");
|
"For more information check http://shellinabox.com");
|
||||||
};
|
};
|
||||||
|
|
|
@ -495,6 +495,33 @@ struct Utmp *newUtmp(int useLogin, const char *ptyPath,
|
||||||
return utmp;
|
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) {
|
void destroyUtmp(struct Utmp *utmp) {
|
||||||
if (utmp) {
|
if (utmp) {
|
||||||
if (utmp->pty >= 0) {
|
if (utmp->pty >= 0) {
|
||||||
|
@ -518,9 +545,12 @@ void destroyUtmp(struct Utmp *utmp) {
|
||||||
setutxent();
|
setutxent();
|
||||||
pututxline(&utmp->utmpx);
|
pututxline(&utmp->utmpx);
|
||||||
endutxent();
|
endutxent();
|
||||||
|
|
||||||
|
#if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX)
|
||||||
if (!utmp->useLogin) {
|
if (!utmp->useLogin) {
|
||||||
updwtmpx("/var/log/wtmp", &utmp->utmpx);
|
updwtmpx("/var/log/wtmp", &utmp->utmpx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Switch back to the lower privileges
|
// Switch back to the lower privileges
|
||||||
check(!setresgid(r_gid, e_gid, s_gid));
|
check(!setresgid(r_gid, e_gid, s_gid));
|
||||||
|
@ -1043,7 +1073,10 @@ static pam_handle_t *internalLogin(struct Service *service, struct Utmp *utmp,
|
||||||
setutxent();
|
setutxent();
|
||||||
pututxline(&utmp->utmpx);
|
pututxline(&utmp->utmpx);
|
||||||
endutxent();
|
endutxent();
|
||||||
|
|
||||||
|
#if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX)
|
||||||
updwtmpx("/var/log/wtmp", &utmp->utmpx);
|
updwtmpx("/var/log/wtmp", &utmp->utmpx);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1339,11 +1372,14 @@ static void childProcess(struct Service *service, int width, int height,
|
||||||
}
|
}
|
||||||
pututxline(&utmpx);
|
pututxline(&utmpx);
|
||||||
endutxent();
|
endutxent();
|
||||||
|
|
||||||
|
#if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX)
|
||||||
if (!utmp->useLogin) {
|
if (!utmp->useLogin) {
|
||||||
memset(&utmpx.ut_user, 0, sizeof(utmpx.ut_user));
|
memset(&utmpx.ut_user, 0, sizeof(utmpx.ut_user));
|
||||||
strncat(&utmpx.ut_user[0], "LOGIN", sizeof(utmpx.ut_user));
|
strncat(&utmpx.ut_user[0], "LOGIN", sizeof(utmpx.ut_user));
|
||||||
updwtmpx("/var/log/wtmp", &utmpx);
|
updwtmpx("/var/log/wtmp", &utmpx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create session. We might have to fork another process as PAM wants us
|
// Create session. We might have to fork another process as PAM wants us
|
||||||
|
|
|
@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ShellInABox.prototype.about = function() {
|
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" +
|
"\nCopyright 2008-2010 by Markus Gutschke\n" +
|
||||||
"For more information check http://shellinabox.com" +
|
"For more information check http://shellinabox.com" +
|
||||||
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
|
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
|
||||||
|
|
|
@ -1955,7 +1955,7 @@ VT100.prototype.toggleBell = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
VT100.prototype.about = 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" +
|
"\nCopyright 2008-2010 by Markus Gutschke\n" +
|
||||||
"For more information check http://shellinabox.com");
|
"For more information check http://shellinabox.com");
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue