OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /v/openpkg/cvs Email: r...@openpkg.org Module: openpkg-src Date: 31-Jan-2009 22:38:22 Branch: HEAD Handle: 2009013121382200 Added files: openpkg-src/shellinabox shellinabox.patch shellinabox.spec Log: new package: shellinabox 2.3 (Browser-Based Terminal Emulation) Summary: Revision Changes Path 1.1 +293 -0 openpkg-src/shellinabox/shellinabox.patch 1.1 +89 -0 openpkg-src/shellinabox/shellinabox.spec ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/shellinabox/shellinabox.patch ============================================================================ $ cvs diff -u -r0 -r1.1 shellinabox.patch --- /dev/null 2009-01-31 22:38:21 +0100 +++ shellinabox.patch 2009-01-31 22:38:22 +0100 @@ -0,0 +1,293 @@ +Index: Makefile.in +--- Makefile.in.orig 2009-01-22 03:40:12 +0100 ++++ Makefile.in 2009-01-31 19:57:21 +0100 +@@ -234,7 +234,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 +@@ -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 + + clean-local: + -rm -rf shellinaboxd.1 \ +Index: libhttp/httpconnection.c +--- 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 @@ + #include <arpa/inet.h> + #include <netdb.h> + #include <netinet/in.h> ++#include <sys/socket.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +Index: libhttp/server.c +--- 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 + + #include <arpa/inet.h> ++#include <netinet/in.h> + #include <fcntl.h> + #include <stdlib.h> + #include <string.h> +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 <sys/utsname.h> + #include <termios.h> + #include <unistd.h> ++#ifdef __linux__ + #include <utmpx.h> ++#endif ++#include <signal.h> + + #if defined(HAVE_SECURITY_PAM_APPL_H) && defined(HAVE_SECURITY_PAM_MISC_H) + #include <security/pam_appl.h> +@@ -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 <stdio.h> + #include <stdlib.h> + #include <string.h> ++#ifdef __linux__ + #include <sys/prctl.h> ++#endif + #include <sys/resource.h> + #include <sys/types.h> + #include <sys/stat.h> +@@ -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 @@ . patch -p0 <<'@@ .' Index: openpkg-src/shellinabox/shellinabox.spec ============================================================================ $ cvs diff -u -r0 -r1.1 shellinabox.spec --- /dev/null 2009-01-31 22:38:21 +0100 +++ shellinabox.spec 2009-01-31 22:38:22 +0100 @@ -0,0 +1,89 @@ +## +## shellinabox.spec -- OpenPKG RPM Package Specification +## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/> +## +## Permission to use, copy, modify, and distribute this software for +## any purpose with or without fee is hereby granted, provided that +## the above copyright notice and this permission notice appear in all +## copies. +## +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## SUCH DAMAGE. +## + +# package information +Name: shellinabox +Summary: Browser-Based Terminal Emulation +URL: http://code.google.com/p/shellinabox/ +Vendor: Markus Gutschke +Packager: OpenPKG Foundation e.V. +Distribution: OpenPKG Community +Class: EVAL +Group: Terminal +License: GPL +Version: 2.3 +Release: 20090131 + +# list of sources +Source0: http://shellinabox.googlecode.com/files/shellinabox-%{version}.tar.gz +Patch0: shellinabox.patch + +# build information +Prefix: %{l_prefix} +BuildRoot: %{l_buildroot} +BuildPreReq: OpenPKG, openpkg >= 20060823 +PreReq: OpenPKG, openpkg >= 20060823 +BuildPreReq: openssl +PreReq: openssl +AutoReq: no +AutoReqProv: no + +%description + Shell In A Box implements a small web server that can export + arbitrary command line tools to a web based terminal emulator. This + emulator is accessible to any JavaScript and CSS enabled web browser + and does not require any additional browser plugins. + +%track + prog shellinabox = { + version = %{version} + url = ftp://ftp.shellinabox.org/pub/shellinabox/ + regex = shellinabox-(__VER__)\.tar\.gz + } + +%prep + %setup -q + %patch -p0 + +%build + CC="%{l_cc}" \ + CFLAGS="%{l_cflags -O}" \ + CPPFLAGS="%{l_cppflags}" \ + LDFLAGS="%{l_ldflags}" \ + ./configure \ + --prefix=%{l_prefix} \ + --mandir=%{l_prefix}/man + %{l_make} %{l_mflags} + +%install + rm -rf $RPM_BUILD_ROOT + %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" + strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true + rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} + +%files -f files + +%clean + rm -rf $RPM_BUILD_ROOT + @@ . ______________________________________________________________________ OpenPKG http://openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org