summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wendler <polynomial-c@gentoo.org>2019-11-19 11:36:19 +0100
committerLars Wendler <polynomial-c@gentoo.org>2019-11-19 11:37:04 +0100
commit30c4a8ad9c4fc913b0fc0b2530d9d03ded040852 (patch)
treed5cd2199dd115410831d6991c474a6dd6e00e04b /sys-apps/shadow
parentsys-apps/util-linux: Introduced "logger" and "su" USE flags (diff)
downloadgentoo-30c4a8ad9c4fc913b0fc0b2530d9d03ded040852.tar.gz
gentoo-30c4a8ad9c4fc913b0fc0b2530d9d03ded040852.tar.bz2
gentoo-30c4a8ad9c4fc913b0fc0b2530d9d03ded040852.zip
sys-apps/shadow: Introduced "su" USE flag
Moved passwd from /usr/bin to /bin (again) as it breaks at least one package that has passwd path hardcoded (net-misc/scponly) Thanks-to: fling <fling@member.fsf.org> Bug: https://bugs.gentoo.org/699930 Package-Manager: Portage-2.3.79, Repoman-2.3.18 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
Diffstat (limited to 'sys-apps/shadow')
-rw-r--r--sys-apps/shadow/files/shadow-4.7-optional_su.patch130
-rw-r--r--sys-apps/shadow/metadata.xml3
-rw-r--r--sys-apps/shadow/shadow-4.7-r2.ebuild234
3 files changed, 367 insertions, 0 deletions
diff --git a/sys-apps/shadow/files/shadow-4.7-optional_su.patch b/sys-apps/shadow/files/shadow-4.7-optional_su.patch
new file mode 100644
index 000000000000..472846460776
--- /dev/null
+++ b/sys-apps/shadow/files/shadow-4.7-optional_su.patch
@@ -0,0 +1,130 @@
+From ddb0553b2e559fd431fe8b460c37cb7fef8c06ee Mon Sep 17 00:00:00 2001
+From: Lars Wendler <polynomial-c@gentoo.org>
+Date: Tue, 19 Nov 2019 10:57:06 +0100
+Subject: [PATCH] build: Make build/installation of su and its support files
+ optional
+
+Enabled by default
+This is necessary because coreutils and util-linux can also provide su
+
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ configure.ac | 7 +++++++
+ etc/pam.d/Makefile.am | 7 +++++--
+ man/Makefile.am | 5 ++++-
+ src/Makefile.am | 10 ++++++++--
+ 4 files changed, 24 insertions(+), 5 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 67625564..5629df98 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -286,6 +286,9 @@ AC_ARG_WITH(sssd,
+ AC_ARG_WITH(group-name-max-length,
+ [AC_HELP_STRING([--with-group-name-max-length], [set max group name length @<:@default=16@:>@])],
+ [with_group_name_max_length=$withval], [with_group_name_max_length=yes])
++AC_ARG_WITH(su,
++ [AC_HELP_STRING([--with-su], [build and install su program and man page @<:@default=yes@:>@])],
++ [with_su=$withval], [with_su=yes])
+
+ if test "$with_group_name_max_length" = "no" ; then
+ with_group_name_max_length=0
+@@ -313,6 +316,9 @@ if test "$with_sssd" = "yes"; then
+ [AC_MSG_ERROR([posix_spawn is needed for sssd support])])
+ fi
+
++AS_IF([test "$with_su" != "no"], AC_DEFINE(WITH_SU, 1, [Build with su])])
++AM_CONDITIONAL([WITH_SU], [test "x$with_su" != "xno"])
++
+ dnl Check for some functions in libc first, only if not found check for
+ dnl other libraries. This should prevent linking libnsl if not really
+ dnl needed (Linux glibc, Irix), but still link it if needed (Solaris).
+@@ -719,4 +725,5 @@ echo " nscd support: $with_nscd"
+ echo " sssd support: $with_sssd"
+ echo " subordinate IDs support: $enable_subids"
+ echo " use file caps: $with_fcaps"
++echo " install su: $with_su"
+ echo
+diff --git a/etc/pam.d/Makefile.am b/etc/pam.d/Makefile.am
+index d967eb95..38ff26ae 100644
+--- a/etc/pam.d/Makefile.am
++++ b/etc/pam.d/Makefile.am
+@@ -6,8 +6,7 @@ pamd_files = \
+ chsh \
+ groupmems \
+ login \
+- passwd \
+- su
++ passwd
+
+ pamd_acct_tools_files = \
+ chage \
+@@ -29,4 +28,8 @@ pamd_DATA += $(pamd_acct_tools_files)
+ endif
+ endif
+
++if WITH_SU
++pamd_files += su
++endif
++
+ EXTRA_DIST = $(pamd_files) $(pamd_acct_tools_files)
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 3f040e05..8b64feba 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -41,7 +41,6 @@ man_MANS = \
+ man1/sg.1 \
+ man3/shadow.3 \
+ man5/shadow.5 \
+- man1/su.1 \
+ man5/suauth.5 \
+ man8/useradd.8 \
+ man8/userdel.8 \
+@@ -54,6 +53,10 @@ man_nopam = \
+ man5/login.access.5 \
+ man5/porttime.5
+
++if WITH_SU
++man_MANS += man1/su.1
++endif
++
+ if !USE_PAM
+ man_MANS += $(man_nopam)
+ endif
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 34690ced..06ee9545 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -23,12 +23,15 @@ AM_CPPFLAGS = \
+ # and installation would be much simpler (just two directories,
+ # $prefix/bin and $prefix/sbin, no install-data hacks...)
+
+-bin_PROGRAMS = groups login su
++bin_PROGRAMS = groups login
+ sbin_PROGRAMS = nologin
+ ubin_PROGRAMS = faillog lastlog chage chfn chsh expiry gpasswd newgrp passwd
+ if ENABLE_SUBIDS
+ ubin_PROGRAMS += newgidmap newuidmap
+ endif
++if WITH_SU
++bin_PROGRAMS += su
++endif
+ usbin_PROGRAMS = \
+ chgpasswd \
+ chpasswd \
+@@ -52,8 +55,11 @@ usbin_PROGRAMS = \
+ # id and groups are from gnu, sulogin from sysvinit
+ noinst_PROGRAMS = id sulogin
+
+-suidbins = su
++suidbins =
+ suidubins = chage chfn chsh expiry gpasswd newgrp
++if WITH_SU
++suidbins += su
++endif
+ if !WITH_TCB
+ suidubins += passwd
+ endif
+--
+2.24.0
+
diff --git a/sys-apps/shadow/metadata.xml b/sys-apps/shadow/metadata.xml
index 623e134e2752..a69630c7b1eb 100644
--- a/sys-apps/shadow/metadata.xml
+++ b/sys-apps/shadow/metadata.xml
@@ -5,6 +5,9 @@
<email>base-system@gentoo.org</email>
<name>Gentoo Base System</name>
</maintainer>
+ <use>
+ <flag name="su">build the su program</flag>
+ </use>
<!-- only for USE=pam -->
<upstream>
<remote-id type="cpe">cpe:/a:debian:shadow</remote-id>
diff --git a/sys-apps/shadow/shadow-4.7-r2.ebuild b/sys-apps/shadow/shadow-4.7-r2.ebuild
new file mode 100644
index 000000000000..b75f9599e1c5
--- /dev/null
+++ b/sys-apps/shadow/shadow-4.7-r2.ebuild
@@ -0,0 +1,234 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools libtool pam
+
+DESCRIPTION="Utilities to deal with user accounts"
+HOMEPAGE="https://github.com/shadow-maint/shadow"
+SRC_URI="https://github.com/shadow-maint/shadow/releases/download/${PV}/${P}.tar.gz"
+
+LICENSE="BSD GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86"
+IUSE="acl audit +cracklib nls pam selinux skey split-usr +su xattr"
+# 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 )
+
+DEPEND="
+ acl? ( sys-apps/acl:0= )
+ audit? ( >=sys-process/audit-2.6:0= )
+ cracklib? ( >=sys-libs/cracklib-2.7-r3:0= )
+ nls? ( virtual/libintl )
+ pam? ( sys-libs/pam:0= )
+ skey? ( sys-auth/skey:0= )
+ selinux? (
+ >=sys-libs/libselinux-1.28:0=
+ sys-libs/libsemanage:0=
+ )
+ su? ( !sys-apps/util-linux[su] )
+ xattr? ( sys-apps/attr:0= )
+"
+BDEPEND="
+ app-arch/xz-utils
+ nls? ( sys-devel/gettext )
+"
+RDEPEND="
+ ${DEPEND}
+ pam? ( >=sys-auth/pambase-20150213 )
+"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-4.1.3-dots-in-usernames.patch"
+ "${FILESDIR}/${PN}-4.7-optional_su.patch"
+)
+
+src_prepare() {
+ default
+ eautoreconf
+ #elibtoolize
+}
+
+src_configure() {
+ local myeconfargs=(
+ --with-btrfs
+ --without-group-name-max-length
+ --without-tcb
+ --enable-shared=no
+ --enable-static=yes
+ $(use_enable nls)
+ $(use_with acl)
+ $(use_with audit)
+ $(use_with cracklib libcrack)
+ $(use_with elibc_glibc nscd)
+ $(use_with pam libpam)
+ $(use_with selinux)
+ $(use_with skey)
+ $(use_with su)
+ $(use_with xattr attr)
+ )
+ econf "${myeconfargs[@]}"
+
+ has_version 'sys-libs/uclibc[-rpc]' && sed -i '/RLOGIN/d' config.h #425052
+
+ if use nls ; then
+ local l langs="po" # These are the pot files.
+ for l in ${LANGS[*]} ; do
+ has ${l} ${LINGUAS-${l}} && langs+=" ${l}"
+ done
+ sed -i "/^SUBDIRS = /s:=.*:= ${langs}:" man/Makefile || die
+ fi
+}
+
+set_login_opt() {
+ local comment="" opt=$1 val=$2
+ if [[ -z ${val} ]]; then
+ comment="#"
+ sed -i \
+ -e "/^${opt}\>/s:^:#:" \
+ "${ED}"/etc/login.defs || die
+ else
+ sed -i -r \
+ -e "/^#?${opt}\>/s:.*:${opt} ${val}:" \
+ "${ED}"/etc/login.defs
+ fi
+ local res=$(grep "^${comment}${opt}\>" "${ED}"/etc/login.defs)
+ einfo "${res:-Unable to find ${opt} in /etc/login.defs}"
+}
+
+src_install() {
+ emake DESTDIR="${D}" suidperms=4711 install
+
+ # Remove libshadow and libmisc; see bug 37725 and the following
+ # comment from shadow's README.linux:
+ # Currently, libshadow.a is for internal use only, so if you see
+ # -lshadow in a Makefile of some other package, it is safe to
+ # remove it.
+ rm -f "${ED}"/{,usr/}$(get_libdir)/lib{misc,shadow}.{a,la}
+
+ insinto /etc
+ if ! use pam ; then
+ insopts -m0600
+ doins etc/login.access etc/limits
+ fi
+
+ # needed for 'useradd -D'
+ insinto /etc/default
+ insopts -m0600
+ doins "${FILESDIR}"/default/useradd
+
+ if use split-usr ; then
+ # move passwd to / to help recover broke systems #64441
+ # We cannot simply remove this or else net-misc/scponly
+ # and other tools will break because of hardcoded passwd
+ # location
+ dodir /bin
+ mv "${ED}"/usr/bin/passwd "${ED}"/bin/ || die
+ dosym ../../bin/passwd /usr/bin/passwd
+ fi
+
+ cd "${S}" || die
+ insinto /etc
+ insopts -m0644
+ newins etc/login.defs login.defs
+
+ set_login_opt CREATE_HOME yes
+ if ! use pam ; then
+ set_login_opt MAIL_CHECK_ENAB no
+ set_login_opt SU_WHEEL_ONLY yes
+ set_login_opt CRACKLIB_DICTPATH /usr/$(get_libdir)/cracklib_dict
+ set_login_opt LOGIN_RETRIES 3
+ set_login_opt ENCRYPT_METHOD SHA512
+ set_login_opt CONSOLE
+ else
+ dopamd "${FILESDIR}"/pam.d-include/shadow
+
+ for x in chpasswd chgpasswd newusers; do
+ newpamd "${FILESDIR}"/pam.d-include/passwd ${x}
+ done
+
+ for x in chage chsh chfn \
+ user{add,del,mod} group{add,del,mod} ; do
+ newpamd "${FILESDIR}"/pam.d-include/shadow ${x}
+ done
+
+ # comment out login.defs options that pam hates
+ local opt sed_args=()
+ for opt in \
+ CHFN_AUTH \
+ CONSOLE \
+ CRACKLIB_DICTPATH \
+ ENV_HZ \
+ ENVIRON_FILE \
+ FAILLOG_ENAB \
+ FTMP_FILE \
+ LASTLOG_ENAB \
+ MAIL_CHECK_ENAB \
+ MOTD_FILE \
+ NOLOGINS_FILE \
+ OBSCURE_CHECKS_ENAB \
+ PASS_ALWAYS_WARN \
+ PASS_CHANGE_TRIES \
+ PASS_MIN_LEN \
+ PORTTIME_CHECKS_ENAB \
+ QUOTAS_ENAB \
+ SU_WHEEL_ONLY
+ do
+ set_login_opt ${opt}
+ sed_args+=( -e "/^#${opt}\>/b pamnote" )
+ done
+ sed -i "${sed_args[@]}" \
+ -e 'b exit' \
+ -e ': pamnote; i# NOTE: This setting should be configured via /etc/pam.d/ and not in this file.' \
+ -e ': exit' \
+ "${ED}"/etc/login.defs || die
+
+ # remove manpages that pam will install for us
+ # and/or don't apply when using pam
+ find "${ED}"/usr/share/man -type f \
+ '(' -name 'limits.5*' -o -name 'suauth.5*' ')' \
+ -delete
+
+ # Remove pam.d files provided by pambase.
+ rm "${ED}"/etc/pam.d/{login,passwd} || die
+ if use su ; then
+ rm "${ED}"/etc/pam.d/su || die
+ fi
+ fi
+
+ # Remove manpages that are handled by other packages
+ find "${ED}"/usr/share/man \
+ '(' -name id.1 -o -name passwd.5 -o -name getspnam.3 ')' \
+ -delete
+
+ cd "${S}" || die
+ dodoc ChangeLog NEWS TODO
+ newdoc README README.download
+ cd doc || die
+ dodoc HOWTO README* WISHLIST *.txt
+}
+
+pkg_preinst() {
+ rm -f "${EROOT}"/etc/pam.d/system-auth.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
+
+ [[ ! -f "${EROOT}"/etc/subgid ]] &&
+ touch "${EROOT}"/etc/subgid
+ [[ ! -f "${EROOT}"/etc/subuid ]] &&
+ touch "${EROOT}"/etc/subuid
+
+ einfo "The 'adduser' symlink to 'useradd' has been dropped."
+}