commit 12e8db7eadb8638bf29c97e2bb2c9f9a847fea71
parent 34538f5ec0495938565fdabea301200c62fa30ce
Author: MTRNord <mtrnord1@gmail.com>
Date: Fri, 22 Sep 2017 20:27:45 +0200
make string concating prettier
Signed-off-by: MTRNord <mtrnord1@gmail.com>
Diffstat:
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/broker.cpp b/broker.cpp
@@ -2,16 +2,12 @@
// Created by marce on 22.09.2017.
//
-#ifdef linux
+//#ifdef linux
#include "broker.h"
#include <iostream>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <errno.h>
- #include <stdlib.h>
+#include <sys/wait.h>
- using namespace std;
+using namespace std;
broker::TunnelManager::TunnelManager(const char * nspaceL) {
nspace = nspaceL;
@@ -20,8 +16,9 @@
int broker::TunnelManager::initialize() {
printf("Prepare Routing");
- char * prerouting_chain = (char *) printf("L2TP_PREROUTING_%s", nspace);
- char * postrouting_chain = (char *) printf("L2TP_POSTROUTING_%s", nspace);
+
+ string prerouting_chain = (string) "L2TP_PREROUTING_" + nspace;
+ string postrouting_chain = (string) "L2TP_POSTROUTING_" + nspace;
pid_t pid;
int status;
@@ -55,4 +52,4 @@
return 0;
}
-#endif
-\ No newline at end of file
+//#endif
+\ No newline at end of file
diff --git a/main.cpp b/main.cpp
@@ -28,8 +28,8 @@ int main(int argc, char* argv[]) {
std::cout << "Config loaded from '"<< configFile << "': address="
<< reader.Get("broker", "address", "UNKNOWN") << ", port="
<< reader.Get("broker", "port", "UNKNOWN") << endl;
- int uid=getuid(), euid=geteuid();
- if (uid<0 || uid!=euid) {
+ int uid=getuid();
+ if (uid == 0) {
/* We might have elevated privileges beyond that of the user who invoked
* the program, due to suid bit. Be very careful about trusting any data! */
@@ -38,7 +38,7 @@ int main(int argc, char* argv[]) {
broker::TunnelManager tunnelManager(nspaceL.c_str());
tunnelManager.initialize();
} else {
- /* Anything goes. */
+ std::cout << "Please run this as root" << endl;
}
return 0;
#else