Ejemplo n.º 1
0
 def test_ngcco06(self):
     gk = gatekeeper.GateKeeper()
     cwd = os.getcwd()
     ffn = cwd + "/test/ngcco06.jpg"
     print("Checking " + ffn)
     (car, gate) = gk.check_garage_state(ffn, False)
     self.assertTrue(gate)
     self.assertFalse(car)
Ejemplo n.º 2
0
    def __init__(self, httpport, nossl, ssl_cert, ssl_key, database, user_name,
                 player_timeout):

        self.database = database
        self.user_name = user_name
        self.httpport = httpport
        self.nossl = nossl
        self.ssl_cert = ssl_cert
        self.ssl_key = ssl_key

        try:

            flist = [self.ssl_cert, self.ssl_key]

            if self.database.startswith("sqlite:///"):

                dbpath = self.database[len("sqlite:///"):]
                dbdir = os.path.dirname(dbpath)

                flist.append(dbpath)
                flist.append(dbdir)

            sudo.drop_privileges(self.user_name, flist)

            logging.info("Dropped privileges to user '%s'" % self.user_name)

        except KeyError:

            logger.warn("User '%s' not found - not dropping privileges!" %
                        self.user_name)

        self.pm = persistence.PersistenceManager(self.database)
        self.gk = gatekeeper.GateKeeper(player_timeout)

        self.app = Flask(__name__)
        self.app.secret_key = '98s7ad=)$Djguiu87g'

        self.app.add_url_rule("/login",
                              view_func=self.login,
                              methods=['GET', 'POST'])
        self.app.add_url_rule("/logout", view_func=self.logout)
        self.app.add_url_rule("/admin",
                              view_func=self.admin,
                              methods=['GET', 'POST'])
        self.app.add_url_rule("/passwd",
                              view_func=self.passwd,
                              methods=['GET', 'POST'])
        self.app.add_url_rule("/renew", view_func=self.renew)
        self.app.add_url_rule("/", view_func=self.root)

        self.app.add_url_rule("/files/<path:path>", view_func=self.files)

        self.login_manager = flask_login.LoginManager()
        self.login_manager.init_app(self.app)

        self.login_manager.user_loader(self.user_loader)
        self.login_manager.request_loader(self.request_loader)
        self.login_manager.unauthorized_handler(self.unauthorized_handler)
Ejemplo n.º 3
0
import daemon

import gatekeeper

with daemon.DaemonContext():
    gk = gatekeeper.GateKeeper()
    gk.daemonize()