am 2fd9c589: nexus: OpenVPN: Instead of creating / using a configfile, use the new dynamic service argument support so we don\'t need one :)

Merge commit '2fd9c5897aba37847879033dd1cffd345ced93fc'

* commit '2fd9c5897aba37847879033dd1cffd345ced93fc':
  nexus: OpenVPN: Instead of creating / using a configfile, use the new
This commit is contained in:
San Mehat 2009-05-20 17:36:17 -07:00 committed by The Android Open Source Project
commit 13dee24501
2 changed files with 8 additions and 21 deletions

View File

@ -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;
}

View File

@ -33,11 +33,6 @@ public:
int stop();
int enable();
int disable();
protected:
private:
int validateConfig();
};
#endif