Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pennmush/pennmush
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnw committed Mar 18, 2015
2 parents e25621b + 2d39a02 commit 10240e4
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -12,12 +12,14 @@ game/log
game/mush.cnf
game/names.cnf
game/netmush
game/netmush.pid
game/restrict.cnf
game/ssl_slave
game/txt/compose.sh
game/txt/events.txt
game/txt/help.txt
game/txt/news.txt
game/save
hdrs/buildinf.h
hdrs/cmds.h
hdrs/funs.h
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.186
Expand Up @@ -20,4 +20,5 @@ Major changes:

Hardcode:
* Clean up some more remnants of the previous configure package's
naming convention in favor of autoconf style ones. [SW]
naming convention in favor of autoconf style ones. [SW]
* OpenBSD fixes. [SW]
8 changes: 5 additions & 3 deletions config.h.in
Expand Up @@ -63,6 +63,8 @@

#undef HAVE_FENV_H

#undef HAVE_SYS_PARAM_H

#undef HAVE_SYS_UCRED_H

/* Libraries */
Expand All @@ -79,16 +81,16 @@

#undef HAVE_PCRE

#undef HAVE_EVENT_H
#undef HAVE_EVENT2_EVENT_H

#undef HAVE_EVENT2_DNS_H

#if defined(HAVE_EVENT_H) && defined(HAVE_EVENT2_DNS_H)
#if defined(HAVE_EVENT2_EVENT_H) && defined(HAVE_EVENT2_DNS_H)

/* Only define if it looks like libevent2 is installed. (Debian and
* derived distros only have 1.X) */

#undef HAVE_LIBEVENT
#undef HAVE_LIBEVENT_CORE

#endif

Expand Down
107 changes: 92 additions & 15 deletions configure
Expand Up @@ -4232,18 +4232,26 @@ case "${build_os}" in
;;
*netbsd*)
USING_NETBSD=yes
;;
*openbsd*)
USING_OPENBSD=yes
esac

# Adds additional paths potentially needed or BSD compilation
if test "${USING_FREEBSD}" = yes; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include -I/usr/local/include/event2"
LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/local/lib/event2"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi

if test "${USING_NETBSD}" = yes; then
CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
LDFLAGS="$LDFLAGS -L/usr/pkg/lib -Wl,-R/usr/pkg/lib"
fi
fi

if test "${USING_OPENBSD}" = yes; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi

# Set good debug and warning options if using gcc or clang
# and custom CFLAGS aren't being used.
Expand Down Expand Up @@ -5651,7 +5659,7 @@ fi

done

for ac_header in zlib.h event.h event2/dns.h fenv.h sys/ucred.h
for ac_header in zlib.h event2/event.h event2/dns.h fenv.h sys/param.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
Expand All @@ -5664,6 +5672,24 @@ fi

done

for ac_header in sys/ucred.h
do :
ac_fn_c_check_header_compile "$LINENO" "sys/ucred.h" "ac_cv_header_sys_ucred_h" "
$ac_includes_default
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
"
if test "x$ac_cv_header_sys_ucred_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYS_UCRED_H 1
_ACEOF

fi

done


### C language support
# Only need to check C99 and GNU extensions
Expand Down Expand Up @@ -6918,13 +6944,13 @@ _ACEOF

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_base_loop in -levent" >&5
$as_echo_n "checking for event_base_loop in -levent... " >&6; }
if ${ac_cv_lib_event_event_base_loop+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_base_loop in -levent_core" >&5
$as_echo_n "checking for event_base_loop in -levent_core... " >&6; }
if ${ac_cv_lib_event_core_event_base_loop+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-levent $LIBS"
LIBS="-levent_core $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -6944,22 +6970,67 @@ return event_base_loop ();
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_event_event_base_loop=yes
ac_cv_lib_event_core_event_base_loop=yes
else
ac_cv_lib_event_event_base_loop=no
ac_cv_lib_event_core_event_base_loop=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_event_base_loop" >&5
$as_echo "$ac_cv_lib_event_event_base_loop" >&6; }
if test "x$ac_cv_lib_event_event_base_loop" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_core_event_base_loop" >&5
$as_echo "$ac_cv_lib_event_core_event_base_loop" >&6; }
if test "x$ac_cv_lib_event_core_event_base_loop" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBEVENT 1
#define HAVE_LIBEVENT_CORE 1
_ACEOF

LIBS="-levent $LIBS"
LIBS="-levent_core $LIBS"

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for evdns_base_new in -levent_extra" >&5
$as_echo_n "checking for evdns_base_new in -levent_extra... " >&6; }
if ${ac_cv_lib_event_extra_evdns_base_new+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-levent_extra $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char evdns_base_new ();
int
main ()
{
return evdns_base_new ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_event_extra_evdns_base_new=yes
else
ac_cv_lib_event_extra_evdns_base_new=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_extra_evdns_base_new" >&5
$as_echo "$ac_cv_lib_event_extra_evdns_base_new" >&6; }
if test "x$ac_cv_lib_event_extra_evdns_base_new" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBEVENT_EXTRA 1
_ACEOF

LIBS="-levent_extra $LIBS"

fi

Expand Down Expand Up @@ -8605,6 +8676,9 @@ ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_i
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
Expand All @@ -8622,6 +8696,9 @@ ac_fn_c_check_type "$LINENO" "struct xucred" "ac_cv_type_struct_xucred" "
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
Expand Down
28 changes: 23 additions & 5 deletions configure.in
Expand Up @@ -49,18 +49,26 @@ case "${build_os}" in
;;
*netbsd*)
USING_NETBSD=yes
;;
*openbsd*)
USING_OPENBSD=yes
esac

# Adds additional paths potentially needed or BSD compilation
if test "${USING_FREEBSD}" = yes; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include -I/usr/local/include/event2"
LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/local/lib/event2"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi

if test "${USING_NETBSD}" = yes; then
CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
LDFLAGS="$LDFLAGS -L/usr/pkg/lib -Wl,-R/usr/pkg/lib"
fi
fi

if test "${USING_OPENBSD}" = yes; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi

# Set good debug and warning options if using gcc or clang
# and custom CFLAGS aren't being used.
Expand Down Expand Up @@ -156,7 +164,13 @@ AC_CHECK_HEADERS([sys/stat.h sys/time.h sys/types.h])
AC_CHECK_HEADERS([sys/socket.h arpa/inet.h libintl.h netdb.h netinet/tcp.h netinet/in.h])
AC_CHECK_HEADERS([sys/un.h sys/resource.h sys/event.h sys/uio.h byteswap.h])
AC_CHECK_HEADERS([poll.h sys/select.h sys/inotify.h fam.h])
AC_CHECK_HEADERS([zlib.h event.h event2/dns.h fenv.h sys/ucred.h])
AC_CHECK_HEADERS([zlib.h event2/event.h event2/dns.h fenv.h sys/param.h])
AC_CHECK_HEADERS([sys/ucred.h], [], [], [
AC_INCLUDES_DEFAULT
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
])

### C language support
# Only need to check C99 and GNU extensions
Expand Down Expand Up @@ -203,7 +217,8 @@ AC_CHECK_LIB(intl, gettext)
AC_CHECK_LIB(crypt, crypt)
AX_LIB_SOCKET_NSL
AC_CHECK_LIB(fam, FAMOpen)
AC_CHECK_LIB(event, event_base_loop)
AC_CHECK_LIB(event_core, event_base_loop)
AC_CHECK_LIB(event_extra, evdns_base_new)
AC_CHECK_LIB(event_openssl, bufferevent_openssl_socket_new)

AC_ARG_ENABLE(zlib, AS_HELP_STRING([--disable-zlib], [Don't use zlib for database compression.]),
Expand Down Expand Up @@ -357,6 +372,9 @@ AC_CHECK_TYPES([struct sockaddr_in6, struct xucred], [], [], [
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
Expand Down
12 changes: 6 additions & 6 deletions game/restart
Expand Up @@ -81,14 +81,14 @@ RAW_INDB=`egrep "^input_database" $CONF_FILE | tail -n1`
RAW_OUTDB=`egrep "^output_database" $CONF_FILE | tail -n1`
RAW_PANICDB=`egrep "^crash_database" $CONF_FILE | tail -n1`

INDIR=$(dirname ${RAW_INDB#input_database})
INDB=$(basename ${RAW_INDB#input_database})
INDIR=$(dirname "${RAW_INDB#input_database }")
INDB=$(basename "${RAW_INDB#input_database }")

OUTDIR=$(dirname ${RAW_OUTDB#output_database})
OUTDB=$(basename ${RAW_OUTDB#output_database})
OUTDIR=$(dirname "${RAW_OUTDB#output_database }")
OUTDB=$(basename "${RAW_OUTDB#output_database }")

PANICDIR=$(dirname ${RAW_PANICDB#crash_database})
PANICDB=$(basename ${RAW_PANICDB#crash_database})
PANICDIR=$(dirname "${RAW_PANICDB#crash_database }")
PANICDB=$(basename "${RAW_PANICDB#crash_database }")

COMPRESSOR="cat"
SUFFIX=""
Expand Down
9 changes: 7 additions & 2 deletions hints/openbsd.txt
@@ -1,5 +1,10 @@
Penn will compile and run out of the box on OpenBSD, with the caveats
below:
Penn will compile and run on OpenBSD, with the caveats below. Tested
with OpenBSD 5.6.

Some packages need to be installed via pkg_add or from source if not
already present on the server:

pcre, libevent, optional desired SQL database.

* OpenBSD will not forward IPv4 connections to a listening IPv6
port. Specify a generic IPv4 address (0.0.0.0) or specific one in
Expand Down
4 changes: 2 additions & 2 deletions src/info_slave.c
Expand Up @@ -61,7 +61,7 @@
void fputerr(const char *);
const char *time_string(void);

#ifdef HAVE_LIBEVENT
#ifdef HAVE_LIBEVENT_CORE


/* Version using libevent's async dns routines. Much shorter because
Expand All @@ -79,7 +79,7 @@ const char *time_string(void);
* linux and other systems. Not as elegant, but it works.
*/

#include <event.h>
#include <event2/event.h>
#include <event2/dns.h>

struct event_base *main_loop = NULL;
Expand Down
15 changes: 15 additions & 0 deletions src/mysocket.c
Expand Up @@ -90,6 +90,10 @@ extern int h_errno;
#include <sys/select.h>
#endif

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
Expand Down Expand Up @@ -532,6 +536,17 @@ recv_with_creds(int s, void *buf, size_t len, int *remote_pid, int *remote_uid)
*remote_uid = creds.uid;
}
}
#elif defined(__OpenBSD__)
{
struct sockpeercred creds;
socklen_t credlen = sizeof creds;
if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &creds, &credlen) < 0) {
perror("getsockopt SO_PEERCRED");
} else {
*remote_pid = creds.pid;
*remote_uid = creds.uid;
}
}
#elif defined(HAVE_STRUCT_XUCRED)
{
struct xucred creds;
Expand Down
4 changes: 2 additions & 2 deletions src/ssl_slave.c
Expand Up @@ -8,7 +8,7 @@
#error "ssl_slave requires OpenSSL!"
#endif

#ifndef HAVE_LIBEVENT
#ifndef HAVE_LIBEVENT_CORE
#error "ssl_slave requires libevent!"
#endif

Expand All @@ -24,7 +24,7 @@
#include <stdio.h>
#include <string.h>

#include <event.h>
#include <event2/event.h>
#include <event2/dns.h>
#include <event2/bufferevent_ssl.h>

Expand Down

0 comments on commit 10240e4

Please sign in to comment.