MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / sysctl_set

Function sysctl_set

sshuttle/methods/ipfw.py:75–96  ·  view source on GitHub ↗
(name, val, permanent=False)

Source from the content-addressed store, hash-verified

73
74
75def sysctl_set(name, val, permanent=False):
76 PREFIX = 'net.inet.ip'
77 assert name.startswith(PREFIX + '.')
78 val = str(val)
79 if not _oldctls:
80 _fill_oldctls(PREFIX)
81 if not (name in _oldctls):
82 debug1('>> No such sysctl: %r' % name)
83 return False
84 oldval = _oldctls[name]
85 if val != oldval:
86 rv = _sysctl_set(name, val)
87 if rv == 0 and permanent:
88 debug1('>> ...saving permanently in /etc/sysctl.conf')
89 f = open('/etc/sysctl.conf', 'a')
90 f.write('\n'
91 '# Added by sshuttle\n'
92 '%s=%s\n' % (name, val))
93 f.close()
94 else:
95 _changedctls.append(name)
96 return True
97
98
99def ipfw(*args):

Callers 1

setup_firewallMethod · 0.85

Calls 5

debug1Function · 0.90
_fill_oldctlsFunction · 0.85
_sysctl_setFunction · 0.85
writeMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected