Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Capabilities #185

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
db3d867
Initial attempt at libcap - untested!
mhaas Mar 15, 2015
6a2e306
Fix: wifidog requires CAP_NET_RAW
mhaas Mar 16, 2015
5f71eb7
Cherry-pick SOCK_PACKET -> SOCK_RAW
mhaas Mar 16, 2015
9326edf
Fix: drop group first, regain privileges
mhaas Mar 16, 2015
d280fb5
Merge branch 'master' of https://github.com/mhaas/wifidog-gateway int…
mhaas Mar 25, 2015
78b537f
Merge branch 'master' of https://github.com/wifidog/wifidog-gateway i…
mhaas Mar 25, 2015
93c94db
Merge branch 'coverity-fixes' into HEAD
mhaas Mar 25, 2015
6f6f526
Move drop_privileges to capabilities.c
mhaas Mar 25, 2015
c0ef73c
Add debug output
mhaas Mar 25, 2015
6c18daf
Error handling in capabilities.c
mhaas Mar 25, 2015
fbf3556
Fix compilation
mhaas Mar 25, 2015
2a54bdf
Merge branch 'master' of https://github.com/wifidog/wifidog-gateway i…
mhaas Apr 3, 2015
c0d284c
Tabs -> spaces
mhaas Apr 3, 2015
bd19dc8
Capabilities: Fix unnecessary calls
mhaas Apr 3, 2015
1d324c5
Add user/group config option
mhaas Apr 3, 2015
2131aae
Fix: CAP_NET_ADMIN is actually required, add back
mhaas Apr 3, 2015
05af333
Add TODO - need to check return values!
mhaas Apr 3, 2015
6302dda
Capabilities: error handling, comment
mhaas Apr 3, 2015
a0a78a8
Refactor capabilities.c and hook up fw_iptables.c
mhaas Apr 3, 2015
8ad25bc
Remove TODO
mhaas Apr 3, 2015
6f6cdac
Add license header, fix formatting
mhaas Apr 3, 2015
be3e019
Fix typo: open -> popen
mhaas Apr 3, 2015
ef379f3
Fix help string for --enable-libcap
mhaas Apr 3, 2015
79e60f1
Fix alignment of configure help
acv Apr 3, 2015
9af8215
OCD realignment
acv Apr 3, 2015
05c04c7
Rename build type cyassl -> full
mhaas Apr 8, 2015
9c26326
Respect $CFLAGS in travis configure wrapper
mhaas Apr 8, 2015
58984c3
Travis: build libcap
mhaas Apr 8, 2015
b750717
Also build libattr as a libcap dependency
mhaas Apr 8, 2015
f507078
Refactor travis_configure_wrapper
mhaas Apr 8, 2015
5dee3cf
Reset CFLAGS, libattr fails due to -Werror
mhaas Apr 8, 2015
3e26b42
Free memory, use thread-safe getpwnam_r
mhaas Apr 8, 2015
3cc6aca
Fix unprivileged group example
mhaas Apr 8, 2015
142d289
Merge branch 'master' of https://github.com/wifidog/wifidog-gateway i…
mhaas Apr 8, 2015
426a1c1
Merge pull request #3 from acv/feature-capabilities-3
mhaas Apr 8, 2015
fcde454
Merge branch 'feature-capabilities-3' of https://github.com/mhaas/wif…
mhaas Apr 8, 2015
b471afb
Re-order declarations
mhaas Apr 8, 2015
e445b38
Fix missing variable in travis configure wrapper
mhaas Apr 8, 2015
87c5572
Fix libcap include paths
mhaas Apr 8, 2015
56c8fd2
Fix libcap install location
mhaas Apr 8, 2015
c78e25c
Fix prefix for libcap
mhaas Apr 8, 2015
d03694d
Merge branch 'master' of https://github.com/wifidog/wifidog-gateway i…
mhaas Apr 8, 2015
3031faa
Free some memory
mhaas Apr 8, 2015
a83394c
Run indent
mhaas Apr 8, 2015
070435a
Fix superfluous newlines in capabilities.h decl
mhaas Apr 8, 2015
42e5341
Fix typo: , -> ;
mhaas Apr 8, 2015
897a695
Remove erroneous comment
mhaas Apr 9, 2015
7a24ddb
Fix typo
mhaas Apr 9, 2015
d64cd9f
Merge branch 'master' into feature-capabilities-3
mhaas Jul 26, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
- secure: fiVVKcMM8Cz8WAj6PB6eD/b+Y77klXOe9jbpehf6QwjFwf6paEHoMsrZ0aFXogm2Uej47GlTdRb3UkBqonbK4ANbu0ewsWCW0RGClZz5ghaSnfwdxEhuXsrFIax7DvJCStk2V84Keb+tSVemx4opxqZAlZ/Nen28S91KSDoJeRA=
matrix:
- BUILD_TYPE=normal
- CYASSL="3.3.2" BUILD_TYPE=cyassl
- LIBATTR="2.4.47" LIBCAP="2.24" CYASSL="3.3.2" BUILD_TYPE="full"
cache:
directories:
- dependencies-src
Expand Down
115 changes: 95 additions & 20 deletions .travis_configure_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
#!/usr/bin/env bash

if [[ -z "$BUILD_TYPE" ]]; then
echo "BUILD_TYPE not set. Bye."
exit 1
fi

if [[ "$BUILD_TYPE" == "normal" ]]; then
function main {
if [[ -z "$BUILD_TYPE" ]]; then
echo "BUILD_TYPE not set. Bye."
exit 1
fi

echo "Running Wifidog configure"
./configure $@
if [[ "$BUILD_TYPE" == "normal" ]]; then

elif [[ "$BUILD_TYPE" == "cyassl" ]]; then
if [[ -z "$CYASSL" ]]; then
echo "CYASSL not set."
echo "Running Wifidog configure"
./configure $@

elif [[ "$BUILD_TYPE" == "full" ]]; then
if [[ -z "$CYASSL" || -z "$LIBCAP" || -z "$LIBATTR" ]]; then
echo "Make sure that CYASSL, LIBCAP and LIBATTR are set."
exit 1
fi
mkdir -p dependencies-src || true
mkdir -p dependencies-installed || true
# reset CFLAGS because some dependencies generate warnings
OLD_CFLAGS="${CFLAGS}"
OLD_CXXFLAGS="${CXXFLAGS}"
OLD_LDFLAGS="${LDFLAGS}"
CUR=`pwd`
export CFLAGS="-I${CUR}/dependencies-installed/include/"
export CXXFLAGS="-I${CUR}/dependencies-installed/include/"
export LDFLAGS="-L${CUR}/dependencies-installed/lib/"
build_cyassl
build_libattr
build_libcap
echo "Running Wifidog configure"
export CFLAGS="${OLD_CFLAGS} ${CFLAGS}"
export CXXFLAGS="${OLD_CXXFLAGS} ${LDFLAGS}"
export LDFLAGS="${OLD_LDFLAGS} ${LDFLAGS}"
./configure --enable-cyassl --enable-libcap $@
else
echo "Unknow BUILD_TYPE $BUILD_TYPE"
exit 1
fi

}

function build_cyassl {
# TODO: changing $CYASSL version number will not invalidate this check
# Need to remove full cache in travis interface if we want to upgrade
# CyaSSL
CUR=`pwd`
mkdir -p dependencies-src || true
mkdir -p dependencies-installed || true
if [[ ! -f dependencies-installed/include/cyassl/ssl.h ]]; then
echo "Cached CyaSSL install not found. Installing."
cd dependencies-src
Expand Down Expand Up @@ -47,11 +76,57 @@ elif [[ "$BUILD_TYPE" == "cyassl" ]]; then
else
echo "Cached CyaSSL install found."
fi
echo "Running Wifidog configure"
export CFLAGS="-I${CUR}/dependencies-installed/include/"
export LDFLAGS="-L${CUR}/dependencies-installed/lib/"
./configure --enable-cyassl $@
else
echo "Unknow BUILD_TYPE $BUILD_TYPE"
exit 1
fi
}

function build_libcap {
CUR=`pwd`
if [[ ! -f dependencies-installed/usr/include/sys/capability.h ]]; then
echo "Cached libcap not found. Installing."
cd dependencies-src
if [[ -f libcap-${LIBCAP}/Makefile ]]; then
echo "Found cached libcap package"
else
echo "No cache, downloading libcap"
wget https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-${LIBCAP}.tar.gz \
-O libcap-${LIBCAP}.tar.gz
tar -xvzf libcap-${LIBCAP}.tar.gz
fi
cd libcap-${LIBCAP}
echo "Content of libcap-${LIBCAP}"
ls
echo "Running libcap make install"
make install DESTDIR="$CUR"/dependencies-installed/ IPATH="${CFLAGS} -fPIC -I\$(topdir)/libcap/include/uapi -I\$(topdir)/libcap/include" LDFLAGS=${LDFLAGS} RAISE_SETFCAP=no lib=lib prefix=/
cd "$CUR"
else
echo "Cached libcap install found."
fi

}

function build_libattr {
CUR=`pwd`
if [[ ! -f dependencies-installed/include/attr/libattr.h ]]; then
echo "Cached libattr not found. Installing."
cd dependencies-src
if [[ -f libattr-${LIBATTR}/configure ]]; then
echo "Found cached libattr package"
else
echo "No cache, downloading libattr"
wget http://download.savannah.gnu.org/releases/attr/attr-${LIBATTR}.src.tar.gz \
-O attr-${LIBATTR}.tar.gz
tar -xvzf attr-${LIBATTR}.tar.gz
fi
cd attr-${LIBATTR}
echo "Content of attr-${LIBATTR}"
ls
echo "Running attr configure"
./configure --prefix="$CUR"/dependencies-installed/
echo "Running attr make install"
make install install-dev install-lib
cd $CUR
else
echo "Cached attr install found."
fi
}

main
17 changes: 16 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,25 @@ AC_SUBST(enable_latex_docs)
# Acutally perform the doxygen check
BB_ENABLE_DOXYGEN

# Enable capabilities?
AC_DEFUN([BB_LIBCAP],
[
AC_ARG_ENABLE(libcap, [ --enable-libcap enable privilege dropping with capabilities (no)], [], [enable_libcap=no])
if test "x$enable_libcap" = xyes; then
AC_CHECK_HEADERS(sys/capability.h)
AC_SEARCH_LIBS([cap_get_proc], [cap], [], [
AC_MSG_ERROR([unable to find the cap_get_proc function.])
])
AC_DEFINE(USE_LIBCAP,, "Compile with libcap support")
fi
])
# Actually perform the libcap check
BB_LIBCAP

# Enable cyassl?
AC_DEFUN([BB_CYASSL],
[
AC_ARG_ENABLE(cyassl, [ --enable-cyassl enable TLS support for auth server communication (no)], [], [enable_cyassl=no])
AC_ARG_ENABLE(cyassl, [ --enable-cyassl enable TLS support for auth server communication (no)], [], [enable_cyassl=no])
if test "x$enable_cyassl" = xyes; then
AC_CHECK_HEADERS(cyassl/ssl.h)
AC_SEARCH_LIBS([CyaSSLv23_client_method], [cyassl wolfssl], [], [
Expand Down
3 changes: 3 additions & 0 deletions contrib/load-tester/wifidog-mock.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
User nobody
Group nobody

ExternalInterface eth0
GatewayInterface internal0

Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ libgateway_a_SOURCES = commandline.c \
httpd_thread.c \
simple_http.c \
pstring.c \
capabilities.c \
wd_util.c

noinst_HEADERS = commandline.h \
Expand All @@ -55,6 +56,7 @@ noinst_HEADERS = commandline.h \
httpd_thread.h \
simple_http.h \
pstring.h \
capabilities.h \
wd_util.h

wdctl_LDADD = libgateway.a
Expand Down
Loading