mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
tinc: replace subprocess.call, closes https://github.com/opnsense/core/issues/3574
This commit is contained in:
parent
79cbb1b0b5
commit
e2fff6bade
2 changed files with 8 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
PLUGIN_NAME= tinc
|
||||
PLUGIN_VERSION= 1.4
|
||||
PLUGIN_REVISION= 4
|
||||
PLUGIN_REVISION= 5
|
||||
PLUGIN_COMMENT= Tinc VPN
|
||||
PLUGIN_DEPENDS= tinc
|
||||
PLUGIN_MAINTAINER= ad@opnsense.org
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def read_config(config_filename):
|
|||
return result
|
||||
|
||||
def deploy(config_filename):
|
||||
interfaces = (subprocess.check_output(['/sbin/ifconfig','-l'])).decode().split()
|
||||
interfaces = subprocess.run(['/sbin/ifconfig','-l'], capture_output=True, text=True).stdout.split()
|
||||
networks = read_config(config_filename)
|
||||
# remove previous configuration
|
||||
os.system('rm -rf /usr/local/etc/tinc')
|
||||
|
|
@ -91,9 +91,10 @@ def deploy(config_filename):
|
|||
|
||||
# configure and rename new tun device, place all in group "tinc" symlink associated tun device
|
||||
if interface_name not in interfaces:
|
||||
tundev = subprocess.check_output(['/sbin/ifconfig',interface_type,'create']).decode().split()[0]
|
||||
subprocess.call(['/sbin/ifconfig',tundev,'name',interface_name])
|
||||
subprocess.call(['/sbin/ifconfig',interface_name,'group','tinc'])
|
||||
tundev = subprocess.run(['/sbin/ifconfig', interface_type, 'create'],
|
||||
capture_output=True, text=True).stdout.split()[0]
|
||||
subprocess.run(['/sbin/ifconfig',tundev,'name',interface_name])
|
||||
subprocess.run(['/sbin/ifconfig',interface_name,'group','tinc'])
|
||||
if os.path.islink('/dev/%s' % interface_name):
|
||||
os.remove('/dev/%s' % interface_name)
|
||||
os.symlink('/dev/%s' % tundev, '/dev/%s' % interface_name)
|
||||
|
|
@ -102,7 +103,7 @@ def deploy(config_filename):
|
|||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == 'stop':
|
||||
for instance in glob.glob('/usr/local/etc/tinc/*'):
|
||||
subprocess.call(['/usr/local/sbin/tincd','-n',instance.split('/')[-1], '-k'])
|
||||
subprocess.run(['/usr/local/sbin/tincd','-n',instance.split('/')[-1], '-k'])
|
||||
elif sys.argv[1] == 'start':
|
||||
for netwrk in deploy('/usr/local/etc/tinc_deploy.xml'):
|
||||
subprocess.call(['/usr/local/sbin/tincd','-n',netwrk.get_network(), '-R', '-d', netwrk.get_debuglevel()])
|
||||
subprocess.run(['/usr/local/sbin/tincd','-n',netwrk.get_network(), '-R', '-d', netwrk.get_debuglevel()])
|
||||
|
|
|
|||
Loading…
Reference in a new issue