(name, val, permanent=False)
| 73 | |
| 74 | |
| 75 | def 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 | |
| 99 | def ipfw(*args): |
no test coverage detected