summaryrefslogtreecommitdiffstats
path: root/nexus
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-05-20 10:15:23 -0700
committerSan Mehat <san@google.com>2009-05-20 17:16:00 -0700
commit2fd9c5897aba37847879033dd1cffd345ced93fc (patch)
tree17713ae400758559fdd241ad2f7d8c7b411d73b4 /nexus
parenta61755e5fca065dfc89c7639bb672c20a4f9854e (diff)
downloadsystem_core-2fd9c5897aba37847879033dd1cffd345ced93fc.zip
system_core-2fd9c5897aba37847879033dd1cffd345ced93fc.tar.gz
system_core-2fd9c5897aba37847879033dd1cffd345ced93fc.tar.bz2
nexus: OpenVPN: Instead of creating / using a configfile, use the new
dynamic service argument support so we don't need one :) Signed-off-by: San Mehat <san@google.com> nexus: fix property max
Diffstat (limited to 'nexus')
-rw-r--r--nexus/OpenVpnController.cpp24
-rw-r--r--nexus/OpenVpnController.h5
2 files changed, 8 insertions, 21 deletions
diff --git a/nexus/OpenVpnController.cpp b/nexus/OpenVpnController.cpp
index d326ad5..411a0c7 100644
--- a/nexus/OpenVpnController.cpp
+++ b/nexus/OpenVpnController.cpp
@@ -26,6 +26,7 @@
#include "OpenVpnController.h"
#define DAEMON_PROP_NAME "vpn.openvpn.status"
+
#define DAEMON_CONFIG_FILE "/data/misc/openvpn/openvpn.conf"
OpenVpnController::OpenVpnController() :
@@ -46,13 +47,16 @@ int OpenVpnController::stop() {
}
int OpenVpnController::enable() {
-
- if (validateConfig()) {
- LOGE("Error validating configuration file");
+ char svc[PROPERTY_VALUE_MAX];
+ char tmp[64];
+
+ if (!getProperty("vpn.gateway", tmp, sizeof(tmp))) {
+ LOGE("Error reading property 'vpn.gateway' (%s)", strerror(errno));
return -1;
}
+ snprintf(svc, sizeof(svc), "openvpn:--remote %s 1194", tmp);
- if (mServiceManager->start("openvpn"))
+ if (mServiceManager->start(svc))
return -1;
return 0;
@@ -64,15 +68,3 @@ int OpenVpnController::disable() {
return -1;
return 0;
}
-
-int OpenVpnController::validateConfig() {
- unlink(DAEMON_CONFIG_FILE);
-
- FILE *fp = fopen(DAEMON_CONFIG_FILE, "w");
- if (!fp)
- return -1;
-
- fprintf(fp, "remote %s 1194\n", inet_ntoa(getVpnGateway()));
- fclose(fp);
- return 0;
-}
diff --git a/nexus/OpenVpnController.h b/nexus/OpenVpnController.h
index 7bcc098..b321029 100644
--- a/nexus/OpenVpnController.h
+++ b/nexus/OpenVpnController.h
@@ -33,11 +33,6 @@ public:
int stop();
int enable();
int disable();
-
-protected:
-
-private:
- int validateConfig();
};
#endif