Skip to contentSkip to conversation

deal common part of etc passwd in 99base

PATCH Applied Dave Young 3 participants 10 messages Dec 26, 2011 – Jan 23, 2012 4 messages not in the archive

lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH v2 1/5 deal common part of etc passwd in 99base

ssh module will need root user in /etc/passwd, so add root and nobody to /etc/passwd in 99base instead of nfs module

---
 modules.d/95nfs/module-setup.sh  |    2 --
 modules.d/99base/module-setup.sh |    4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)
modules.d/95nfs/module-setup.sh +0 -2
index bb3b793..674a438 100755
@@ -65,8 +65,6 @@ install() {
 
     # Rather than copy the passwd file in, just set a user for rpcbind
     # We'll save the state and restart the daemon from the root anyway
-    egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
-    egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^nfsnobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
modules.d/99base/module-setup.sh +4 -0
index 5297a9d..f6c1209 100755
@@ -20,6 +20,10 @@ install() {
         dracut_install bash
         (ln -s bash "${initdir}/bin/sh" || :)
     fi
+
+    #add common users in /etc/passwd, it will be used by nfs/ssh currently
+    egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
+    egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
     # install our scripts and hooks
     inst "$moddir/init" "/init"
     inst "$moddir/initqueue" "/sbin/initqueue"
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Dave Young

ssh module will need root user in /etc/passwd, so add root and nobody to /etc/passwd in 99base instead of nfs module

Sorry, for people who don't use nfs/ssh module,
this is totally unnecessary.

And, I don't think duplicating 2 lines of code is a problem here...

author
#2 lore raw
Quoted 7 lines · Cong Wang
Quoted 3 lines · Dave Young

ssh module will need root user in /etc/passwd, so add root and nobody to /etc/passwd in 99base instead of nfs module

Sorry, for people who don't use nfs/ssh module,
this is totally unnecessary.

I dont think so, but if you insist I can add an dracut function like inst_root_user

Quoted 7 lines

And, I don't think duplicating 2 lines of code is a problem here...

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Thanks
Dave
#3 lore raw
Quoted 7 lines · Dave Young
Quoted 5 lines · Cong Wang
Quoted 3 lines · Dave Young

ssh module will need root user in /etc/passwd, so add root and nobody to /etc/passwd in 99base instead of nfs module

Quoted 7 lines
Quoted 2 lines

Sorry, for people who don't use nfs/ssh module,
this is totally unnecessary.

I dont think so, but if you insist I can add an dracut function like inst_root_user

I cooked the following patch.

The nfs module still uses "/" as home of root, while ssh module uses "/root". With you patches, you changed to "/root" for both nfs and ssh, which *maybe* a problem for nfs module since you didn't test it.

----

modules.d/95nfs/module-setup.sh +2 -2
index 6778f28..c97dea3 100755
@@ -65,8 +65,8 @@ install() {
 
     # Rather than copy the passwd file in, just set a user for rpcbind
     # We'll save the state and restart the daemon from the root anyway
-    egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
-    egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
+    egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
+    egrep -q '^nobody:' "$initdir/etc/passwd" 2>/dev/null || egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^nfsnobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
modules.d/95ssh-client/module-setup.sh +3 -0
index 0ffc298..ef8effe 100644
@@ -56,5 +56,8 @@ install() {
     inst ssh
     inst scp
     inst_sshenv
+
+    egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/root:/bin/sh' >> "$initdir/etc/passwd"
+    egrep -q '^nobody:' "$initdir/etc/passwd" 2>/dev/null || egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
 }
 
author
#5 lore raw
In reply to Cong Wang
Quoted 12 lines · Cong Wang
Quoted 11 lines · Dave Young
Quoted 7 lines · Cong Wang
Quoted 3 lines · Dave Young

ssh module will need root user in /etc/passwd, so add root and nobody to /etc/passwd in 99base instead of nfs module

Sorry, for people who don't use nfs/ssh module,
this is totally unnecessary.

Quoted 5 lines
Quoted 3 lines

I dont think so, but if you insist I can add an dracut function like inst_root_user

I cooked the following patch.

Thanks.

Quoted 4 lines

The nfs module still uses "/" as home of root, while ssh module uses "/root". With you patches, you changed to "/root" for both nfs and ssh, which *maybe* a problem for nfs module since you didn't test it.

I tested nfs boot as well, it works ok with $HOME=/root

Also if you add both ssh-client and nfs, what's the result of /etc/passwd?

Quoted 36 lines

----

modules.d/95nfs/module-setup.sh +2 -2
index 6778f28..c97dea3 100755
@@ -65,8 +65,8 @@ install() {
 
     # Rather than copy the passwd file in, just set a user for rpcbind
     # We'll save the state and restart the daemon from the root anyway
-    egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
-    egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
+    egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
+    egrep -q '^nobody:' "$initdir/etc/passwd" 2>/dev/null || egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^nfsnobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
modules.d/95ssh-client/module-setup.sh +3 -1
index 0ffc298..ef8effe 100644
@@ -56,5 +56,8 @@ install() {
     inst ssh
     inst scp
     inst_sshenv
+
+    egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/root:/bin/sh' >> "$initdir/etc/passwd"
+    egrep -q '^nobody:' "$initdir/etc/passwd" 2>/dev/null || egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
 }
 
 
--

To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Thanks
Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 7 lines · Dave Young
Quoted 3 lines · Cong Wang

The nfs module still uses "/" as home of root, while ssh module uses "/root". With you patches, you changed to "/root" for both nfs and ssh, which *maybe* a problem for nfs module since you didn't test it.

I tested nfs boot as well, it works ok with $HOME=/root

Ok, will change to "/root" too.

Quoted 2 lines

Also if you add both ssh-client and nfs, what's the result of /etc/passwd?

If the line "root:" exists before,

egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo
'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"

egrep will succeed and echo will not be executed...

A message that is not in the archive (sent off-list or not yet received): CAM_iQpX6kWGPB_mGUWOaywQgxeWEC+Og6WjOZmknS+FPGuA0xQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#9 lore raw
Quoted 12 lines · Cong Wang
Quoted 7 lines · Dave Young
Quoted 3 lines · Cong Wang

The nfs module still uses "/" as home of root, while ssh module uses "/root". With you patches, you changed to "/root" for both nfs and ssh, which *maybe* a problem for nfs module since you didn't test it.

I tested nfs boot as well, it works ok with $HOME=/root

Ok, will change to "/root" too.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Also if you add both ssh-client and nfs, what's the result of /etc/passwd?

If the line "root:" exists before,

egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo
'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"

egrep will succeed and echo will not be executed...

Yes, but who knows which module will be added firstly, maybe there's other module do this in future.

But if nfs also use /root as HOME it will be ok currently

Signature · 2 lines
Thanks
Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 21 lines · Dave Young
Quoted 19 lines · Cong Wang
Quoted 7 lines · Dave Young
Quoted 3 lines · Cong Wang

The nfs module still uses "/" as home of root, while ssh module uses "/root". With you patches, you changed to "/root" for both nfs and ssh, which *maybe* a problem for nfs module since you didn't test it.

I tested nfs boot as well, it works ok with $HOME=/root

Ok, will change to "/root" too.

Quoted 2 lines

Also if you add both ssh-client and nfs, what's the result of /etc/passwd?

If the line "root:" exists before,

 egrep -q '^root:' "$initdir/etc/passwd" 2>/dev/null || echo 'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"

Quoted 9 lines
Quoted 1 line

egrep will succeed and echo will not be executed...

Yes, but who knows which module will be added firstly, maybe there's other module do this in future.

But if nfs also use /root as HOME it will be ok currently

Yeah, it is in git now.

A message that is not in the archive (sent off-list or not yet received): 20111226062910.GA3141-4/[email protected]

#13 lore raw

Am 26.12.2011 07:29, schrieb Dave Young:

Quoted 27 lines

ssh module will need root user in /etc/passwd, so add root and nobody to /etc/passwd in 99base instead of nfs module

---
 modules.d/95nfs/module-setup.sh  |    2 --
 modules.d/99base/module-setup.sh |    4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)
modules.d/95nfs/module-setup.sh +0 -2
index bb3b793..674a438 100755
@@ -65,8 +65,6 @@ install() {
 
     # Rather than copy the passwd file in, just set a user for rpcbind
     # We'll save the state and restart the daemon from the root anyway
-    egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
-    egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^nfsnobody:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
     egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
modules.d/99base/module-setup.sh +0 -0
index 5297a9d..f6c1209 100755

modules.d/99base/module-setup.sh install() { · line 29

Quoted 10 lines
modules.d/99base/module-setup.sh +4 -0
@@ -20,6 +20,10 @@ install() {
         dracut_install bash
         (ln -s bash "${initdir}/bin/sh" || :)
     fi
+
+    #add common users in /etc/passwd, it will be used by nfs/ssh currently
+    egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
+    egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
     # install our scripts and hooks
     inst "$moddir/init" "/init"
     inst "$moddir/initqueue" "/sbin/initqueue"

pushed