Some changes to improve compatibility with MacOS X.

git-svn-id: https://shellinabox.googlecode.com/svn/trunk@231 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac@gmail.com 2010-09-29 06:28:58 +00:00
parent 81af285a8d
commit 301823036a
18 changed files with 242 additions and 59 deletions

View file

@ -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
@ -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
@ -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
@ -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"

View file

@ -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
@ -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
@ -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

23
configure vendored
View file

@ -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
@ -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"
@ -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

View file

@ -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=230
VCS_REVISION=231
AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system])
@ -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
@ -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,

View file

@ -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");
};

View file

@ -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"
@ -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);
}

View file

@ -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
@ -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);
}
@ -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;

View file

@ -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
@ -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);
@ -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;
}

View file

@ -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;
@ -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);
}

View file

@ -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;
@ -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 *, ...);
@ -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);
}
@ -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);
}
@ -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.
@ -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) {

View file

@ -63,6 +63,36 @@ int runAsUser = -1;
int runAsGroup = -1;
#ifndef HAVE_GETRESUID
int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) {
*ruid = getuid();
*euid = geteuid();
*suid = -1;
return 0;
}
#endif
#ifndef HAVE_GETRESGID
int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) {
*rgid = getgid();
*egid = getegid();
*sgid = -1;
return 0;
}
#endif
#ifndef HAVE_SETRESUID
int setresuid(uid_t ruid, uid_t euid, uid_t suid) {
return setreuid(ruid, euid);
}
#endif
#ifndef HAVE_SETRESGID
int setresgid(gid_t rgid, gid_t egid, gid_t sgid) {
return setregid(rgid, egid);
}
#endif
static void removeGroupPrivileges(int showError) {
gid_t rg, eg, sg;
check(!getresgid(&rg, &eg, &sg));

View file

@ -1,5 +1,5 @@
// privileges.h -- Manage process privileges
// Copyright (C) 2008-2009 Markus Gutschke <markus@shellinabox.com>
// Copyright (C) 2008-2010 Markus Gutschke <markus@shellinabox.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -60,4 +60,17 @@ const char *getGroupName(gid_t gid);
gid_t getGroupId(const char *name);
gid_t parseGroup(const char *arg, const char **name);
#ifndef HAVE_GETRESUID
int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
#endif
#ifndef HAVE_GETRESGID
int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
#endif
#ifndef HAVE_SETRESUID
int setresuid(uid_t ruid, uid_t euid, uid_t suid);
#endif
#ifndef HAVE_SETRESGID
int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
#endif
#endif

View file

@ -55,6 +55,13 @@
#include "shellinabox/privileges.h"
#include "shellinabox/service.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
struct Service **services;
int numServices;
@ -242,15 +249,17 @@ void deleteService(struct Service *service) {
free(service);
}
void destroyServiceHashEntry(void *arg, char *key, char *value) {
(void)arg;
(void)key;
(void)value;
void destroyServiceHashEntry(void *arg ATTR_UNUSED, char *key ATTR_UNUSED,
char *value ATTR_UNUSED) {
UNUSED(arg);
UNUSED(key);
UNUSED(value);
}
static int enumerateServicesHelper(void *arg, const char *key, char **value) {
(void)arg;
(void)key;
static int enumerateServicesHelper(void *arg ATTR_UNUSED,
const char *key ATTR_UNUSED, char **value) {
UNUSED(arg);
UNUSED(key);
check(services = realloc(services,
++numServices * sizeof(struct Service *)));

View file

@ -54,6 +54,14 @@
#include "shellinabox/session.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
static HashMap *sessions;
@ -152,9 +160,10 @@ void finishAllSessions(void) {
deleteHashMap(sessions);
}
static void destroySessionHashEntry(void *arg, char *key, char *value) {
(void)arg;
(void)key;
static void destroySessionHashEntry(void *arg ATTR_UNUSED,
char *key ATTR_UNUSED, char *value) {
UNUSED(arg);
UNUSED(key);
deleteSession((struct Session *)value);
}

View file

@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
};
ShellInABox.prototype.about = function() {
alert("Shell In A Box version " + "2.10 (revision 230)" +
alert("Shell In A Box version " + "2.10 (revision 231)" +
"\nCopyright 2008-2010 by Markus Gutschke\n" +
"For more information check http://shellinabox.com" +
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?

View file

@ -89,6 +89,13 @@
#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
@ -275,8 +282,8 @@ static void sessionDone(void *arg) {
}
static int handleSession(struct ServerConnection *connection, void *arg,
short *events, short revents) {
(void)events;
short *events ATTR_UNUSED, short revents) {
UNUSED(events);
struct Session *session = (struct Session *)arg;
session->connection = connection;
int len = MAX_RESPONSE - session->len;
@ -330,8 +337,8 @@ static int invalidatePendingHttpSession(void *arg, const char *key,
}
static int dataHandler(HttpConnection *http, struct Service *service,
const char *buf, int len, URL *url) {
(void)len;
const char *buf, int len ATTR_UNUSED, URL *url) {
UNUSED(len);
if (!buf) {
// Somebody unexpectedly closed our http connection (e.g. because of a
// timeout). This is the last notification that we will get.
@ -815,8 +822,9 @@ static void usage(void) {
free((char *)group);
}
static void destroyExternalFileHashEntry(void *arg, char *key, char *value) {
(void)arg;
static void destroyExternalFileHashEntry(void *arg ATTR_UNUSED, char *key,
char *value) {
UNUSED(arg);
free(key);
free(value);
}

View file

@ -57,11 +57,20 @@
#include "shellinabox/usercss.h"
#include "libhttp/hashmap.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 struct HashMap *defines;
static void definesDestructor(void *arg, char *key, char *value) {
(void)arg;
(void)value;
static void definesDestructor(void *arg ATTR_UNUSED, char *key,
char *value ATTR_UNUSED) {
UNUSED(arg);
UNUSED(value);
free(key);
}

View file

@ -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");
};