/* 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
/* 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
/* 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
#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"
/* 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
/* 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
/* 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
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-VCS_REVISION=230
+VCS_REVISION=231
cat >>confdefs.h <<_ACEOF
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"
$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
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])
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
[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,
};
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");
};
#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"
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);
}
#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
}
-static void serverDestroyHandlers(void *arg, char *value) {
- (void)arg;
+static void serverDestroyHandlers(void *arg ATTR_UNUSED, char *value) {
+ UNUSED(arg);
free(value);
}
}
}
-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;
#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
#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);
// 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;
}
#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;
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);
}
#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;
#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 *, ...);
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);
}
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);
}
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.
_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) {
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));
// 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
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
#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;
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 *)));
#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;
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);
}
};
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 ?
#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
}
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;
}
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.
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);
}
#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);
}
};
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");
};