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

@ -43,6 +43,10 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if err := deploy.DeleteUserPassword(ctx, "root"); err != nil {
log.Errorf("root login: %w")
}
download := deploy.New(log.Named("download"), &net.Dialer{}, serviceManager, streamer)
var fetcher metadata.Fetcher
csp := os.Getenv("CONSTEL_CSP")

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
}