Exemplo n.º 1
0
def main():
    args = make_argparser().parse_args()

    if os.getuid() != 0:
        print("Must be started as root")
        sys.exit(1)

    socket = megaping.make_sockets()  # make raw sockets while we have root
    nav.daemon.switchuser(NAV_CONFIG['NAV_USER'])
    start(args.foreground, socket)
Exemplo n.º 2
0
def main():
    args = make_argparser().parse_args()

    if os.getuid() != 0:
        print("Must be started as root")
        sys.exit(1)

    socket = megaping.make_sockets()  # make raw sockets while we have root
    switch_user()
    start(args.nofork, socket)
Exemplo n.º 3
0
    myPinger = pinger(socket=sock)
    myPinger.main()


def setUser():
    conf = config.pingconf()
    username = conf.get("user", "nobody")
    nav.daemon.switchuser(username)


if __name__ == "__main__":
    nofork = 0
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hn", ["help", "nofork"])
        for opt, val in opts:
            if opt in ("-h", "--help"):
                help()
                sys.exit(0)
            elif opt in ("-n", "--nofork"):
                nofork = 1

    except getopt.error:
        help()
        sys.exit(2)
    if os.getuid() != 0:
        print("Must be started as root")
        sys.exit(1)
    sock = megaping.make_sockets()
    setUser()
    start(nofork)
Exemplo n.º 4
0
def setUser():
    conf = config.pingconf()
    username = conf.get("user", "nobody")
    nav.daemon.switchuser(username)

if __name__=="__main__":
    nofork=0
    try:
        opts, args = getopt.getopt(sys.argv[1:],
                                   "hnv",
                                   ["help","nofork", "version"])
        for opt, val in opts:
            if opt in ("-h","--help"):
                help()
                sys.exit(0)
            elif opt in ("-n","--nofork"):
                nofork=1
            elif opt in ("-v","--version"):
                print __version__
                sys.exit(0)
                
    except (getopt.error):
        help()
        sys.exit(2)
    if os.getuid() != 0:
        print "Must be started as root"
        sys.exit(1)
    sock = megaping.make_sockets()
    setUser()
    start(nofork)