debugd: Allow root login on serial console when using debug image (#407)

This commit is contained in:
Malte Poll 2022-08-26 14:07:53 +02:00 committed by GitHub
parent a796c7ee69
commit f5270c6c01
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,18 @@
package deploy
import (
"context"
"fmt"
"os/exec"
)
// DeleteUserPassword sets the user's password to an empty string
// effectively allowing anyone with access to the serial console to log in.
func DeleteUserPassword(ctx context.Context, user string) error {
cmd := exec.CommandContext(ctx, "passwd", "-d", user)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("deleting user password: %q %w", output, err)
}
return nil
}