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 @@
int main(int argc, char *argv[])
{
char *p;
int pd;
char buf[512];
int n;
......@@ -22,8 +21,8 @@ int main(int argc, char *argv[])
return 1;
}
pd = strtol(argv[1], &p, 10);
if (! (*p == 0)) {
pd = open(argv[1], 1);
if (pd == -1) {
fprintf(stderr, "invalid pipe %s\n", argv[1]);
return 1;
}
......
......@@ -14,7 +14,6 @@ if arg1 != 'None':
*/
int main(int argc, char *argv[])
{
char *p;
int pd;
char buf[512];
int n;
......@@ -67,8 +66,8 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "None") == 0)
return 0;
pd = strtol(argv[1], &p, 10);
if (! (*p == 0)) {
pd = open(argv[1], 1);
if (pd == -1) {
fprintf(stderr, "invalid pipe %s\n", argv[1]);
return 1;
}
......
......@@ -31,7 +31,7 @@ def openvpn(iface, 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:
args = ('--client-disconnect', client_script) + args
return openvpn(iface, encrypt,
......
......@@ -65,7 +65,7 @@ class Connection(object):
'--resolv-retry', '0',
'--connect-retry-max', '3', '--tls-exit',
'--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)
_retry += 1
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