mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-25 08:43:36 +00:00
Check user db permissions when we redirect to firstboot, instead of trying to check if the file exists.
This commit is contained in:
parent
3f36781fdf
commit
a7decf383e
14
plinth.py
14
plinth.py
@ -57,6 +57,9 @@ class Root(plugin_mount.PagePlugin):
|
||||
## TODO: firstboot hijacking root should probably be in the firstboot module with a hook in plinth.py
|
||||
with sqlite_db(cfg.store_file, table="firstboot") as db:
|
||||
if not 'state' in db:
|
||||
# if we created a new user db, make sure it can't be read by everyone
|
||||
userdb_fname = '{}.sqlite3'.format(cfg.user_db)
|
||||
os.chmod(userdb_fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
|
||||
raise cherrypy.InternalRedirect('firstboot')
|
||||
elif db['state'] < 5:
|
||||
cfg.log("First Boot state = %d" % db['state'])
|
||||
@ -136,18 +139,7 @@ def setup():
|
||||
load_modules()
|
||||
cfg.html_root = Root()
|
||||
|
||||
# check if we are creating a new user db
|
||||
userdb_fname = '{}.sqlite3'.format(cfg.user_db)
|
||||
try:
|
||||
with open(userdb_fname):
|
||||
userdb_exists = True
|
||||
except IOError:
|
||||
userdb_exists = False
|
||||
cfg.users = plugin_mount.UserStoreModule.get_plugins()[0]
|
||||
# if we created a new user db, make sure it can't be read by everyone
|
||||
if not userdb_exists:
|
||||
os.chmod(userdb_fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
|
||||
|
||||
cfg.page_plugins = plugin_mount.PagePlugin.get_plugins()
|
||||
cfg.log("Loaded %d page plugins" % len(cfg.page_plugins))
|
||||
cfg.forms = plugin_mount.FormPlugin.get_plugins()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user