head 1.5; access; symbols; locks; strict; comment @# @; 1.5 date 2009.11.22.22.29.22; author rse; state Exp; branches; next 1.4; commitid mvMqgngew7nm8zcu; 1.4 date 2009.04.13.08.07.55; author rse; state Exp; branches; next 1.3; commitid Knb3A3yJdYpfxPJt; 1.3 date 2009.03.23.07.36.25; author rse; state Exp; branches; next 1.2; commitid 4BS3GehbsMFi28Ht; 1.2 date 2009.02.13.23.12.24; author rse; state Exp; branches; next 1.1; commitid 6mPITND2Xbs7rkCt; 1.1 date 2009.01.31.21.38.22; author rse; state Exp; branches; next ; commitid vdGAs047pcVLkEAt; desc @@ 1.5 log @upgrading package: shellinabox 2.9 -> 2.10 @ text @Index: Makefile.in --- Makefile.in.orig 2009-11-21 23:47:39 +0100 +++ Makefile.in 2009-11-22 23:21:53 +0100 @@@@ -1218,8 +1218,6 @@@@ sed -e '/^#ifdef *DPKGBUILD$$/,/^#endif$$/d'; \ fi | \ sed -e '/^#/d' >"$@@" - @@out=`echo "$@@" 2>/dev/null|sed -e 's/\.[^.]*$$/.ps/'`; \ - man -Tps "./$@@" >"$${out}" 2>/dev/null || rm -f "$${out}" clean-local: -rm -rf shellinaboxd.1 \ Index: libhttp/httpconnection.c --- libhttp/httpconnection.c.orig 2009-11-18 17:55:51 +0100 +++ libhttp/httpconnection.c 2009-11-22 23:21:19 +0100 @@@@ -51,6 +51,7 @@@@ #include #include #include +#include #include #include #include Index: libhttp/server.c --- libhttp/server.c.orig 2009-11-18 17:55:51 +0100 +++ libhttp/server.c 2009-11-22 23:21:19 +0100 @@@@ -46,6 +46,7 @@@@ #include "config.h" #include +#include #include #include #include @ 1.4 log @upgrading package: shellinabox 2.5 -> 2.6 @ text @d2 6 a7 6 --- Makefile.in.orig 2009-04-12 19:23:52 +0200 +++ Makefile.in 2009-04-13 09:33:02 +0200 @@@@ -1044,8 +1044,6 @@@@ else \ sed -e '/^#ifdef *HAVE_PAM$$/,/^#endif$$/d' "$$src" >"$@@"; \ fi d14 4 a17 4 --- libhttp/httpconnection.c.orig 2009-03-21 19:58:34 +0100 +++ libhttp/httpconnection.c 2009-04-13 09:33:02 +0200 @@@@ -49,6 +49,7 @@@@ #include d25 2 a26 2 --- libhttp/server.c.orig 2009-03-21 05:22:46 +0100 +++ libhttp/server.c 2009-04-13 09:33:02 +0200 @ 1.3 log @upgrading package: shellinabox 2.4 -> 2.5 @ text @d2 3 a4 12 --- Makefile.in.orig 2009-03-21 16:54:36 +0100 +++ Makefile.in 2009-03-23 08:31:42 +0100 @@@@ -237,7 +237,7 @@@@ top_builddir = @@top_builddir@@ top_srcdir = @@top_srcdir@@ AM_CPPFLAGS = -AM_CFLAGS = -g -std=gnu99 -Wall -Werror -Os +AM_CFLAGS = -g -std=gnu99 -Wall -Werror AM_LDFLAGS = -g noinst_LTLIBRARIES = libhttp.la \ liblogging.la @@@@ -1013,8 +1013,6 @@@@ d14 2 a15 2 --- libhttp/httpconnection.c.orig 2009-03-21 05:23:43 +0100 +++ libhttp/httpconnection.c 2009-03-23 08:31:05 +0100 d26 1 a26 1 +++ libhttp/server.c 2009-03-23 08:31:05 +0100 @ 1.2 log @upgrading package: shellinabox 2.3 -> 2.4 @ text @d2 3 a4 3 --- Makefile.in.orig 2009-02-13 02:52:39 +0100 +++ Makefile.in 2009-02-14 00:06:15 +0100 @@@@ -235,7 +235,7 @@@@ d13 1 a13 2 @@@@ -1001,9 +1001,7 @@@@ -e '/^#endif$$/d' "$$src" >"$@@"; \ d15 4 a18 5 sed -e '/^#ifdef *HAVE_OPENSSL$$/,/^#endif$$/d' "$$src" >"$@@"; \ - fi - @@man -Tps "./$@@" >`echo "$@@" 2>/dev/null|sed -e 's/\.[^.]*$$/.ps/'` \ - || true + fi || true d23 2 a24 2 --- libhttp/httpconnection.c.orig 2009-02-11 23:58:39 +0100 +++ libhttp/httpconnection.c 2009-02-14 00:05:28 +0100 d34 2 a35 2 --- libhttp/server.c.orig 2009-02-11 23:58:48 +0100 +++ libhttp/server.c 2009-02-14 00:05:28 +0100 @ 1.1 log @new package: shellinabox 2.3 (Browser-Based Terminal Emulation) @ text @d2 3 a4 3 --- Makefile.in.orig 2009-01-22 03:40:12 +0100 +++ Makefile.in 2009-01-31 19:57:21 +0100 @@@@ -234,7 +234,7 @@@@ d13 8 a20 23 @@@@ -287,7 +287,7 @@@@ libhttp/libhttp.sym libhttp_la_LDFLAGS = -export-symbols $(top_srcdir)/libhttp/libhttp.sym \ - -version 1:0:0 -ldl + -version 1:0:0 shellinaboxd_SOURCES = shellinabox/shellinaboxd.c \ shellinabox/externalfile.c \ @@@@ -311,7 +311,7 @@@@ shellinaboxd_LDADD = liblogging.la \ libhttp.la -shellinaboxd_LDFLAGS = -static -ldl +shellinaboxd_LDFLAGS = -static all: all-am .SUFFIXES: @@@@ -976,7 +976,6 @@@@ else \ sed -e '/^#ifdef *HAVE_OPENSSL$$/,/^#endif$$/d' "$<" >"$@@"; \ fi - @@man -Tps "./$@@" >`echo "$@@"|sed -e 's/\.[^.]*$$/.ps/'` || true d25 3 a27 3 --- libhttp/httpconnection.c.orig 2009-01-22 00:47:55 +0100 +++ libhttp/httpconnection.c 2009-01-31 19:56:48 +0100 @@@@ -47,6 +47,7 @@@@ d36 4 a39 4 --- libhttp/server.c.orig 2009-01-22 00:47:55 +0100 +++ libhttp/server.c 2009-01-31 19:56:48 +0100 @@@@ -44,6 +44,7 @@@@ // http://shellinabox.com d44 1 a45 234 #include Index: libhttp/ssl.c --- libhttp/ssl.c.orig 2009-01-22 00:47:55 +0100 +++ libhttp/ssl.c 2009-01-31 19:56:48 +0100 @@@@ -167,10 +167,14 @@@@ void *dl = RTLD_DEFAULT; void *rc = dlsym(dl, fn); if (!rc) { +#ifdef RTLD_NOLOAD dl = dlopen(lib, RTLD_LAZY|RTLD_GLOBAL|RTLD_NOLOAD); if (dl == NULL) { +#endif dl = dlopen(lib, RTLD_LAZY|RTLD_GLOBAL); +#ifdef RTLD_NOLOAD } +#endif if (dl != NULL) { rc = dlsym(dl, fn); } @@@@ -548,9 +552,11 @@@@ (dsaSize > 0 && !SSL_CTX_use_PrivateKey_ASN1(EVP_PKEY_DSA, ssl->sslContext, dsa, dsaSize)) || +#ifdef EVP_PKEY_EC (ecSize > 0 && !SSL_CTX_use_PrivateKey_ASN1(EVP_PKEY_EC, ssl->sslContext, ec, ecSize)) || +#endif !SSL_CTX_check_private_key(ssl->sslContext)) { fatal("Cannot read valid certificate from fd %d. Check file format.", fd); } Index: shellinabox/externalfile.c --- shellinabox/externalfile.c.orig 2009-01-22 00:47:56 +0100 +++ shellinabox/externalfile.c 2009-01-31 19:56:48 +0100 @@@@ -99,7 +99,11 @@@@ } // Open file for reading +#ifdef O_LARGEFILE int fd = NOINTR(open(fn, O_RDONLY|O_LARGEFILE)); +#else + int fd = NOINTR(open(fn, O_RDONLY)); +#endif // Recognize a couple of common MIME types static const struct { @@@@ -141,9 +145,9 @@@@ // We only serve regular files, and restrict the file size to 100MB. // As a special-case, we also allow access to /dev/null. - struct stat64 sb = { 0 }; + struct stat sb = { 0 }; if (strcmp(fn, "/dev/null") && - (fstat64(fd, &sb) || + (fstat(fd, &sb) || !S_ISREG(sb.st_mode) || sb.st_size > (100 << 20))) { free(fn); Index: shellinabox/launcher.c --- shellinabox/launcher.c.orig 2009-01-22 00:47:56 +0100 +++ shellinabox/launcher.c 2009-01-31 19:56:48 +0100 @@@@ -62,7 +62,10 @@@@ #include #include #include +#ifdef __linux__ #include +#endif +#include #if defined(HAVE_SECURITY_PAM_APPL_H) && defined(HAVE_SECURITY_PAM_MISC_H) #include @@@@ -228,7 +231,9 @@@@ const char pid[32]; int pty; int useLogin; +#ifdef __linux__ struct utmpx utmpx; +#endif }; static HashMap *childProcesses; @@@@ -238,16 +243,22 @@@@ memset(utmp, 0, sizeof(struct Utmp)); utmp->pty = -1; utmp->useLogin = useLogin; +#ifdef __linux__ utmp->utmpx.ut_type = useLogin ? LOGIN_PROCESS : USER_PROCESS; +#endif dcheck(!strncmp(ptyPath, "/dev/pts", 8)); +#ifdef __linux__ strncat(&utmp->utmpx.ut_line[0], ptyPath + 5, sizeof(utmp->utmpx.ut_line)); strncat(&utmp->utmpx.ut_id[0], ptyPath + 8, sizeof(utmp->utmpx.ut_id)); strncat(&utmp->utmpx.ut_user[0], "SHELLINABOX", sizeof(utmp->utmpx.ut_user)); strncat(&utmp->utmpx.ut_host[0], peerName, sizeof(utmp->utmpx.ut_host)); +#endif struct timeval tv; check(!gettimeofday(&tv, NULL)); +#ifdef __linux__ utmp->utmpx.ut_tv.tv_sec = tv.tv_sec; utmp->utmpx.ut_tv.tv_usec = tv.tv_usec; +#endif } struct Utmp *newUtmp(int useLogin, const char *ptyPath, @@@@ -259,6 +270,7 @@@@ } void destroyUtmp(struct Utmp *utmp) { +#ifdef __linux__ if (utmp) { if (utmp->pty >= 0) { utmp->utmpx.ut_type = DEAD_PROCESS; @@@@ -291,6 +303,7 @@@@ NOINTR(close(utmp->pty)); } } +#endif } void deleteUtmp(struct Utmp *utmp) { @@@@ -359,11 +372,23 @@@@ static int forkPty(int *pty, int useLogin, struct Utmp **utmp, const char *peerName) { int slave; +#ifdef __linux__ char ptyPath[PATH_MAX]; +#else + char *ptyPath; +#endif +#ifdef __linux__ if ((*pty = getpt()) < 0 || +#else + if ((*pty = posix_openpt(O_RDWR)) < 0 || +#endif grantpt(*pty) < 0 || unlockpt(*pty) < 0 || +#ifdef __linux__ ptsname_r(*pty, ptyPath, sizeof(ptyPath)) < 0 || +#else + (ptyPath = ptsname(*pty)) == NULL || +#endif (slave = NOINTR(open(ptyPath, O_RDWR|O_NOCTTY))) < 0) { if (*pty >= 0) { NOINTR(close(*pty)); @@@@ -388,8 +413,10 @@@@ } else if (pid == 0) { pid = getpid(); snprintf((char *)&(*utmp)->pid[0], sizeof((*utmp)->pid), "%d", pid); +#ifdef __linux__ (*utmp)->utmpx.ut_pid = pid; (*utmp)->pty = slave; +#endif closeAllFds((int []){ slave }, 1); @@@@ -411,9 +438,11 @@@@ return 0; } else { +#ifdef __linux__ snprintf((char *)&(*utmp)->pid[0], sizeof((*utmp)->pid), "%d", pid); (*utmp)->utmpx.ut_pid = pid; (*utmp)->pty = *pty; +#endif fcntl(*pty, F_SETFL, O_NONBLOCK|O_RDWR); NOINTR(close(slave)); return pid; @@@@ -608,12 +637,14 @@@@ free((void *)pw); // Update utmp/wtmp entries +#ifdef __linux__ memset(&utmp->utmpx.ut_user, 0, sizeof(utmp->utmpx.ut_user)); strncat(&utmp->utmpx.ut_user[0], service->user, sizeof(utmp->utmpx.ut_user)); setutxent(); pututxline(&utmp->utmpx); endutxent(); updwtmpx("/var/log/wtmp", &utmp->utmpx); +#endif alarm(0); return pam; @@@@ -849,6 +880,7 @@@@ // Assert root privileges in order to update utmp entry. setresuid(0, 0, 0); setresgid(0, 0, 0); +#ifdef __linux__ setutxent(); struct utmpx utmpx = utmp->utmpx; if (service->useLogin || service->authUser) { @@@@ -862,6 +894,7 @@@@ strncat(&utmpx.ut_user[0], "LOGIN", sizeof(utmpx.ut_user)); updwtmpx("/var/log/wtmp", &utmpx); } +#endif // Create session. We might have to fork another process as PAM wants us // to close the session when the child terminates. And we must retain Index: shellinabox/shellinaboxd.c --- shellinabox/shellinaboxd.c.orig 2009-01-22 03:38:22 +0100 +++ shellinabox/shellinaboxd.c 2009-01-31 19:56:48 +0100 @@@@ -54,7 +54,9 @@@@ #include #include #include +#ifdef __linux__ #include +#endif #include #include #include @@@@ -853,7 +855,11 @@@@ setsid(); if (pidfile) { int fd = NOINTR(open(pidfile, +#ifdef O_LARGEFILE O_WRONLY|O_TRUNC|O_LARGEFILE|O_CREAT, +#else + O_WRONLY|O_TRUNC|O_CREAT, +#endif 0644)); if (fd >= 0) { char buf[40]; @@@@ -906,7 +912,9 @@@@ int main(int argc, char * const argv[]) { // Disable core files +#ifdef __linux__ prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); +#endif removeLimits(); // Parse command line arguments @