Commit 27b0be38 authored by Martín Ferrari's avatar Martín Ferrari

config.run_as attribute and get_nodes

parent b5ef8214
#!/usr/bin/env python #!/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4 # vim:ts=4:sw=4:et:ai:sts=4
import os import os, pwd
from netns.node import Node from netns.node import Node
class __Config(object): class __Config(object):
def __init__(self): def __init__(self):
self.run_as = None self._run_as = 65535
try:
self._run_as = pwd.getpwnam('nobody')[2]
except:
pass
def _set_run_as(self, uid):
if type(uid) != int:
uid = pwd.getpwnam(uid)[2]
if uid == 0:
raise AttributeError("Cannot run as root by default")
self._run_as = uid
def _get_run_as(self):
return self._run_as
run_as = property(_get_run_as, _set_run_as, None,
"Default uid to run applications as")
config = __Config() config = __Config()
__nodes = set() get_nodes = Node.get_nodes
def get_nodes():
return set(__nodes)
def set_cleanup_hooks(on_exit = False, on_signals = []): def set_cleanup_hooks(on_exit = False, on_signals = []):
pass pass
......
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