Skip to content

Commit

Permalink
Some changes to improve compatibility with MacOS X.
Browse files Browse the repository at this point in the history
git-svn-id: https://shellinabox.googlecode.com/svn/trunk@231 0da03de8-d603-11dd-86c2-0f8696b7b6f9
  • Loading branch information
[email protected] committed Sep 29, 2010
1 parent 81af285 commit 3018230
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 59 deletions.
17 changes: 16 additions & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/* Define to 1 if you have support for symbol aliasing */
#define HAVE_ATTRIBUTE_ALIAS 1

/* Define to 1 if you have support for the "unused" attribute */
#define HAVE_ATTRIBUTE_UNUSED 1

/* Set if you want support for calling /bin/login */
#define HAVE_BIN_LOGIN 1

Expand All @@ -28,6 +31,12 @@
/* Define to 1 if you have the `getpwuid_r' function. */
#define HAVE_GETPWUID_R 1

/* Define to 1 if you have the `getresgid' function. */
#define HAVE_GETRESGID 1

/* Define to 1 if you have the `getresuid' function. */
#define HAVE_GETRESUID 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

Expand Down Expand Up @@ -73,6 +82,12 @@
/* Define to 1 if you have the <security/pam_misc.h> header file. */
#define HAVE_SECURITY_PAM_MISC_H 1

/* Define to 1 if you have the `setresgid' function. */
#define HAVE_SETRESGID 1

/* Define to 1 if you have the `setresuid' function. */
#define HAVE_SETRESUID 1

/* Define to 1 if you have a working sigwait */
#define HAVE_SIGWAIT 1

Expand Down Expand Up @@ -156,7 +171,7 @@
#define STDC_HEADERS 1

/* Most recent revision number in the version control system */
#define VCS_REVISION "230"
#define VCS_REVISION "231"

/* Version number of package */
#define VERSION "2.10"
Expand Down
15 changes: 15 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/* Define to 1 if you have support for symbol aliasing */
#undef HAVE_ATTRIBUTE_ALIAS

/* Define to 1 if you have support for the "unused" attribute */
#undef HAVE_ATTRIBUTE_UNUSED

/* Set if you want support for calling /bin/login */
#undef HAVE_BIN_LOGIN

Expand All @@ -27,6 +30,12 @@
/* Define to 1 if you have the `getpwuid_r' function. */
#undef HAVE_GETPWUID_R

/* Define to 1 if you have the `getresgid' function. */
#undef HAVE_GETRESGID

/* Define to 1 if you have the `getresuid' function. */
#undef HAVE_GETRESUID

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

Expand Down Expand Up @@ -72,6 +81,12 @@
/* Define to 1 if you have the <security/pam_misc.h> header file. */
#undef HAVE_SECURITY_PAM_MISC_H

/* Define to 1 if you have the `setresgid' function. */
#undef HAVE_SETRESGID

/* Define to 1 if you have the `setresuid' function. */
#undef HAVE_SETRESUID

/* Define to 1 if you have a working sigwait */
#undef HAVE_SIGWAIT

Expand Down
23 changes: 21 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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=230
VCS_REVISION=231


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -10655,7 +10655,7 @@ done


for ac_func in getgrgid_r getgrnam_r gethostbyname_r getpwnam_r getpwuid_r \
openpty strcasestr
openpty strcasestr getresuid getresgid setresuid setresgid
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
Expand Down Expand Up @@ -10786,6 +10786,25 @@ if ac_fn_c_try_link "$LINENO"; then :

$as_echo "#define HAVE_ATTRIBUTE_ALIAS 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. */
void x(int i __attribute__((unused))) __attribute__((unused));
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :

$as_echo "#define HAVE_ATTRIBUTE_UNUSED 1" >>confdefs.h

fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
Expand Down
10 changes: 8 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected])
VCS_REVISION=230
VCS_REVISION=231
AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system])
Expand Down Expand Up @@ -34,7 +34,7 @@ AC_CHECK_FUNCS([strlcat])

dnl Prefer thread-safe functions, if available
AC_CHECK_FUNCS([getgrgid_r getgrnam_r gethostbyname_r getpwnam_r getpwuid_r \
openpty strcasestr ])
openpty strcasestr getresuid getresgid setresuid setresgid ])

dnl We prefer ptsname_r(), but will settle for ptsname() if necessary
AC_TRY_LINK([#ifndef _XOPEN_SOURCE
Expand Down Expand Up @@ -78,6 +78,12 @@ AC_TRY_LINK([void x(void) { };
[AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
Define to 1 if you have support for symbol aliasing)])

dnl Check if the compiler has support to mark parameters as unused
AC_TRY_LINK([void x(int i __attribute__((unused))) __attribute__((unused));],
[],
[AC_DEFINE(HAVE_ATTRIBUTE_UNUSED, 1,
Define to 1 if you have support for the "unused" attribute)])

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.
AC_ARG_ENABLE(login,
Expand Down
2 changes: 1 addition & 1 deletion demo/vt100.js
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() {
};

VT100.prototype.about = function() {
alert("VT100 Terminal Emulator " + "2.10 (revision 230)" +
alert("VT100 Terminal Emulator " + "2.10 (revision 231)" +
"\nCopyright 2008-2010 by Markus Gutschke\n" +
"For more information check http://shellinabox.com");
};
Expand Down
11 changes: 9 additions & 2 deletions libhttp/httpconnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
#endif
#define max(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \
_a > _b ? _a : _b; })
#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

#include "libhttp/httpconnection.h"
#include "logging/logging.h"
Expand Down Expand Up @@ -270,8 +277,8 @@ static int httpFinishCommand(struct HttpConnection *http) {
return rc;
}

static void httpDestroyHeaders(void *arg, char *key, char *value) {
(void)arg;
static void httpDestroyHeaders(void *arg ATTR_UNUSED, char *key, char *value) {
UNUSED(arg);
free(key);
free(value);
}
Expand Down
17 changes: 13 additions & 4 deletions libhttp/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
#include "libhttp/ssl.h"
#include "logging/logging.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 INITIAL_TIMEOUT (10*60)

// Maximum amount of payload (e.g. form values that have been POST'd) that we
Expand Down Expand Up @@ -128,8 +136,8 @@ static int serverCollectHandler(struct HttpConnection *http, void *handler_) {

}

static void serverDestroyHandlers(void *arg, char *value) {
(void)arg;
static void serverDestroyHandlers(void *arg ATTR_UNUSED, char *value) {
UNUSED(arg);
free(value);
}

Expand Down Expand Up @@ -183,8 +191,9 @@ void serverRegisterWebSocketHandler(struct Server *server, const char *url,
}
}

static int serverQuitHandler(struct HttpConnection *http, void *arg) {
(void)arg;
static int serverQuitHandler(struct HttpConnection *http ATTR_UNUSED,
void *arg) {
UNUSED(arg);
httpSendReply(http, 200, "Good Bye", NO_MSG);
httpExitLoop(http, 1);
return HTTP_DONE;
Expand Down
19 changes: 14 additions & 5 deletions libhttp/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
#include "libhttp/httpconnection.h"
#include "logging/logging.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

#undef pthread_once
#undef pthread_sigmask

Expand Down Expand Up @@ -541,8 +549,9 @@ static int sslSetCertificateFromFile(SSL_CTX *context,
#endif

#ifdef HAVE_TLSEXT
static int sslSNICallback(SSL *sslHndl, int *al, struct SSLSupport *ssl) {
(void)al;
static int sslSNICallback(SSL *sslHndl, int *al ATTR_UNUSED,
struct SSLSupport *ssl) {
UNUSED(al);
check(!ERR_peek_error());
const char *name = SSL_get_servername(sslHndl,
TLSEXT_NAMETYPE_host_name);
Expand Down Expand Up @@ -615,10 +624,10 @@ static int sslSNICallback(SSL *sslHndl, int *al, struct SSLSupport *ssl) {
// This is a not-thread-safe replacement for gethostbyname_r()
#define gethostbyname_r x_gethostbyname_r
static int gethostbyname_r(const char *name, struct hostent *ret,
char *buf, size_t buflen,
char *buf ATTR_UNUSED, size_t buflen ATTR_UNUSED,
struct hostent **result, int *h_errnop) {
(void)buf;
(void)buflen;
UNUSED(buf);
UNUSED(buflen);
if (result) {
*result = NULL;
}
Expand Down
13 changes: 11 additions & 2 deletions libhttp/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@

#include "logging/logging.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

static char *urlUnescape(char *s) {
int warned = 0;
char *r = s;
Expand Down Expand Up @@ -86,8 +94,9 @@ static char *urlUnescape(char *s) {
return r;
}

static void urlDestroyHashMapEntry(void *arg, char *key, char *value) {
(void)arg;
static void urlDestroyHashMapEntry(void *arg ATTR_UNUSED, char *key,
char *value) {
UNUSED(arg);
free(key);
free(value);
}
Expand Down
52 changes: 34 additions & 18 deletions shellinabox/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
#if defined(HAVE_SECURITY_PAM_MISC_H)
#include <security/pam_misc.h>
#endif

#ifndef PAM_DATA_SILENT
#define PAM_DATA_SILENT 0
#endif
#else
struct pam_message;
struct pam_response;
Expand All @@ -116,6 +120,14 @@ typedef struct pam_handle pam_handle_t;
#include "libhttp/hashmap.h"
#include "logging/logging.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

#undef pthread_once
#undef execle
int execle(const char *, const char *, ...);
Expand Down Expand Up @@ -562,9 +574,10 @@ void deleteUtmp(struct Utmp *utmp) {
free(utmp);
}

static void destroyUtmpHashEntry(void *arg, char *key, char *value) {
(void)arg;
(void)key;
static void destroyUtmpHashEntry(void *arg ATTR_UNUSED, char *key ATTR_UNUSED,
char *value) {
UNUSED(arg);
UNUSED(key);
deleteUtmp((struct Utmp *)value);
}

Expand Down Expand Up @@ -791,10 +804,11 @@ static const struct passwd *getPWEnt(uid_t uid) {
return passwd;
}

static void sigAlrmHandler(int sig, siginfo_t *info, void *unused) {
(void)sig;
(void)info;
(void)unused;
static void sigAlrmHandler(int sig ATTR_UNUSED, siginfo_t *info ATTR_UNUSED,
void *unused ATTR_UNUSED) {
UNUSED(sig);
UNUSED(info);
UNUSED(unused);
puts("\nLogin timed out after 60 seconds.");
_exit(1);
}
Expand Down Expand Up @@ -1079,17 +1093,18 @@ static pam_handle_t *internalLogin(struct Service *service, struct Utmp *utmp,
return pam;
}

static void destroyVariableHashEntry(void *arg, char *key, char *value) {
(void)arg;
static void destroyVariableHashEntry(void *arg ATTR_UNUSED, char *key,
char *value) {
UNUSED(arg);
free(key);
free(value);
}

static void execService(int width, int height, struct Service *service,
const char *peerName, char **environment,
const char *url) {
(void)width;
(void)height;
static void execService(int width ATTR_UNUSED, int height ATTR_UNUSED,
struct Service *service, const char *peerName,
char **environment, const char *url) {
UNUSED(width);
UNUSED(height);

// Create a hash table with all the variables that we can expand. This
// includes all environment variables being passed to the child.
Expand Down Expand Up @@ -1450,10 +1465,11 @@ static void childProcess(struct Service *service, int width, int height,
_exit(1);
}

static void sigChildHandler(int sig, siginfo_t *info, void *unused) {
(void)sig;
(void)info;
(void)unused;
static void sigChildHandler(int sig ATTR_UNUSED, siginfo_t *info ATTR_UNUSED,
void *unused ATTR_UNUSED) {
UNUSED(sig);
UNUSED(info);
UNUSED(unused);
}

static void launcherDaemon(int fd) {
Expand Down
Loading

0 comments on commit 3018230

Please sign in to comment.