pmbootstrap init: don't allow 'root' as username
While going over the wiki pages recently, I've noticed that somebody added a note to not use "root" as username. I don't think many people will attempt to do this, but let's catch it here in pmbootstrap with a friendly message instead of mentioning it in the wiki. Reviewed-by: Luca Weiss <luca@z3ntu.xyz> Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230126071154.1689-1-ollieparanoid@postmarketos.org%3E
This commit is contained in:
parent
e8a2ab2e98
commit
98290f9191
|
@ -33,6 +33,23 @@ def require_programs():
|
||||||
f" {', '.join(missing)}")
|
f" {', '.join(missing)}")
|
||||||
|
|
||||||
|
|
||||||
|
def ask_for_username(args):
|
||||||
|
"""
|
||||||
|
Ask for a reasonable username for the non-root user.
|
||||||
|
|
||||||
|
:returns: the username
|
||||||
|
"""
|
||||||
|
while True:
|
||||||
|
ret = pmb.helpers.cli.ask("Username", None, args.user, False,
|
||||||
|
"[a-z_][a-z0-9_-]*")
|
||||||
|
if ret == "root":
|
||||||
|
logging.fatal("ERROR: don't put \"root\" here. This is about"
|
||||||
|
" creating an additional non-root user. Don't worry,"
|
||||||
|
" the root user will also be created ;)")
|
||||||
|
continue
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def ask_for_work_path(args):
|
def ask_for_work_path(args):
|
||||||
"""
|
"""
|
||||||
Ask for the work path, until we can create it (when it does not exist) and
|
Ask for the work path, until we can create it (when it does not exist) and
|
||||||
|
@ -653,11 +670,7 @@ def frontend(args):
|
||||||
if device_exists:
|
if device_exists:
|
||||||
cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, info)
|
cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, info)
|
||||||
|
|
||||||
# Username
|
cfg["pmbootstrap"]["user"] = ask_for_username(args)
|
||||||
cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask("Username", None,
|
|
||||||
args.user, False,
|
|
||||||
"[a-z_][a-z0-9_-]*")
|
|
||||||
|
|
||||||
ask_for_provider_select_pkg(args, "postmarketos-base", cfg["providers"])
|
ask_for_provider_select_pkg(args, "postmarketos-base", cfg["providers"])
|
||||||
|
|
||||||
# UI and various build options
|
# UI and various build options
|
||||||
|
|
Loading…
Reference in New Issue