summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile9
-rw-r--r--src/anytun.cpp8
-rw-r--r--src/daemon.hpp2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/Makefile b/src/Makefile
index e328929..87c3f47 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -117,16 +117,19 @@ strip: $(EXECUTABLE)
anytun: $(OBJS) $(SYNCOBJS) anytun.o
$(LD) $(OBJS) $(SYNCOBJS) anytun.o -o $@ $(LDFLAGS)
-anytun-static: $(OBJS) $(SYNCOBJS) anytun.o
- $(LD) $(OBJS) $(SYNCOBJS) anytun.o -o $@ -static-libgcc -static $(LDFLAGS) -lpthread
+anytun-static: $(OBJS) $(SYNCOBJS) anytun-noprivdrop.o
+ $(LD) $(OBJS) $(SYNCOBJS) anytun-noprivdrop.o -o $@ -Bstatic -lstdc++ -static $(LDFLAGS) -lpthread
strip -s anytun-static
anytun-nosync: $(OBJS) anytun-nosync.o
$(LD) $(OBJS) anytun-nosync.o -o $@ $(LDFLAGS)
-anytun-nosync.o: anytun.cpp anytun.o
+anytun-nosync.o: anytun.cpp
$(CXX) $(CXXFLAGS) -DANYTUN_NOSYNC $< -c -o anytun-nosync.o
+anytun-noprivdrop.o: anytun.cpp
+ $(CXX) $(CXXFLAGS) -DNO_PRIVDROP $< -c -o anytun-noprivdrop.o
+
anytun-showtables: $(OBJS) $(SYNCOBJS) anytun-showtables.o
$(LD) $(OBJS) $(SYNCOBJS) anytun-showtables.o -o $@ $(LDFLAGS)
diff --git a/src/anytun.cpp b/src/anytun.cpp
index 84e5582..ab847a8 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -338,7 +338,9 @@ int main(int argc, char* argv[])
}
#ifndef NO_DAEMON
- PrivInfo privs(gOpt.getUsername(), gOpt.getGroupname());
+#ifndef NO_PRIVDROP
+ PrivInfo privs(gOpt.getUsername(), gOpt.getGroupname());
+#endif
std::ofstream pidFile;
if(gOpt.getPidFile() != "") {
@@ -404,9 +406,9 @@ int main(int argc, char* argv[])
#ifndef NO_DAEMON
if(gOpt.getChrootDir() != "")
do_chroot(gOpt.getChrootDir());
-
+#ifndef NO_PRIVDROP
privs.drop();
-
+#endif
if(gOpt.getDaemonize()) {
daemonize();
daemonized = true;
diff --git a/src/daemon.hpp b/src/daemon.hpp
index 4b59661..cc9a2b2 100644
--- a/src/daemon.hpp
+++ b/src/daemon.hpp
@@ -45,6 +45,7 @@
#include "log.h"
+#ifndef NO_PRIVDROP
class PrivInfo
{
public:
@@ -101,6 +102,7 @@ private:
struct passwd* pw_;
struct group* gr_;
};
+#endif
void do_chroot(std::string const& chrootdir)
{