Skip to contentSkip to conversation

rootfs-postcommands.bbclass: Print a warning when login with root is disabled

PATCH In review Robert Yang 2 participants 7 messages Mar 5, 2021 – Mar 15, 2021

lore
Share & tools
lore
#0 lore raw

cover rootfs-postcommands.bbclass: Print a warning when login with root is disabled

The following changes since commit 6db24928d62aeb093a0e6da6619713eaca57a96f:

recipes-support: Add missing HOMEPAGE and DESCRIPTION for recipes (2021-03-02 20:35:08 +0000)

are available in the Git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/root
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/root

Robert Yang (1):
rootfs-postcommands.bbclass: Print a warning when login with root is
disabled

 meta/classes/rootfs-postcommands.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Fixed:
EXTRA_IMAGE_FEATURES_remove = "debug-tweaks"

$ bitbake core-image-minimal

Then we can't login to the system with root without any messages. Add a warning makes it easy to debug.

---
 meta/classes/rootfs-postcommands.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/rootfs-postcommands.bbclass +5 -1
index 1f27a3d07a..e4fe416ac9 100644
@@ -147,7 +147,11 @@ read_only_rootfs_hook () {
 zap_empty_root_password () {
 	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
 		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
-        fi
+		grep -q '^root:*:' ${IMAGE_ROOTFS}/etc/shadow
+		if [ $? -eq 0 ]; then
+			bbwarn "Login with root user is disabled since zap_empty_root_password is enabled"
+		fi
+	fi
 	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
 		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
 	fi
Signature · 1 line
2.17.1
#2 lore raw
Quoted 24 lines

-----Original Message-----
From: [email protected] <openembedded-
[email protected]> On Behalf Of Robert Yang
Sent: den 5 mars 2021 09:49
To: [email protected]
Subject: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Fixed:
EXTRA_IMAGE_FEATURES_remove = "debug-tweaks"

$ bitbake core-image-minimal

Then we can't login to the system with root without any messages. Add a warning makes it easy to debug.

---
 meta/classes/rootfs-postcommands.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/rootfs-postcommands.bbclass +0 -0
index 1f27a3d07a..e4fe416ac9 100644

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 150

Quoted 5 lines
meta/classes/rootfs-postcommands.bbclass +1 -1
@@ -147,7 +147,11 @@ read_only_rootfs_hook () {
 zap_empty_root_password () {
 	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
 		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
-        fi
+		grep -q '^root:*:' ${IMAGE_ROOTFS}/etc/shadow

That will match any /etc/shadow file with "root:" in it. Change it to:

		grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

And make this optional. We intentionally do not have a root password set in our products when they are delivered due to the state law (SB-327) that went into effect on January 1, 2020 in California, which prohibits default passwords to be used in IoT products.

Quoted 9 lines
meta/classes/rootfs-postcommands.bbclass +4 -1
+		if [ $? -eq 0 ]; then
+			bbwarn "Login with root user is disabled since zap_empty_root_password is enabled"
+		fi
+	fi
 	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
 		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
 	fi
--

2.17.1

//Peter

#3 lore raw

Hi Peter,

Quoted 32 lines · Peter Kjellerstedt
Quoted 24 lines

-----Original Message-----
From: [email protected] <openembedded-
[email protected]> On Behalf Of Robert Yang
Sent: den 5 mars 2021 09:49
To: [email protected]
Subject: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Fixed:
EXTRA_IMAGE_FEATURES_remove = "debug-tweaks"

$ bitbake core-image-minimal

Then we can't login to the system with root without any messages. Add a warning makes it easy to debug.

---
  meta/classes/rootfs-postcommands.bbclass | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/rootfs-postcommands.bbclass +0 -0
index 1f27a3d07a..e4fe416ac9 100644

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 150

Quoted 5 lines
meta/classes/rootfs-postcommands.bbclass +1 -1
@@ -147,7 +147,11 @@ read_only_rootfs_hook () {
  zap_empty_root_password () {
  	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
  		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
-        fi
+		grep -q '^root:*:' ${IMAGE_ROOTFS}/etc/shadow

That will match any /etc/shadow file with "root:" in it. Change it to:

Quoted 1 line
		grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Thanks, I will update it.

Quoted 2 lines

And make this optional. We intentionally do not have a root password set in our

I don't quite understand about "optional", when the command is:

grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Then empty root password in shadow is:
root::

so empty root password won't be matched?

// Robert

Quoted 16 lines

products when they are delivered due to the state law (SB-327) that went into effect on January 1, 2020 in California, which prohibits default passwords to be used in IoT products.

Quoted 9 lines
meta/classes/rootfs-postcommands.bbclass +4 -1
+		if [ $? -eq 0 ]; then
+			bbwarn "Login with root user is disabled since zap_empty_root_password is enabled"
+		fi
+	fi
  	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
  		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
  	fi
--

2.17.1

//Peter

#4 lore raw
Quoted 55 lines

-----Original Message-----
From: Robert Yang <[email protected]>
Sent: den 9 mars 2021 09:32
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Hi Peter,

Quoted 6 lines · Peter Kjellerstedt
Quoted 6 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Robert Yang
Sent: den 5 mars 2021 09:49
To: [email protected]
Subject: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a

warning when login with root is disabled

Quoted 6 lines
Quoted 6 lines

Fixed:
EXTRA_IMAGE_FEATURES_remove = "debug-tweaks"

$ bitbake core-image-minimal

Then we can't login to the system with root without any messages. Add a

warning

Quoted 8 lines

Review

Quoted 8 lines

makes it easy to debug.

---
  meta/classes/rootfs-postcommands.bbclass | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes/rootfs-postcommands.bbclass

Quoted 7 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 149

Quoted 7 lines

index 1f27a3d07a..e4fe416ac9 100644

meta/classes/rootfs-postcommands.bbclass +0 -0
@@ -147,7 +147,11 @@ read_only_rootfs_hook () {
  zap_empty_root_password () {
  	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
  		sed -i 's%^root::%root:*:%'

${IMAGE_ROOTFS}/etc/shadow

Quoted 6 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 150

Quoted 2 lines
meta/classes/rootfs-postcommands.bbclass +1 -1
-        fi
+		grep -q '^root:*:' ${IMAGE_ROOTFS}/etc/shadow

That will match any /etc/shadow file with "root:" in it. Change it to:

		grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Thanks, I will update it.

Quoted 2 lines

And make this optional. We intentionally do not have a root password set

in our

Quoted 8 lines

I don't quite understand about "optional", when the command is:

grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Then empty root password in shadow is:
root::

so empty root password won't be matched?

Sorry, I was unclear. We do not have an empty password, we have "root:*:..." in /etc/shadow, and we obviously do not want this warning.

Quoted 1 line

// Robert

//Peter

Quoted 20 lines
Quoted 1 line

products when they are delivered due to the state law (SB-327) that went

into

Quoted 1 line

effect on January 1, 2020 in California, which prohibits default

passwords to

Quoted 4 lines

be used in IoT products.

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 152

Quoted 2 lines
meta/classes/rootfs-postcommands.bbclass +2 -0
+		if [ $? -eq 0 ]; then
+			bbwarn "Login with root user is disabled

since zap_empty_root_password is enabled"

Quoted 4 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () {

Quoted 4 lines
meta/classes/rootfs-postcommands.bbclass +2 -0
+		fi
+	fi
  	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
  		sed -i 's%^root::%root:*:%'

${IMAGE_ROOTFS}/etc/passwd

Quoted 6 lines
Quoted 3 lines
meta/classes/rootfs-postcommands.bbclass +0 -1
  	fi
--

2.17.1

//Peter

#5 lore raw
Quoted 59 lines · Peter Kjellerstedt
Quoted 59 lines

-----Original Message-----
From: Robert Yang <[email protected]>
Sent: den 9 mars 2021 09:32
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Hi Peter,

Quoted 6 lines · Peter Kjellerstedt
Quoted 6 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Robert Yang
Sent: den 5 mars 2021 09:49
To: [email protected]
Subject: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a

warning when login with root is disabled

Quoted 6 lines
Quoted 6 lines

Fixed:
EXTRA_IMAGE_FEATURES_remove = "debug-tweaks"

$ bitbake core-image-minimal

Then we can't login to the system with root without any messages. Add a

warning

Quoted 8 lines

Review

Quoted 8 lines

makes it easy to debug.

---
   meta/classes/rootfs-postcommands.bbclass | 6 +++++-
   1 file changed, 5 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes/rootfs-postcommands.bbclass

Quoted 7 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 149

Quoted 7 lines

index 1f27a3d07a..e4fe416ac9 100644

meta/classes/rootfs-postcommands.bbclass +0 -0
@@ -147,7 +147,11 @@ read_only_rootfs_hook () {
   zap_empty_root_password () {
   	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
   		sed -i 's%^root::%root:*:%'

${IMAGE_ROOTFS}/etc/shadow

Quoted 6 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 150

Quoted 2 lines
meta/classes/rootfs-postcommands.bbclass +1 -1
-        fi
+		grep -q '^root:*:' ${IMAGE_ROOTFS}/etc/shadow

That will match any /etc/shadow file with "root:" in it. Change it to:

		grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Thanks, I will update it.

Quoted 2 lines

And make this optional. We intentionally do not have a root password set

in our

I don't quite understand about "optional", when the command is:

grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Quoted 7 lines
Quoted 4 lines

Then empty root password in shadow is:
root::

so empty root password won't be matched?

Sorry, I was unclear. We do not have an empty password, we have "root:*:..." in /etc/shadow, and we obviously do not want this warning.

Thanks, makes sense, then let's drop this patch, this patch is for debugging only, it doesn't matter to drop it.

I wonder how to login when the line is "root:*:..." in /etc/shadow?

// Robert

Quoted 25 lines
Quoted 2 lines

// Robert

//Peter

Quoted 20 lines
Quoted 1 line

products when they are delivered due to the state law (SB-327) that went

into

Quoted 1 line

effect on January 1, 2020 in California, which prohibits default

passwords to

Quoted 4 lines

be used in IoT products.

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 152

Quoted 2 lines
meta/classes/rootfs-postcommands.bbclass +2 -0
+		if [ $? -eq 0 ]; then
+			bbwarn "Login with root user is disabled

since zap_empty_root_password is enabled"

Quoted 4 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () {

Quoted 4 lines
meta/classes/rootfs-postcommands.bbclass +2 -0
+		fi
+	fi
   	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
   		sed -i 's%^root::%root:*:%'

${IMAGE_ROOTFS}/etc/passwd

Quoted 6 lines
Quoted 3 lines
meta/classes/rootfs-postcommands.bbclass +0 -1
   	fi
--

2.17.1

//Peter

#6 lore raw
Quoted 71 lines

-----Original Message-----
From: Robert Yang <[email protected]>
Sent: den 15 mars 2021 03:32
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Quoted 62 lines · Peter Kjellerstedt
Quoted 61 lines

-----Original Message-----
From: Robert Yang <[email protected]>
Sent: den 9 mars 2021 09:32
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a warning when login with root is disabled

Hi Peter,

Quoted 6 lines · Peter Kjellerstedt
Quoted 6 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Robert Yang
Sent: den 5 mars 2021 09:49
To: [email protected]
Subject: [OE-core] [PATCH 1/1] rootfs-postcommands.bbclass: Print a

warning when login with root is disabled

Quoted 8 lines
Quoted 8 lines

Fixed:
EXTRA_IMAGE_FEATURES_remove = "debug-tweaks"

$ bitbake core-image-minimal

Then we can't login to the system with root without any messages. Add a warning makes it easy to debug.

Quoted 6 lines

Review

Quoted 6 lines
---
   meta/classes/rootfs-postcommands.bbclass | 6 +++++-
   1 file changed, 5 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes/rootfs-postcommands.bbclass

Quoted 12 lines

meta/classes/rootfs-postcommands.bbclass read_only_rootfs_hook () { · line 150

Quoted 9 lines

index 1f27a3d07a..e4fe416ac9 100644

meta/classes/rootfs-postcommands.bbclass +1 -1
@@ -147,7 +147,11 @@ read_only_rootfs_hook () {
   zap_empty_root_password () {
   	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
   		sed -i 's%^root::%root:*:%' >> ${IMAGE_ROOTFS}/etc/shadow
-        fi
+		grep -q '^root:*:' ${IMAGE_ROOTFS}/etc/shadow

That will match any /etc/shadow file with "root:" in it. Change it to:

Quoted 1 line
		grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Thanks, I will update it.

Quoted 3 lines

And make this optional. We intentionally do not have a root password set in our

I don't quite understand about "optional", when the command is:

grep -q '^root:\*:' ${IMAGE_ROOTFS}/etc/shadow

Then empty root password in shadow is:
root::

so empty root password won't be matched?

Quoted 7 lines
Quoted 2 lines

Sorry, I was unclear. We do not have an empty password, we have "root:*:..." in /etc/shadow, and we obviously do not want this warning.

Thanks, makes sense, then let's drop this patch, this patch is for debugging only, it doesn't matter to drop it.

I wonder how to login when the line is "root:*:..." in /etc/shadow?

In our case, you have to set a password the first time you access the product's web page.

Quoted 22 lines

// Robert

Quoted 20 lines
Quoted 2 lines

// Robert

//Peter

Quoted 15 lines
Quoted 15 lines

products when they are delivered due to the state law (SB-327) that went into effect on January 1, 2020 in California, which prohibits default passwords to be used in IoT products.

Quoted 9 lines
meta/classes/rootfs-postcommands.bbclass +4 -1
+		if [ $? -eq 0 ]; then
+			bbwarn "Login with root user is disabled since zap_empty_root_password is enabled"
+		fi
+	fi
   	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
   		sed -i 's%^root::%root:*:%' >> ${IMAGE_ROOTFS}/etc/passwd
   	fi
--

2.17.1

//Peter

//Peter