Exemplo n.º 1
0
def reset_token_commands(args):
    if args.clear_reset_password:
        username = args.clear_reset_password
    else:
        username = args.reset_password

    # duplicate some minimal setup needed for this to work
    config.logging_config.pop('filename', None)
    args.logfile = "<stdout>"  # make the log message easier to read

    init_logging(config.logging_config)

    if not check_config():
        err_exit("Errors in config. Exiting.")
    if config.dgl_mode:
        userdb.ensure_user_db_exists()
        userdb.upgrade_user_db()
    userdb.ensure_settings_db_exists()
    user_info = userdb.get_user_info(username)
    if not user_info:
        err_exit("Reset/clear password failed; invalid user: %s" % username)

    # don't crash on the default config
    if config.lobby_url is None:
        config.lobby_url = "[insert lobby url here]"

    if args.clear_reset_password:
        ok, msg = userdb.clear_password_token(username)
        if not ok:
            err_exit("Error clearing password reset token for %s: %s" % (username, msg))
        else:
            print("Password reset token cleared for account '%s'." % username)
    else:
        ok, msg = userdb.generate_forgot_password(username)
        if not ok:
            err_exit("Error generating password reset token for %s: %s" % (username, msg))
        else:
            if not user_info[1]:
                logging.warning("No email set for account '%s', use caution!" % username)
            print("Setting a password reset token on account '%s'." % username)
            print("Email: %s\nMessage body to send to user:\n%s\n" % (user_info[1], msg))
Exemplo n.º 2
0
    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGHUP, signal_handler)
    signal.signal(signal.SIGINT, signal_handler)

    if umask is not None:
        os.umask(umask)

    write_pidfile()

    servers = bind_server()
    ensure_tornado_current()

    shed_privileges()

    if dgl_mode:
        userdb.ensure_user_db_exists()
        userdb.upgrade_user_db()
    userdb.ensure_settings_db_exists()
    try:
        IOLoop.current().set_blocking_log_threshold(0.5)  # type: ignore
        logging.info("Blocking call timeout: 500ms.")
    except:
        # this is the new normal; still not sure of a way to deal with this.
        logging.info("Webserver running without a blocking call timeout.")

    if dgl_mode:
        status_file_timeout()
        auth.purge_login_tokens_timeout()
        start_reading_milestones()

        if watch_socket_dirs:
Exemplo n.º 3
0
        daemonize()

    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGHUP, signal_handler)

    if umask is not None:
        os.umask(umask)

    write_pidfile()

    servers = bind_server()

    shed_privileges()

    if dgl_mode:
        userdb.ensure_user_db_exists()
    userdb.ensure_settings_db_exists()

    ioloop = tornado.ioloop.IOLoop.instance()
    ioloop.set_blocking_log_threshold(0.5)

    if dgl_mode:
        status_file_timeout()
        purge_login_tokens_timeout()
        start_reading_milestones()

        if watch_socket_dirs:
            process_handler.watch_socket_dirs()

    logging.info("Webtiles server started! (PID: %s)" % os.getpid())
Exemplo n.º 4
0
def server_main():
    args = parse_args()
    if config.chroot:
        os.chroot(config.chroot)

    if getattr(config, 'live_debug', False):
        logging.info("Starting in live-debug mode.")
        config.watch_socket_dirs = False

    # do this here so it can happen before logging init
    if args.logfile:
        if args.logfile == "-":
            config.logging_config.pop('filename', None)
            args.logfile = "<stdout>"  # make the log message easier to read
        else:
            config.logging_config['filename'] = args.logfile

    init_logging(config.logging_config)

    if args.logfile:
        logging.info("Using command-line supplied logfile: '%s'", args.logfile)

    _do_load_games()

    export_args_to_config(args)

    if not check_config():
        err_exit("Errors in config. Exiting.")

    if config.daemon:
        daemonize()

    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGHUP, signal_handler)
    signal.signal(signal.SIGINT, signal_handler)

    if getattr(config, 'umask', None) is not None:
        os.umask(config.umask)

    write_pidfile()

    global servers
    servers = bind_server()
    ensure_tornado_current()

    shed_privileges()

    if config.dgl_mode:
        userdb.ensure_user_db_exists()
        userdb.upgrade_user_db()
    userdb.ensure_settings_db_exists()

    signal.signal(signal.SIGUSR1, usr1_handler)

    try:
        IOLoop.current().set_blocking_log_threshold(0.5) # type: ignore
        logging.info("Blocking call timeout: 500ms.")
    except:
        # this is the new normal; still not sure of a way to deal with this.
        logging.info("Webserver running without a blocking call timeout.")

    if config.dgl_mode:
        status_file_timeout()
        auth.purge_login_tokens_timeout()
        start_reading_milestones()

        if config.watch_socket_dirs:
            process_handler.watch_socket_dirs()

    logging.info("DCSS Webtiles server started with Tornado %s! (PID: %s)" %
                                                (tornado.version, os.getpid()))

    IOLoop.current().start()

    logging.info("Bye!")
    remove_pidfile()