GithubHelp home page GithubHelp logo

ovpn-py's Introduction

OpenVPN embedded Python plugin.

This plugin implements V1 OpenVPN plugin interface,
thus in other words getting many info from OpenVPN
and returning only TRUE/FALSE values.

It is loaded as other plugins. Plugin parameters are:
1. module name which will be imported the same way as
if it was "import ..." from Python. Mandatory. By
default it prepends plugin (.so) path to sys.path.
2. Path which will be prepended to Python "sys.path"
and where also module noted in 1-st parameter will
be searched for. Optional. In this case plugin (.so)
path is not in sys.path, but this parameter path.

Module.
Module should contain anything, but at least two
callback functions must be declared:
1. plugin_up() which is called on initialization of
plugin.
2. plugin_down() which is called on OpenVPN shutdown.

Next callbacks which are optional:
route_up()
ipchange()
tls_verify()
auth_user_pass_verify()
client_connect()
client_disconnect()
learn_address()
tls_final()
enable_pf()

During initialization of plugin those optional callbacks
are searched for presence and if they are Python callable.
If so, OpenVPN type mask is set for particular callbacks,
so only those, which are declared, are advertised to
OpenVPN.
Every callback has at least one parameter, environment
which is Python dictionary. It is not system env., but
OpenVPN environment. Callbacks are expected to return
only True/False values. Look at sample module in sources.

Import and use what you wish, but threading is not
anyhow handled. In fact may be it is not a problem
for this plugin cause of its behavior, but keep it
on mind.

ovpn-py's People

Contributors

nudzo avatar

Watchers

 avatar

ovpn-py's Issues

openvpn server with ovpn-py plugin crashes

What steps will reproduce the problem?
1. Install openvpn 2.2.1
2. Build ovpn-py.c
3. Write plugin in Python
4. Create openvpn configuration that uses the Python plugin
5. Start openvpn  

What is the expected output?
openvpn runs forever

What do you see instead?
openvpn crashes after several hours of normal operation with the following 
trace:

Core was generated by `/usr/sbin/openvpn --daemon --writepid 
/var/run/openvpn/vpn-udp.pid --config vpn'. 
Program terminated with signal 6, Aborted. 
#0 0x00bd6402 in __kernel_vsyscall () 
(gdb) where 
#0 0x00bd6402 in __kernel_vsyscall () 
#1 0x003dfdf0 in raise () from /lib/libc.so.6 
#2 0x003e1701 in abort () from /lib/libc.so.6 
#3 0x003d926b in __assert_fail () from /lib/libc.so.6 
#4 0x00652f8d in visit_decref (op=0xb7c6bbdc, data=0x0) at 
Modules/gcmodule.c:277 
#5 0x005b8c7c in frame_traverse (f=0x90e195c, visit=0x652ee0 <visit_decref>, 
arg=0x0) at Objects/frameobject.c:461 
#6 0x006535d8 in subtract_refs (generation=2) at Modules/gcmodule.c:296 
#7 collect (generation=2) at Modules/gcmodule.c:817 
#8 0x00653fa8 in collect_generations (basicsize=12) at Modules/gcmodule.c:924 
#9 _PyObject_GC_Malloc (basicsize=12) at Modules/gcmodule.c:1363 
#10 0x00654035 in _PyObject_GC_New (tp=0x6b50c0) at Modules/gcmodule.c:1373 
#11 0x0059f31b in PyCell_New (obj=0x6b2c30) at Objects/cellobject.c:10 
#12 0x00629e91 in PyEval_EvalCodeEx (co=0x8f11410, globals=0x8e291c4, 
locals=0x0, args=0x90f0fd4, argcount=2, kws=0x90f0fdc, kwcount=1, 
    defs=0x8f84e98, defcount=1, closure=0x0) at Python/ceval.c:2962 
#13 0x00628338 in call_function (f=0x90f0e5c, throwflag=0) at 
Python/ceval.c:3846 
#14 PyEval_EvalFrameEx (f=0x90f0e5c, throwflag=0) at Python/ceval.c:2412 
#15 0x0062a3f1 in PyEval_EvalCodeEx (co=0x8f11848, globals=0x8e291c4, 
locals=0x0, args=0x90ef40c, argcount=1, kws=0x90ef410, kwcount=0, 
    defs=0x8f84ef8, defcount=1, closure=0x0) at Python/ceval.c:3000 
#16 0x00628338 in call_function (f=0x90ef27c, throwflag=0) at 
Python/ceval.c:3846 
#17 PyEval_EvalFrameEx (f=0x90ef27c, throwflag=0) at Python/ceval.c:2412 
#18 0x0062a3f1 in PyEval_EvalCodeEx (co=0x8f8a0f8, globals=0x8f8668c, 
locals=0x0, args=0x90e2a28, argcount=15, kws=0x90e2a64, kwcount=0, 
    defs=0x8f8a3e0, defcount=12, closure=0x0) at Python/ceval.c:3000 
#19 0x00628338 in call_function (f=0x90e28b4, throwflag=0) at 
Python/ceval.c:3846 
#20 PyEval_EvalFrameEx (f=0x90e28b4, throwflag=0) at Python/ceval.c:2412 
#21 0x0062a3f1 in PyEval_EvalCodeEx (co=0x8f119f8, globals=0x8f862d4, 
locals=0x0, args=0x8f84498, argcount=2, kws=0x90244d0, kwcount=1, 
    defs=0x8f1bce0, defcount=12, closure=0x0) at Python/ceval.c:3000 
#22 0x005bb0a9 in function_call (func=0x8f82f0c, arg=0x8f8448c, kw=0xa6570b4) 
at Objects/funcobject.c:524 
#23 0x0058f58c in PyObject_Call (func=0x8f82f0c, arg=0x8f8448c, kw=0xa6570b4) 
at Objects/abstract.c:2492 
#24 0x00624adf in ext_do_call (f=0x90e274c, throwflag=0) at Python/ceval.c:4063 
#25 PyEval_EvalFrameEx (f=0x90e274c, throwflag=0) at Python/ceval.c:2452 
#26 0x0062a3f1 in PyEval_EvalCodeEx (co=0x8f16920, globals=0x8f862d4, 
locals=0x0, args=0x90e1ab0, argcount=1, kws=0x90e1ab4, kwcount=0, 
    defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3000 
#27 0x00628338 in call_function (f=0x90e195c, throwflag=0) at 
Python/ceval.c:3846 
#28 PyEval_EvalFrameEx (f=0x90e195c, throwflag=0) at Python/ceval.c:2412 
---Type <return> to continue, or q <return> to quit--- 
#29 0x0062a3f1 in PyEval_EvalCodeEx (co=0xb7ecd260, globals=0xb7c6bbdc, 
locals=0x0, args=0xb7c68858, argcount=1, kws=0x0, kwcount=0, defs=0x0, 
    defcount=0, closure=0x0) at Python/ceval.c:3000 
#30 0x005bafba in function_call (func=0x8fa217c, arg=0xb7c6884c, kw=0x0) at 
Objects/funcobject.c:524 
#31 0x0058f58c in PyObject_Call (func=0x8fa217c, arg=0xb7c6884c, kw=0x0) at 
Objects/abstract.c:2492 
#32 0x00622f74 in PyEval_CallObjectWithKeywords (func=0x8fa217c, 
arg=0xb7c6884c, kw=0x0) at Python/ceval.c:3619 
#33 0x0058ffcc in PyObject_CallObject (o=0x8fa217c, a=0xb7c6884c) at 
Objects/abstract.c:2480 
#34 0x0094edcb in openvpn_plugin_func_v1 (handle=0x8d3d4a0, type=5, 
argv=0x90600c8, envp=0x952c4c8) at ovpn-py.c:179 
#35 0x0808c4b4 in plugin_call () 
#36 0x080a2abc in key_method_2_read () 
#37 0x080a45ff in tls_process () 
#38 0x080a55fc in tls_multi_process () 
#39 0x08055b07 in check_tls_dowork () 
#40 0x08057c32 in pre_select () 
#41 0x08071889 in multi_process_post () 
#42 0x08073893 in multi_process_incoming_link () 
#43 0x0806ec12 in tunnel_server_udp () 
#44 0x08077430 in main () 

What version of the product are you using? On what operating system?
openvpn 2.2.1, 32-bit CentOS 5.6

Please provide any additional information below.
The call trace above is for openvpn server using UDP, TCP server crashes too 
with exact same call trace. 

Original issue reported on code.google.com by [email protected] on 24 Nov 2011 at 4:08

lib-dynload PyExc_ValueError

On ubuntu <= 10.10 if you got problems similar to 
http://bugs.python.org/issue4434 id est « ImportError: 
/usr/lib/python2.6/lib-dynload/SOMETHING.so: undefined symbol: PyExc_ValueError 
»

Open ovpn-py.c , append #include <dlfcn.h> after #include « "openvpn-plugin.h" 
» and dlopen("libpython2.6.so", RTLD_LAZY |RTLD_GLOBAL); before     « 
Py_Initialize(); »

Original issue reported on code.google.com by [email protected] on 8 Dec 2010 at 1:13

Questions

1. Just wondering if you have detail documentation or steps on how to build 
the plugins ?  

2. Would this plugin work if I'm using OVPN 2.2x, the reason being is some of 
the API calls used on this plugin are using v1 

Thanks for your help, 
Cheers

Original issue reported on code.google.com by [email protected] on 25 Jan 2010 at 6:07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.