Skip to content
Permalink
Browse files

Add base64 fallback functions for SASL

Tested with musl / openwrt which lacks base64 functions in libc/resolv.
  • Loading branch information...
michaelortmann authored and vanosg committed Aug 27, 2019
1 parent 89cddad commit 7ea72e91b1a7e9c5beb6dcfc9da5d0c11c162c3b
Showing with 450 additions and 22 deletions.
  1. +48 −0 aclocal.m4
  2. +1 −0 configure.ac
  3. +25 −22 src/compat/Makefile.in
  4. +344 −0 src/compat/base64.c
  5. +31 −0 src/compat/base64.h
  6. +1 −0 src/compat/compat.h
@@ -284,6 +284,54 @@ dnl Checks for types and functions.
dnl


dnl EGG_FUNC_B64_NTOP()
dnl
AC_DEFUN([EGG_FUNC_B64_NTOP],
[
# https://raw.githubusercontent.com/tmux/tmux/2dd9a4fb9cd73987bdca5b8b2f85ca8b1a6e4e73/configure.ac

# Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well.
AC_MSG_CHECKING(for b64_ntop)
AC_TRY_LINK(
[
#include <sys/types.h>
#include <netinet/in.h>
#include <resolv.h>
],
[b64_ntop(NULL, 0, NULL, 0);],
found_b64_ntop=yes,
found_b64_ntop=no
)
if test "x$found_b64_ntop" = xno; then
AC_MSG_RESULT(no)

AC_MSG_CHECKING(for b64_ntop with -lresolv)
OLD_LIBS="$LIBS"
LIBS="$LIBS -lresolv"
AC_TRY_LINK(
[
#include <sys/types.h>
#include <netinet/in.h>
#include <resolv.h>
],
[b64_ntop(NULL, 0, NULL, 0);],
found_b64_ntop=yes,
found_b64_ntop=no
)
if test "x$found_b64_ntop" = xno; then
LIBS="$OLD_LIBS"
AC_MSG_RESULT(no)
fi
fi
if test "x$found_b64_ntop" = xyes; then
AC_DEFINE([HAVE_BASE64], [1], [Define if b64_ntop exists.])
AC_MSG_RESULT(yes)
else
AC_LIBOBJ(base64)
fi
])


dnl EGG_FUNC_VPRINTF()
dnl
AC_DEFUN([EGG_FUNC_VPRINTF],
@@ -113,6 +113,7 @@ AX_CREATE_STDINT_H([eggint.h])
# Checks for functions and their arguments.
AC_CHECK_FUNCS([clock dprintf getrandom getrusage inet_aton inet_ntop isascii random rand lrand48 setpgid snprintf strlcpy vsnprintf])
AC_FUNC_SELECT_ARGTYPES
EGG_FUNC_B64_NTOP
EGG_FUNC_VPRINTF
AC_FUNC_MMAP

@@ -17,8 +17,8 @@ STRIP = @STRIP@
CFLAGS = @CFLAGS@ -I../.. -I$(top_srcdir) -I$(top_srcdir)/src @SSL_INCLUDES@ @DEFS@ $(CFLGS)
CPPFLAGS = @CPPFLAGS@

OBJS = gethostbyname2.o in6.o inet_aton.o inet_ntop.o inet_pton.o snprintf.o \
strlcpy.o
OBJS = base64.o gethostbyname2.o in6.o inet_aton.o inet_ntop.o inet_pton.o \
snprintf.o strlcpy.o

doofus:
@echo ""
@@ -41,48 +41,51 @@ compat: $(OBJS)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

#safety hash
base64.o: base64.c
gethostbyname2.o: gethostbyname2.c gethostbyname2.h ../../src/main.h \
../../config.h ../../eggint.h ../../lush.h ../../src/lang.h \
../../src/eggdrop.h ../../src/compat/in6.h ../../src/flags.h \
../../src/proto.h ../../src/misc_file.h ../../src/cmdt.h \
../../src/tclegg.h ../../src/tclhash.h ../../src/chan.h \
../../src/users.h ../../src/compat/compat.h ../../src/compat/inet_aton.h \
../../src/compat/snprintf.h ../../src/compat/inet_ntop.h \
../../src/compat/inet_pton.h ../../src/compat/gethostbyname2.h \
../../src/compat/strlcpy.h
../../src/users.h ../../src/compat/compat.h ../../src/compat/base64.h \
../../src/compat/inet_aton.h ../../src/compat/snprintf.h \
../../src/compat/inet_ntop.h ../../src/compat/inet_pton.h \
../../src/compat/gethostbyname2.h ../../src/compat/strlcpy.h
in6.o: in6.c in6.h
inet_aton.o: inet_aton.c ../../src/main.h ../../config.h ../../eggint.h \
../../lush.h ../../src/lang.h ../../src/eggdrop.h ../../src/compat/in6.h \
../../src/flags.h ../../src/proto.h ../../src/misc_file.h \
../../src/cmdt.h ../../src/tclegg.h ../../src/tclhash.h ../../src/chan.h \
../../src/users.h ../../src/compat/compat.h ../../src/compat/inet_aton.h \
../../src/main.h ../../src/compat/snprintf.h \
../../src/compat/inet_ntop.h ../../src/compat/inet_pton.h \
../../src/compat/gethostbyname2.h ../../src/compat/strlcpy.h inet_aton.h
../../src/users.h ../../src/compat/compat.h ../../src/compat/base64.h \
../../src/compat/inet_aton.h ../../src/main.h \
../../src/compat/snprintf.h ../../src/compat/inet_ntop.h \
../../src/compat/inet_pton.h ../../src/compat/gethostbyname2.h \
../../src/compat/strlcpy.h inet_aton.h
inet_ntop.o: inet_ntop.c inet_ntop.h ../../src/main.h ../../config.h \
../../eggint.h ../../lush.h ../../src/lang.h ../../src/eggdrop.h \
../../src/compat/in6.h ../../src/flags.h ../../src/proto.h \
../../src/misc_file.h ../../src/cmdt.h ../../src/tclegg.h \
../../src/tclhash.h ../../src/chan.h ../../src/users.h \
../../src/compat/compat.h ../../src/compat/inet_aton.h \
../../src/compat/snprintf.h ../../src/compat/inet_ntop.h \
../../src/compat/inet_pton.h ../../src/compat/gethostbyname2.h \
../../src/compat/strlcpy.h
../../src/compat/compat.h ../../src/compat/base64.h \
../../src/compat/inet_aton.h ../../src/compat/snprintf.h \
../../src/compat/inet_ntop.h ../../src/compat/inet_pton.h \
../../src/compat/gethostbyname2.h ../../src/compat/strlcpy.h
inet_pton.o: inet_pton.c inet_pton.h ../../src/main.h ../../config.h \
../../eggint.h ../../lush.h ../../src/lang.h ../../src/eggdrop.h \
../../src/compat/in6.h ../../src/flags.h ../../src/proto.h \
../../src/misc_file.h ../../src/cmdt.h ../../src/tclegg.h \
../../src/tclhash.h ../../src/chan.h ../../src/users.h \
../../src/compat/compat.h ../../src/compat/inet_aton.h \
../../src/compat/snprintf.h ../../src/compat/inet_ntop.h \
../../src/compat/inet_pton.h ../../src/compat/gethostbyname2.h \
../../src/compat/strlcpy.h
../../src/compat/compat.h ../../src/compat/base64.h \
../../src/compat/inet_aton.h ../../src/compat/snprintf.h \
../../src/compat/inet_ntop.h ../../src/compat/inet_pton.h \
../../src/compat/gethostbyname2.h ../../src/compat/strlcpy.h
snprintf.o: snprintf.c ../../src/main.h ../../config.h ../../eggint.h \
../../lush.h ../../src/lang.h ../../src/eggdrop.h ../../src/compat/in6.h \
../../src/flags.h ../../src/proto.h ../../src/misc_file.h \
../../src/cmdt.h ../../src/tclegg.h ../../src/tclhash.h ../../src/chan.h \
../../src/users.h ../../src/compat/compat.h ../../src/compat/inet_aton.h \
../../src/main.h ../../src/compat/snprintf.h \
../../src/compat/inet_ntop.h ../../src/compat/inet_pton.h \
../../src/compat/gethostbyname2.h ../../src/compat/strlcpy.h snprintf.h
../../src/users.h ../../src/compat/compat.h ../../src/compat/base64.h \
../../src/compat/inet_aton.h ../../src/main.h \
../../src/compat/snprintf.h ../../src/compat/inet_ntop.h \
../../src/compat/inet_pton.h ../../src/compat/gethostbyname2.h \
../../src/compat/strlcpy.h snprintf.h
strlcpy.o: strlcpy.c ../../config.h

0 comments on commit 7ea72e9

Please sign in to comment.
You can’t perform that action at this time.