From 2fd9c5897aba37847879033dd1cffd345ced93fc Mon Sep 17 00:00:00 2001 From: San Mehat Date: Wed, 20 May 2009 10:15:23 -0700 Subject: [PATCH] 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 nexus: fix property max --- nexus/OpenVpnController.cpp | 24 ++++++++---------------- nexus/OpenVpnController.h | 5 ----- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/nexus/OpenVpnController.cpp b/nexus/OpenVpnController.cpp index d326ad5df..411a0c768 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 7bcc098f1..b3210299c 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