sys-apps/shadow: apply CoreOS changes

This just copies most of the previous ebuild's changes.  It drops
a bunch of redundant symlinks in /etc since tmpfiles creates them,
and it drops a passwd move out of /usr since our bindirs are linked
into /usr.
This commit is contained in:
David Michael 2017-06-16 14:32:21 -07:00
parent e167a8d75a
commit ae4f74c1af

View File

@ -3,7 +3,7 @@
EAPI="5" EAPI="5"
inherit eutils libtool pam multilib inherit eutils libtool pam multilib systemd
DESCRIPTION="Utilities to deal with user accounts" DESCRIPTION="Utilities to deal with user accounts"
HOMEPAGE="https://github.com/shadow-maint/shadow http://pkg-shadow.alioth.debian.org/" HOMEPAGE="https://github.com/shadow-maint/shadow http://pkg-shadow.alioth.debian.org/"
@ -11,7 +11,7 @@ SRC_URI="https://github.com/shadow-maint/shadow/releases/download/${PV}/${P}.tar
LICENSE="BSD GPL-2" LICENSE="BSD GPL-2"
SLOT="0" SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
IUSE="acl audit cracklib nls pam selinux skey xattr" IUSE="acl audit cracklib nls pam selinux skey xattr"
# Taken from the man/Makefile.am file. # Taken from the man/Makefile.am file.
LANGS=( cs da de es fi fr hu id it ja ko pl pt_BR ru sv tr zh_CN zh_TW ) LANGS=( cs da de es fi fr hu id it ja ko pl pt_BR ru sv tr zh_CN zh_TW )
@ -77,14 +77,14 @@ set_login_opt() {
comment="#" comment="#"
sed -i \ sed -i \
-e "/^${opt}\>/s:^:#:" \ -e "/^${opt}\>/s:^:#:" \
"${ED}"/etc/login.defs || die "${ED}"/usr/share/shadow/login.defs || die
else else
sed -i -r \ sed -i -r \
-e "/^#?${opt}\>/s:.*:${opt} ${val}:" \ -e "/^#?${opt}\>/s:.*:${opt} ${val}:" \
"${ED}"/etc/login.defs "${ED}"/usr/share/shadow/login.defs
fi fi
local res=$(grep "^${comment}${opt}\>" "${ED}"/etc/login.defs) local res=$(grep "^${comment}${opt}\>" "${ED}"/usr/share/shadow/login.defs)
einfo "${res:-Unable to find ${opt} in /etc/login.defs}" einfo "${res:-Unable to find ${opt} in /usr/share/shadow/login.defs}"
} }
src_install() { src_install() {
@ -97,23 +97,39 @@ src_install() {
# remove it. # remove it.
rm -f "${ED}"/{,usr/}$(get_libdir)/lib{misc,shadow}.{a,la} rm -f "${ED}"/{,usr/}$(get_libdir)/lib{misc,shadow}.{a,la}
insinto /etc # Remove files from /etc, they will be symlinks to /usr instead.
rm -f "${ED}"/etc/{limits,login.access,login.defs,securetty,default/useradd}
# CoreOS: break shadow.conf into two files so that we only have to apply
# etc-shadow.conf in the initrd.
systemd_dotmpfilesd "${FILESDIR}"/tmpfiles.d/etc-shadow.conf
systemd_dotmpfilesd "${FILESDIR}"/tmpfiles.d/var-shadow.conf
insinto /usr/share/shadow
# Using a securetty with devfs device names added
# (compat names kept for non-devfs compatibility)
insopts -m0600 ; doins "${FILESDIR}"/securetty
if ! use pam ; then if ! use pam ; then
insopts -m0600 insopts -m0600
doins etc/login.access etc/limits doins etc/login.access etc/limits
fi fi
# Output arch-specific cruft
local devs
case $(tc-arch) in
ppc*) devs="hvc0 hvsi0 ttyPSC0";;
hppa) devs="ttyB0";;
arm) devs="ttyFB0 ttySAC0 ttySAC1 ttySAC2 ttySAC3 ttymxc0 ttymxc1 ttymxc2 ttymxc3 ttyO0 ttyO1 ttyO2";;
sh) devs="ttySC0 ttySC1";;
amd64|x86) devs="hvc0";;
esac
if [[ -n ${devs} ]]; then
printf '%s\n' ${devs} >> "${ED}"/usr/share/shadow/securetty
fi
# needed for 'useradd -D' # needed for 'useradd -D'
insinto /etc/default
insopts -m0600 insopts -m0600
doins "${FILESDIR}"/default/useradd doins "${FILESDIR}"/default/useradd
# move passwd to / to help recover broke systems #64441
mv "${ED}"/usr/bin/passwd "${ED}"/bin/ || die
dosym /bin/passwd /usr/bin/passwd
cd "${S}"
insinto /etc
insopts -m0644 insopts -m0644
newins etc/login.defs login.defs newins etc/login.defs login.defs
@ -166,7 +182,7 @@ src_install() {
-e 'b exit' \ -e 'b exit' \
-e ': pamnote; i# NOTE: This setting should be configured via /etc/pam.d/ and not in this file.' \ -e ': pamnote; i# NOTE: This setting should be configured via /etc/pam.d/ and not in this file.' \
-e ': exit' \ -e ': exit' \
"${ED}"/etc/login.defs || die "${ED}"/usr/share/shadow/login.defs || die
# remove manpages that pam will install for us # remove manpages that pam will install for us
# and/or don't apply when using pam # and/or don't apply when using pam
@ -194,17 +210,3 @@ pkg_preinst() {
rm -f "${EROOT}"/etc/pam.d/system-auth.new \ rm -f "${EROOT}"/etc/pam.d/system-auth.new \
"${EROOT}/etc/login.defs.new" "${EROOT}/etc/login.defs.new"
} }
pkg_postinst() {
# Enable shadow groups.
if [ ! -f "${EROOT}"/etc/gshadow ] ; then
if grpck -r -R "${EROOT}" 2>/dev/null ; then
grpconv -R "${EROOT}"
else
ewarn "Running 'grpck' returned errors. Please run it by hand, and then"
ewarn "run 'grpconv' afterwards!"
fi
fi
einfo "The 'adduser' symlink to 'useradd' has been dropped."
}