Skip to content

Commit b71e78c

Browse files
committed
Add auto-login getty services and empty root password
Add getty@.service and serial-getty@.service files to enable root auto-login on tty1 and ttyS0 terminals. Configure systems to use empty root passwords by default across azl3, emt3, and elxr12 platforms. Modified imageos.go to handle empty password cases by deleting passwords when none is set. The changes allow for iso initrd automatically log in and start installer scripts. Signed-off-by: Yu, Fei <fei.yu@intel.com>
1 parent 44e6bf9 commit b71e78c

10 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --noclear --autologin root --keep-baud %I $TERM
4+
5+
# Default to tty1 but allow other choices
6+
[Install]
7+
Alias=getty.target.wants/getty@tty1.service
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --noclear --autologin root --keep-baud %I $TERM
4+
5+
# Default to ttyS0 but allow other choices
6+
[Install]
7+
Alias=getty.target.wants/serial-getty@ttyS0.service

config/osv/azure-linux/azl3/imageconfigs/defaultconfigs/default-initrd-x86_64.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ systemConfig:
8888
additionalFiles:
8989
- local: ../additionalfiles/99-dhcp-en.network
9090
final: /etc/systemd/network/99-dhcp-en.network
91+
- local: ../additionalfiles/getty@.service
92+
final: /usr/lib/systemd/system/getty@.service
93+
- local: ../additionalfiles/serial-getty@.service
94+
final: /usr/lib/systemd/system/serial-getty@.service
95+
96+
users:
97+
- name: root
98+
passwordMaxAge: 99999
99+
password: ""
91100

92101
kernel:
93102
name: kernel
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --noclear --autologin root --keep-baud %I $TERM
4+
5+
# Default to tty1 but allow other choices
6+
[Install]
7+
Alias=getty.target.wants/getty@tty1.service
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --noclear --autologin root --keep-baud %I $TERM
4+
5+
# Default to ttyS0 but allow other choices
6+
[Install]
7+
Alias=getty.target.wants/serial-getty@ttyS0.service

config/osv/edge-microvisor-toolkit/emt3/imageconfigs/defaultconfigs/default-initrd-x86_64.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ systemConfig:
8888
additionalFiles:
8989
- local: ../additionalfiles/99-dhcp-en.network
9090
final: /etc/systemd/network/99-dhcp-en.network
91+
- local: ../additionalfiles/getty@.service
92+
final: /usr/lib/systemd/system/getty@.service
93+
- local: ../additionalfiles/serial-getty@.service
94+
final: /usr/lib/systemd/system/serial-getty@.service
95+
96+
users:
97+
- name: root
98+
passwordMaxAge: 99999
99+
password: ""
91100

92101
kernel:
93102
name: kernel
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --noclear --autologin root --keep-baud %I $TERM
4+
5+
# Default to tty1 but allow other choices
6+
[Install]
7+
Alias=getty.target.wants/getty@tty1.service
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --noclear --autologin root --keep-baud %I $TERM
4+
5+
# Default to ttyS0 but allow other choices
6+
[Install]
7+
Alias=getty.target.wants/serial-getty@ttyS0.service

config/osv/wind-river-elxr/elxr12/imageconfigs/defaultconfigs/default-initrd-x86_64.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ systemConfig:
4444
final: /etc/systemd/network/dhcp.network
4545
- local: ../additionalfiles/elxr-aria.list
4646
final: /etc/apt/sources.list.d/elxr-aria.list
47+
- local: ../additionalfiles/getty@.service
48+
final: /usr/lib/systemd/system/getty@.service
49+
- local: ../additionalfiles/serial-getty@.service
50+
final: /usr/lib/systemd/system/serial-getty@.service
51+
52+
users:
53+
- name: root
54+
passwordMaxAge: 99999
55+
password: ""
4756

4857
kernel:
4958
name: kernel

internal/image/imageos/imageos.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,13 @@ func createUser(installRoot string, template *config.ImageTemplate) error {
11991199
if err := setUserPassword(installRoot, user); err != nil {
12001200
return fmt.Errorf("failed to set password for user %s: %w", user.Name, err)
12011201
}
1202+
} else {
1203+
cmd := fmt.Sprintf("passwd -d %s", user.Name)
1204+
if _, err := shell.ExecCmd(cmd, true, installRoot, nil); err != nil {
1205+
log.Errorf("Failed to delete password for user %s: %v", user.Name, err)
1206+
return fmt.Errorf("failed to delete password for user %s: %w", user.Name, err)
1207+
}
1208+
log.Debugf("Deleted password for user %s (no password set)", user.Name)
12021209
}
12031210

12041211
// Add user to groups if specified, filtering out template placeholders

0 commit comments

Comments
 (0)