From 81845fd5f7955cacb4f3eb1b474a1b1ec651b4c9 Mon Sep 17 00:00:00 2001 From: zodiac Date: Mon, 30 Mar 2009 16:09:37 +0000 Subject: [PATCH] Log fatal error messages even in "quiet" mode. Allow overriding more of the default values needed by the system startup script. git-svn-id: https://shellinabox.googlecode.com/svn/trunk@101 0da03de8-d603-11dd-86c2-0f8696b7b6f9 --- ChangeLog | 7 ++++++- config.h | 2 +- configure | 2 +- configure.ac | 2 +- debian/shellinabox.default | 6 ++++++ debian/shellinabox.init | 13 ++++++++++--- logging/logging.c | 2 +- shellinabox/shellinaboxd.c | 7 +++++-- 8 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9bfc8c..9a15488 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ 2009-03-30 Markus Gutschke - * Added initial revision of demo application + * Added initial revision of demo application. + + * Show fatal error message even when running in "quiet" mode. + + * Make it easier to override parameters needed by the system startup + scripts. 2009-03-29 Markus Gutschke diff --git a/config.h b/config.h index 3a5fcb8..d567bc3 100644 --- a/config.h +++ b/config.h @@ -95,7 +95,7 @@ #define STDC_HEADERS 1 /* Most recent revision number in the version control system */ -#define VCS_REVISION "93" +#define VCS_REVISION "101" /* Version number of package */ #define VERSION "2.5" diff --git a/configure b/configure index 79330f6..247f763 100755 --- a/configure +++ b/configure @@ -2056,7 +2056,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -VCS_REVISION=93 +VCS_REVISION=101 cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index 25688dc..a635936 100644 --- a/configure.ac +++ b/configure.ac @@ -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.5, markus@shellinabox.com) -VCS_REVISION=93 +VCS_REVISION=101 AC_SUBST(VCS_REVISION) AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}", [Most recent revision number in the version control system]) diff --git a/debian/shellinabox.default b/debian/shellinabox.default index 28f99b0..bde0eea 100644 --- a/debian/shellinabox.default +++ b/debian/shellinabox.default @@ -4,6 +4,12 @@ SHELLINABOX_DAEMON_START=1 # TCP port that shellinboxd's webserver listens on SHELLINABOX_PORT=4200 +# Parameters that are managed by the system and usually should not need +# changing: +# SHELLINABOX_DATADIR=/var/lib/shellinabox +# SHELLINABOX_USER=shellinabox +# SHELLINABOX_GROUP=shellinabox + # Any optional arguments (e.g. extra service definitions) # We disable beeps, as there have been reports of the VLC plugin crashing # Firefox on Linux/x86_64. diff --git a/debian/shellinabox.init b/debian/shellinabox.init index 443a01a..2c751c2 100755 --- a/debian/shellinabox.init +++ b/debian/shellinabox.init @@ -25,6 +25,12 @@ test -x $DAEMON || exit 0 # Include shellinabox defaults if available. test -f /etc/default/shellinabox && . /etc/default/shellinabox +# Set some default values +SHELLINABOX_DATADIR="${SHELLINABOX_DATADIR:-/var/lib/shellinabox}" +SHELLINABOX_PORT="${SHELLINABOX_PORT:-4200}" +SHELLINABOX_USER="${SHELLINABOX_USER:-shellinabox}" +SHELLINABOX_GROUP="${SHELLINABOX_GROUP:-shellinabox}" + # # Function that starts the daemon/service. # @@ -34,10 +40,11 @@ d_start() { return 0 fi - start-stop-daemon --start --oknodo --quiet --pidfile "$PIDFILE" \ + start-stop-daemon --start --oknodo --pidfile "$PIDFILE" \ --exec "$DAEMON" -- -q --background="$PIDFILE" \ - -c /var/lib/shellinabox -p ${SHELLINABOX_PORT:-4200} \ - -u shellinabox -g shellinabox ${SHELLINABOX_ARGS} + -c "${SHELLINABOX_DATADIR}" -p "${SHELLINABOX_PORT}" \ + -u "${SHELLINABOX_USER}" -g "${SHELLINABOX_GROUP}" \ + ${SHELLINABOX_ARGS} } # diff --git a/logging/logging.c b/logging/logging.c index 555464d..2a806c6 100644 --- a/logging/logging.c +++ b/logging/logging.c @@ -99,7 +99,7 @@ void message(const char *fmt, ...) { void fatal(const char *fmt, ...) { va_list ap; va_start(ap, fmt); - debugMsg(MSG_MESSAGE, fmt, ap); + debugMsg(MSG_QUIET, fmt, ap); va_end(ap); _exit(1); } diff --git a/shellinabox/shellinaboxd.c b/shellinabox/shellinaboxd.c index c51a697..ea4a4b4 100644 --- a/shellinabox/shellinaboxd.c +++ b/shellinabox/shellinaboxd.c @@ -682,7 +682,10 @@ static void parseArgs(int argc, char * const argv[]) { if (idx-- <= 0) { // Help (or invalid argument) usage(); - exit(idx != -1); + if (idx == -1) { + fatal("Failed to parse command line"); + } + exit(0); } else if (!idx--) { // Background if (cgi) { @@ -834,7 +837,7 @@ static void parseArgs(int argc, char * const argv[]) { } if (optind != argc) { usage(); - exit(1); + fatal("Failed to parse command line"); } char *buf = NULL; check(argc >= 1);