Commit c52ee536 authored by Jondy Zhao's avatar Jondy Zhao

fix problem: ovpn-client/server could not write data to pipe

parent f6f91b10
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *p;
int pd; int pd;
char buf[512]; char buf[512];
int n; int n;
...@@ -22,8 +21,8 @@ int main(int argc, char *argv[]) ...@@ -22,8 +21,8 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
pd = strtol(argv[1], &p, 10); pd = open(argv[1], 1);
if (! (*p == 0)) { if (pd == -1) {
fprintf(stderr, "invalid pipe %s\n", argv[1]); fprintf(stderr, "invalid pipe %s\n", argv[1]);
return 1; return 1;
} }
......
...@@ -14,7 +14,6 @@ if arg1 != 'None': ...@@ -14,7 +14,6 @@ if arg1 != 'None':
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *p;
int pd; int pd;
char buf[512]; char buf[512];
int n; int n;
...@@ -67,8 +66,8 @@ int main(int argc, char *argv[]) ...@@ -67,8 +66,8 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "None") == 0) if (strcmp(argv[1], "None") == 0)
return 0; return 0;
pd = strtol(argv[1], &p, 10); pd = open(argv[1], 1);
if (! (*p == 0)) { if (pd == -1) {
fprintf(stderr, "invalid pipe %s\n", argv[1]); fprintf(stderr, "invalid pipe %s\n", argv[1]);
return 1; return 1;
} }
......
...@@ -31,7 +31,7 @@ def openvpn(iface, encrypt, *args, **kw): ...@@ -31,7 +31,7 @@ def openvpn(iface, encrypt, *args, **kw):
def server(iface, max_clients, dh_path, pipe_fd, port, proto, encrypt, *args, **kw): def server(iface, max_clients, dh_path, pipe_fd, port, proto, encrypt, *args, **kw):
client_script = '%s %s' % (ovpn_server, pipe_fd) client_script = '%s /proc/%u/fd/%s' % (ovpn_server, os.getpid(), pipe_fd)
if pipe_fd is not None: if pipe_fd is not None:
args = ('--client-disconnect', client_script) + args args = ('--client-disconnect', client_script) + args
return openvpn(iface, encrypt, return openvpn(iface, encrypt,
......
...@@ -65,7 +65,7 @@ class Connection(object): ...@@ -65,7 +65,7 @@ class Connection(object):
'--resolv-retry', '0', '--resolv-retry', '0',
'--connect-retry-max', '3', '--tls-exit', '--connect-retry-max', '3', '--tls-exit',
'--ping-exit', str(timeout), '--ping-exit', str(timeout),
'--route-up', '%s %u' % (plib.ovpn_client, write_pipe), '--route-up', '%s /proc/%u/fd/%u' % (plib.ovpn_client, os.getpid(), write_pipe),
*ovpn_args) *ovpn_args)
_retry += 1 _retry += 1
self._retry = _retry < len(self.address_list) and ( self._retry = _retry < len(self.address_list) and (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment