Skip to contentSkip to conversation

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

PATCH New Ming Liu 1 participant 3 messages Oct 22, 2013

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH v5 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 ------
 meta/recipes-core/base-files/base-files_3.0.14.bb | 2 +-
 2 files changed, 1 insertion(+), 7 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
meta/recipes-core/base-files/base-files_3.0.14.bb +1 -1
index 054fefa..be3921a 100644
@@ -143,5 +143,5 @@ FILES_${PN}-doc = "${docdir} ${datadir}/common-licenses"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname'][(d.getVar('hostname', True) != '')]}"
+CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname'][(d.getVar('hostname', True) != '')]} ${sysconfdir}/shells"
 
Signature · 1 line
1.8.4.1
author
#1 lore raw

PATCH v5 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 v5 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