Skip to contentSkip to conversation

base-files: remove invalid entries from /etc/shells

PATCH Superseded Ming Liu 2 participants 5 messages Oct 20, 2013 – Oct 22, 2013

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH v4 1/3 base-files: remove invalid entries from /etc/shells

It's more reasonable and secure to keep /etc/shells a minimal file, and then entries for valid shells be added dynamically to the system, only if the packages that provide them are supported.

---
 meta/recipes-core/base-files/base-files/shells | 6 ------
 1 file changed, 6 deletions(-)
meta/recipes-core/base-files/base-files/shells +0 -6
index ce39b3d..3f63987 100644
@@ -1,8 +1,2 @@
 # /etc/shells: valid login shells
 /bin/sh
-/bin/ash
-/bin/bash
-/bin/dash
-/bin/ksh
-/usr/bin/ksh
-/usr/bin/screen
Signature · 1 line
1.8.4.1
author
#1 lore raw

PATCH v4 2/3 bash: dynamically add or remove a entry to/from /etc/shells

1 Add base-files to RDEPENDS.
2 Use ${base_bindir} in regex to match bash path.
3 Add pkg_postrm to remove the entry from /etc/shells that added by pkg_postinst.

---
 meta/recipes-extended/bash/bash.inc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
meta/recipes-extended/bash/bash.inc +7 -3
index 64b476f..99875bf 100644
@@ -17,6 +17,8 @@ ALTERNATIVE_PRIORITY = "100"
 
 export AUTOHEADER = "true"
 
+RDEPENDS_${PN} += "base-files"
+RDEPENDS_${PN}_class-nativesdk = ""
 RDEPENDS_${PN}-ptest += "make"
 
 do_configure_prepend () {
@@ -44,7 +46,9 @@ do_install_ptest () {
 }
 
 pkg_postinst_${PN} () {
-	touch $D${sysconfdir}/shells
-	grep -q "bin/bash" $D${sysconfdir}/shells || echo /bin/bash >> $D${sysconfdir}/shells
-	grep -q "bin/sh" $D${sysconfdir}/shells || echo /bin/sh >> $D${sysconfdir}/shells
+	grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
+}
+
+pkg_postrm_${PN} () {
+	printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
 }
Signature · 1 line
1.8.4.1
author
#2 lore raw

PATCH v4 3/3 screen: dynamically add or remove a entry to/from /etc/shells

In reply to Ming Liu

1 Add base-files to RDEPENDS.
2 Add pkg_postinst and pkg_postrm to add and remove a entry in /etc/shells.

---
 meta/recipes-extended/screen/screen_4.0.3.bb | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/recipes-extended/screen/screen_4.0.3.bb +10 -0
index 1a7eb20..be42fb9 100644
@@ -12,6 +12,8 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0774d66808b0f602e94448108f59448b \
 SECTION = "console/utils"
 DEPENDS = "ncurses \
           ${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
+RDEPENDS_${PN} = "base-files"
+
 PR = "r3"
 
 SRC_URI = "${GNU_MIRROR}/screen/screen-${PV}.tar.gz;name=tarball \
@@ -41,3 +43,11 @@ do_install_append () {
 		fi
 	done
 }
+
+pkg_postinst_${PN} () {
+	grep -q "^${bindir}/screen$" $D${sysconfdir}/shells || echo ${bindir}/screen >> $D${sysconfdir}/shells
+}
+
+pkg_postrm_${PN} () {
+	printf "$(grep -v "^${bindir}/screen$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
+}
Signature · 1 line
1.8.4.1
#3 lore raw

Re: [PATCH V4 3/3] screen: dynamically add or remove a entry to/from /etc/shells

Quoted 4 lines · Ming Liu

1 Add base-files to RDEPENDS.
2 Add pkg_postinst and pkg_postrm to add and remove a entry in /etc/shells.

will it affect upgradability of the package which is providing /etc/shells ?

Review

Quoted 6 lines
---
 meta/recipes-extended/screen/screen_4.0.3.bb | 10 ++++++++++
 1 file changed, 10 insertions(+)
(quoted diff) +0 -0

screen_4.0.3.bb

meta/recipes-extended/screen/screen_4.0.3.bb LIC_FILES_CHKSUM =

Quoted 4 lines

index 1a7eb20..be42fb9 100644

meta/recipes-extended/screen/screen_4.0.3.bb +0 -0
@@ -12,6 +12,8 @@ LIC_FILES_CHKSUM =

"file://COPYING;md5=0774d66808b0f602e94448108f59448b \

Quoted 9 lines
meta/recipes-extended/screen/screen_4.0.3.bb +2 -0
 SECTION = "console/utils"
 DEPENDS = "ncurses \
           ${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
+RDEPENDS_${PN} = "base-files"
+
 PR = "r3"
 
 SRC_URI = "${GNU_MIRROR}/screen/screen-${PV}.tar.gz;name=tarball \

meta/recipes-extended/screen/screen_4.0.3.bb do_install_append () { · line 48

Quoted 6 lines
meta/recipes-extended/screen/screen_4.0.3.bb +3 -0
@@ -41,3 +43,11 @@ do_install_append () {
                fi
        done
 }
+
+pkg_postinst_${PN} () {
+       grep -q "^${bindir}/screen$" $D${sysconfdir}/shells || echo

${bindir}/screen >> $D${sysconfdir}/shells

Quoted 14 lines
meta/recipes-extended/screen/screen_4.0.3.bb +4 -0
+}
+
+pkg_postrm_${PN} () {
+       printf "$(grep -v "^${bindir}/screen$" $D${sysconfdir}/shells)\n"

$D${sysconfdir}/shells
+}
--
1.8.4.1

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#4 lore raw

Re: [PATCH V4 3/3] screen: dynamically add or remove a entry to/from /etc/shells

Quoted 9 lines · Khem Raj
Quoted 4 lines · On Sunday, October 20, 2013, Ming Liu <[email protected]…

1 Add base-files to RDEPENDS.
2 Add pkg_postinst and pkg_postrm to add and remove a entry in /etc/shells.

will it affect upgradability of the package which is providing /etc/shells ?

Yes, you are right, it will. So we need put /etc/shells to CONFFILES in base-files package.

//Ming Liu

Quoted 48 lines
Quoted 2 lines

<mailto:[email protected]>>

Quoted 2 lines

---
meta/recipes-extended/screen/screen_4.0.3.bb

<http://screen_4.0.3.bb> | 10 ++++++++++

Review

Quoted 3 lines
 1 file changed, 10 insertions(+)
(quoted diff) +0 -0

<http://screen_4.0.3.bb> b/meta/recipes-extended/screen/screen_4.0.3.bb <http://screen_4.0.3.bb>

Quoted 2 lines

index 1a7eb20..be42fb9 100644
--- a/meta/recipes-extended/screen/screen_4.0.3.bb

<http://screen_4.0.3.bb>

Quoted 1 line

+++ b/meta/recipes-extended/screen/screen_4.0.3.bb

<http://screen_4.0.3.bb>

Review LIC_FILES_CHKSUM =

Quoted 1 line
(quoted diff) +0 -0
@@ -12,6 +12,8 @@ LIC_FILES_CHKSUM = 

"file://COPYING;md5=0774d66808b0f602e94448108f59448b \

Quoted 9 lines
meta/recipes-extended/screen/screen_4.0.3.bb +2 -0
 SECTION = "console/utils"
 DEPENDS = "ncurses \
           ${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
+RDEPENDS_${PN} = "base-files"
+
 PR = "r3"
 
 SRC_URI = "${GNU_MIRROR}/screen/screen-${PV}.tar.gz;name=tarball \

meta/recipes-extended/screen/screen_4.0.3.bb do_install_append () { · line 48

Quoted 6 lines
meta/recipes-extended/screen/screen_4.0.3.bb +3 -0
@@ -41,3 +43,11 @@ do_install_append () {
                fi
        done
 }
+
+pkg_postinst_${PN} () {
+       grep -q "^${bindir}/screen$" $D${sysconfdir}/shells || echo 

${bindir}/screen >> $D${sysconfdir}/shells

meta/recipes-extended/screen/screen_4.0.3.bb do_install_append () {

Quoted 4 lines
meta/recipes-extended/screen/screen_4.0.3.bb +4 -0
+}
+
+pkg_postrm_${PN} () {
+       printf "$(grep -v "^${bindir}/screen$" 

$D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells

Quoted 7 lines
(quoted diff) +1 -1
+}
--

1.8.4.1

_______________________________________________
Openembedded-core mailing list
[email protected]

<mailto:[email protected]>

Quoted 2 lines

http://lists.openembedded.org/mailman/listinfo/openembedded-core