From 925c2385e7753c4afd229ac1a53b3f8c9f24ec8c Mon Sep 17 00:00:00 2001 From: "zodiac@gmail.com" Date: Wed, 29 Sep 2010 16:46:51 +0000 Subject: [PATCH] Another iteration of changes intended to deal with MacOS X specific build problems. Unfortunately, without access to a MacOS X build environment, some of these have to be mere educated guesses... git-svn-id: https://shellinabox.googlecode.com/svn/trunk@232 0da03de8-d603-11dd-86c2-0f8696b7b6f9 --- Makefile.am | 49 ++++++++++++++++++++--------------- Makefile.in | 49 ++++++++++++++++++++--------------- config.h | 2 +- configure | 2 +- configure.ac | 2 +- demo/vt100.js | 2 +- shellinabox/launcher.c | 11 ++++++++ shellinabox/privileges.c | 4 +-- shellinabox/privileges.h | 4 +-- shellinabox/service.c | 6 +++-- shellinabox/shell_in_a_box.js | 2 +- shellinabox/shellinaboxd.c | 20 +++++++------- shellinabox/vt100.js | 2 +- 13 files changed, 91 insertions(+), 64 deletions(-) diff --git a/Makefile.am b/Makefile.am index c90a13b..4982861 100644 --- a/Makefile.am +++ b/Makefile.am @@ -261,40 +261,44 @@ clean-local: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .gif.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .png.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .html.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" @@ -302,10 +306,11 @@ clean-local: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .jspp.js: @@ -322,10 +327,11 @@ clean-local: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" @@ -333,9 +339,10 @@ clean-local: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" diff --git a/Makefile.in b/Makefile.in index 875941c..62c99fa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1234,50 +1234,55 @@ clean-local: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .gif.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .png.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .html.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .ico.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .jspp.js: @@ -1294,20 +1299,22 @@ clean-local: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" .wav.h: @echo od "$<" '>'"$@" @mkdir -p "`dirname "$@"`" @{ sym="`echo "$<" | $(symbolname)`"; \ - echo "static const char $${sym}Start[]="; \ - od -vb "$<" | sed 's/[0-7]*/"/;s/ /\\/g;s/$$/"/'; \ + echo "static const char $${sym}Start[] ="; \ + od -vb "$<" | sed 's/[0-7]*/"/;s/ *$$/"/;/^""$$/d;s/ */\\/g'; \ echo ';'; \ - echo "static const int $${sym}Size=(int)sizeof($${sym}Start);"; \ + echo "static const int $${sym}Size ATTR_UNUSED =" \ + "(int)sizeof($${sym}Start);"; \ } >"$@" # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/config.h b/config.h index 1d7dbe5..8441265 100644 --- a/config.h +++ b/config.h @@ -171,7 +171,7 @@ #define STDC_HEADERS 1 /* Most recent revision number in the version control system */ -#define VCS_REVISION "231" +#define VCS_REVISION "232" /* Version number of package */ #define VERSION "2.10" diff --git a/configure b/configure index 78d38d8..827be84 100755 --- 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=231 +VCS_REVISION=232 cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index b7e56b8..fb80da4 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.10, markus@shellinabox.com) -VCS_REVISION=231 +VCS_REVISION=232 AC_SUBST(VCS_REVISION) AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}", [Most recent revision number in the version control system]) diff --git a/demo/vt100.js b/demo/vt100.js index 46ebcf0..16e7a8b 100644 --- a/demo/vt100.js +++ b/demo/vt100.js @@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() { }; VT100.prototype.about = function() { - alert("VT100 Terminal Emulator " + "2.10 (revision 231)" + + alert("VT100 Terminal Emulator " + "2.10 (revision 232)" + "\nCopyright 2008-2010 by Markus Gutschke\n" + "For more information check http://shellinabox.com"); }; diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index 2065e12..a60f419 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -167,6 +167,17 @@ static int (*x_misc_conv)(int, const struct pam_message **, #define misc_conv x_misc_conv #endif +// MacOS X has a somewhat unusual definition of getgrouplist() which can +// trigger a compile warning. Unfortunately, there is no good feature test +// for this particular problem. +#if defined(__APPLE__) && defined(__MACH__) +static int x_getgrouplist(const char *user, gid_t group, + gid_t *groups, int *ngroups) { + return getgrouplist(user, (int)group, (int *)groups, ngroups); +} +#define getgrouplist x_getgrouplist +#endif + static int launcher = -1; static uid_t restricted; diff --git a/shellinabox/privileges.c b/shellinabox/privileges.c index 87ccfe5..4da1cbc 100644 --- a/shellinabox/privileges.c +++ b/shellinabox/privileges.c @@ -274,7 +274,7 @@ uid_t getUserId(const char *name) { return uid; } -uid_t parseUser(const char *arg, const char **name) { +uid_t parseUserArg(const char *arg, const char **name) { char *end; errno = 0; unsigned long l = strtoul(arg, &end, 10); @@ -404,7 +404,7 @@ gid_t getGroupId(const char *name) { return gid; } -gid_t parseGroup(const char *arg, const char **name) { +gid_t parseGroupArg(const char *arg, const char **name) { char *end; errno = 0; unsigned long l = strtoul(arg, &end, 10); diff --git a/shellinabox/privileges.h b/shellinabox/privileges.h index 2171167..0ba99d9 100644 --- a/shellinabox/privileges.h +++ b/shellinabox/privileges.h @@ -55,10 +55,10 @@ void lowerPrivileges(void); void dropPrivileges(void); const char *getUserName(uid_t uid); uid_t getUserId(const char *name); -uid_t parseUser(const char *arg, const char **name); +uid_t parseUserArg(const char *arg, const char **name); const char *getGroupName(gid_t gid); gid_t getGroupId(const char *name); -gid_t parseGroup(const char *arg, const char **name); +gid_t parseGroupArg(const char *arg, const char **name); #ifndef HAVE_GETRESUID int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); diff --git a/shellinabox/service.c b/shellinabox/service.c index 7f83028..db8c8a1 100644 --- a/shellinabox/service.c +++ b/shellinabox/service.c @@ -180,7 +180,8 @@ void initService(struct Service *service, const char *arg) { service->authUser = 0; // Numeric or symbolic user id - service->uid = parseUser(arg, &service->user); + service->uid = parseUserArg(arg, + &service->user); *ptr = ':'; arg = ptr + 1; @@ -189,7 +190,8 @@ void initService(struct Service *service, const char *arg) { goto error; } *ptr = '\000'; - service->gid = parseGroup(arg, &service->group); + service->gid = parseGroupArg(arg, + &service->group); } *ptr = ':'; arg = ptr + 1; diff --git a/shellinabox/shell_in_a_box.js b/shellinabox/shell_in_a_box.js index 0db22d2..f0bed3d 100644 --- a/shellinabox/shell_in_a_box.js +++ b/shellinabox/shell_in_a_box.js @@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) { }; ShellInABox.prototype.about = function() { - alert("Shell In A Box version " + "2.10 (revision 231)" + + alert("Shell In A Box version " + "2.10 (revision 232)" + "\nCopyright 2008-2010 by Markus Gutschke\n" + "For more information check http://shellinabox.com" + (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ? diff --git a/shellinabox/shellinaboxd.c b/shellinabox/shellinaboxd.c index d864b57..5be1ca6 100644 --- a/shellinabox/shellinaboxd.c +++ b/shellinabox/shellinaboxd.c @@ -76,6 +76,14 @@ #include "shellinabox/session.h" #include "shellinabox/usercss.h" +#ifdef HAVE_UNUSED +#defined ATTR_UNUSED __attribute__((unused)) +#defined UNUSED(x) do { } while (0) +#else +#define ATTR_UNUSED +#define UNUSED(x) do { (void)(x); } while (0) +#endif + // Embedded resources #include "shellinabox/beep.h" #include "shellinabox/cgi_root.h" @@ -89,14 +97,6 @@ #include "shellinabox/styles.h" #include "shellinabox/vt100.h" -#ifdef HAVE_UNUSED -#defined ATTR_UNUSED __attribute__((unused)) -#defined UNUSED(x) do { } while (0) -#else -#define ATTR_UNUSED -#define UNUSED(x) do { (void)(x); } while (0) -#endif - #define PORTNUM 4200 #define MAX_RESPONSE 2048 @@ -1013,7 +1013,7 @@ static void parseArgs(int argc, char * const argv[]) { if (!optarg || !*optarg) { fatal("\"--group\" expects a group name."); } - runAsGroup = parseGroup(optarg, NULL); + runAsGroup = parseGroupArg(optarg, NULL); } else if (!idx--) { // Linkify if (!strcmp(optarg, "none")) { @@ -1095,7 +1095,7 @@ static void parseArgs(int argc, char * const argv[]) { if (!optarg || !*optarg) { fatal("\"--user\" expects a user name."); } - runAsUser = parseUser(optarg, NULL); + runAsUser = parseUserArg(optarg, NULL); } else if (!idx--) { // User CSS if (!optarg || !*optarg) { diff --git a/shellinabox/vt100.js b/shellinabox/vt100.js index 46ebcf0..16e7a8b 100644 --- a/shellinabox/vt100.js +++ b/shellinabox/vt100.js @@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() { }; VT100.prototype.about = function() { - alert("VT100 Terminal Emulator " + "2.10 (revision 231)" + + alert("VT100 Terminal Emulator " + "2.10 (revision 232)" + "\nCopyright 2008-2010 by Markus Gutschke\n" + "For more information check http://shellinabox.com"); };