The as_root checkbox now changes the command it produces
as_root selects which paths the rendered script writes to: /opt/umbra and /etc/umbra/node.json, or the invoking user's own directories. The command did not follow it. Ticking the box produced a script that wanted to write to /etc while being run by an unprivileged shell, which fails at the first mkdir - after the pairing code has already been spent, so it also leaves the operator with a dead code and nothing to show for it. The command now carries sudo when the box is ticked. The script still checks for root at run time and takes whichever branch is actually available, so this is belt and braces rather than the mechanism; but a control that produces a command which cannot work is worse than no control at all. The checkbox's help text described it as a hint whose effect was decided at run time, which was true and misleading: the effect is decided here, at render time.
This commit is contained in:
@@ -912,9 +912,18 @@ def create_bootstrap(
|
||||
script=script,
|
||||
# The one line a person pastes. Built here rather than in the browser so the
|
||||
# console and a shell user get the same command.
|
||||
# The command follows `as_root`, and this was a real defect.
|
||||
#
|
||||
# `as_root` chooses which paths the script renders: /opt/umbra and
|
||||
# /etc/umbra/node.json, or the user's own directories. The command did not follow
|
||||
# it, so ticking the box produced a script that wanted to write to /etc while
|
||||
# being run by an unprivileged shell - which fails at the first mkdir, after the
|
||||
# pairing code has already been spent. A checkbox that produces a command which
|
||||
# cannot work is worse than no checkbox.
|
||||
command=(
|
||||
f"curl -fsSL {controller}/api/node/bootstrap | sh"
|
||||
f"\n# then enter the code when asked: {minted['code']}"
|
||||
f"curl -fsSL {controller}/api/node/bootstrap | "
|
||||
+ ("sudo sh" if payload.as_root else "sh")
|
||||
+ f"\n# then enter the code when asked: {minted['code']}"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user