system/corennnnn
修订版 | 2fd9c5897aba37847879033dd1cffd345ced93fc (tree) |
---|---|
时间 | 2009-05-21 09:16:00 |
作者 | San Mehat <san@goog...> |
Commiter | San Mehat |
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
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "OpenVpnController.h" |
27 | 27 | |
28 | 28 | #define DAEMON_PROP_NAME "vpn.openvpn.status" |
29 | + | |
29 | 30 | #define DAEMON_CONFIG_FILE "/data/misc/openvpn/openvpn.conf" |
30 | 31 | |
31 | 32 | OpenVpnController::OpenVpnController() : |
@@ -46,13 +47,16 @@ int OpenVpnController::stop() { | ||
46 | 47 | } |
47 | 48 | |
48 | 49 | int OpenVpnController::enable() { |
49 | - | |
50 | - if (validateConfig()) { | |
51 | - LOGE("Error validating configuration file"); | |
50 | + char svc[PROPERTY_VALUE_MAX]; | |
51 | + char tmp[64]; | |
52 | + | |
53 | + if (!getProperty("vpn.gateway", tmp, sizeof(tmp))) { | |
54 | + LOGE("Error reading property 'vpn.gateway' (%s)", strerror(errno)); | |
52 | 55 | return -1; |
53 | 56 | } |
57 | + snprintf(svc, sizeof(svc), "openvpn:--remote %s 1194", tmp); | |
54 | 58 | |
55 | - if (mServiceManager->start("openvpn")) | |
59 | + if (mServiceManager->start(svc)) | |
56 | 60 | return -1; |
57 | 61 | |
58 | 62 | return 0; |
@@ -64,15 +68,3 @@ int OpenVpnController::disable() { | ||
64 | 68 | return -1; |
65 | 69 | return 0; |
66 | 70 | } |
67 | - | |
68 | -int OpenVpnController::validateConfig() { | |
69 | - unlink(DAEMON_CONFIG_FILE); | |
70 | - | |
71 | - FILE *fp = fopen(DAEMON_CONFIG_FILE, "w"); | |
72 | - if (!fp) | |
73 | - return -1; | |
74 | - | |
75 | - fprintf(fp, "remote %s 1194\n", inet_ntoa(getVpnGateway())); | |
76 | - fclose(fp); | |
77 | - return 0; | |
78 | -} |
@@ -33,11 +33,6 @@ public: | ||
33 | 33 | int stop(); |
34 | 34 | int enable(); |
35 | 35 | int disable(); |
36 | - | |
37 | -protected: | |
38 | - | |
39 | -private: | |
40 | - int validateConfig(); | |
41 | 36 | }; |
42 | 37 | |
43 | 38 | #endif |