summaryrefslogtreecommitdiff
path: root/sys-apps/shadow
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-02-17 20:03:52 +0000
committerV3n3RiX <venerix@redcorelinux.org>2018-02-17 20:03:52 +0000
commit4935506e9a5cbfabd37c64093eac5f36c2ff0017 (patch)
treeaf9dd93ea349eacaf28286c7c45c7a083b0b7c31 /sys-apps/shadow
parent434d713861b70f6c6563d6ee50a8e64f14c970d9 (diff)
gentoo resync : 17.02.2018
Diffstat (limited to 'sys-apps/shadow')
-rw-r--r--sys-apps/shadow/Manifest2
-rw-r--r--sys-apps/shadow/files/shadow-4.5-CVE-2018-7169.patch180
-rw-r--r--sys-apps/shadow/shadow-4.5-r1.ebuild212
3 files changed, 394 insertions, 0 deletions
diff --git a/sys-apps/shadow/Manifest b/sys-apps/shadow/Manifest
index e14f4f8e6344..2837d7d44ba3 100644
--- a/sys-apps/shadow/Manifest
+++ b/sys-apps/shadow/Manifest
@@ -6,8 +6,10 @@ AUX shadow-4.4-CVE-2017-2616.patch 2159 BLAKE2B e51b0c81392207d8e07dd6d4b8b16410
AUX shadow-4.4-load_defaults.patch 1027 BLAKE2B 632c18631d1218bed95a043e89a2599f008f8af87c230703c759acaab20768920cdfc21233ebd6a065553a92577a6e5a81f2a0d6d7cdecb9c16cacad4df4f22b SHA512 c821149fdcb71b0c1c7b0de72126a3ec625bd54f2edaff1666ccd30abe3f3d516db329dbe873ae020a6670f93caaf7d235283666113d5b02936043d6dd976d36
AUX shadow-4.4-prototypes.patch 1232 BLAKE2B 757a6db113b6873994dcacfd6867a14e7d35def2d4ba6749b887f28cf7278117722bda2c8b981e23694dafcc25d6f2d7cd9531aeb3d3eb597c9b822729678dc2 SHA512 970f79efaf77e91baa22049230f2a97e6a045f2f03ef846f4c35dc4f5702941e61db5b6544c24d112faafd6d516fc5054725039f28fe81e17926a5e8ef6f0432
AUX shadow-4.4-su-snprintf.patch 849 BLAKE2B 62cb1498bd79991373b1bc8241a07dfcd731ebba7a39406958b30bd0287c8acab65a9a22bcee8ba95073e36c7a8d0b1931b988b4b5963041f61db9ef4c5dbdeb SHA512 2aaa1c847ec34002c6e63af66fb36664e0fc5dc0b719ab38959043f990e84191f5e2f85c2dc44e324abcfe67691c9a9b8181da49077031e2eaaf979dde95b2d9
+AUX shadow-4.5-CVE-2018-7169.patch 5778 BLAKE2B 59e06cda2d3b48d77548c22073f9c4ce018c16bdd128089ce6ae6d8eebe1ad9b73438530fb32b628bc5e72201852b7c452264a13707bcbfa826777b778a7b90b SHA512 fef082516e47ee4e3d9627916c47ffb8e1987580586639374d461b7b9d041370abe5b80dbbfacd4fd256a1bc2f9d23e0e71497298dd60ccd96d795811a13cd58
DIST shadow-4.4.tar.gz 3706812 BLAKE2B b4dc056643ea507af975df68a1775193c942227aef4ff0d19fcc70392e5410da076d3cc9ad1c58082ec992f2aaa35037dd7de9e6563f783aaed96b2007055ab1 SHA512 c1e0f65a4fbd0f9d8de38e488b4a374cac5c476180e233269fc666988d9201c0dcc694605c5e54d54f81039c2e30c95b14c12f10adef749a45cc31f0b4b5d5a6
DIST shadow-4.5.tar.gz 3804933 BLAKE2B c4714b7fe9a1af5a5751d4274e70e7fb31994cc40058b44c401bbbdf83c238fcf48e6e6e663d8a61f614b6291ea524862d9d2425d7d839340a10f8fb7c8eaa85 SHA512 02d6482a1159689e404dd49a68b4e2db85e9ffdcdfbacc8efcbd9043f14a1ec3fc4d749700df915d375df67d589219b6b0f57a6cfd9fb5b197012888a608913b
EBUILD shadow-4.4-r2.ebuild 5484 BLAKE2B 988704357c01c35a2808b48c921c6de6ac6eb06429e6a35945263fba094caf8bddb0d4fed6ef236845f7983671dbee109d95a01f84703e7b4fc59a7fe26ce569 SHA512 8584c5805f4729a4ab42ccac22a558b0899258f9408cae4a9c5570f6b4ea7f9a969da92393ce456f1d5e2a5199bacbb5317f3433a7d41afb5b52e280493b0f56
+EBUILD shadow-4.5-r1.ebuild 5405 BLAKE2B 7518b3700adf543a619413066415f64959a50efbbe669b28622e8d2d4cd749705b256c62e3ba73a88e6f3c0d6c195c87c377e7541e165ccbf4328ec5f4b1b0df SHA512 a50352c9b189d5265e921e977acff5c96dedef2634b046f66b376e6d6e2fdab40b629e453695a3153dd1edb13740e94d6d205daed544b3bba885fd35dbb7251e
EBUILD shadow-4.5.ebuild 5325 BLAKE2B c2849ceaf174e3ea0a660c7da8912f60d4c1446119759c1d98131ee493074340c1bc149e3c542552f56a802cb5b56d2d0db60b36860afe858c84a00122bbfeb1 SHA512 1f1a6dc525673045fee660b661bf772aea028718b172f386560999b884807f1b3e0dd6a9a6ef6a9c89ebe79d9a0ff14526c62dd77d7c9ca96ebc55f1243a870a
MISC metadata.xml 565 BLAKE2B bdd91116c16f590eabb6f18f05a4f72b55651383431c78fb07c27b23e7152b25816895e2ae3e2afd1ecd6e2b9fa9dd0005d198f2ab7ee2061583b586e4c44b01 SHA512 be29faf2eb981bdb0d643ca691d48b10ee702c3a32ca7fca1d00365aa1c4beb5b1b4bec8104be4352fed32f3fabc3108061b8eb8f0054e612c268b5c6f4b1469
diff --git a/sys-apps/shadow/files/shadow-4.5-CVE-2018-7169.patch b/sys-apps/shadow/files/shadow-4.5-CVE-2018-7169.patch
new file mode 100644
index 000000000000..30ad9e614067
--- /dev/null
+++ b/sys-apps/shadow/files/shadow-4.5-CVE-2018-7169.patch
@@ -0,0 +1,180 @@
+From fb28c99b8a66ff2605c5cb96abc0a4d975f92de0 Mon Sep 17 00:00:00 2001
+From: Aleksa Sarai <asarai@suse.de>
+Date: Thu, 15 Feb 2018 23:49:40 +1100
+Subject: [PATCH] newgidmap: enforce setgroups=deny if self-mapping a group
+
+This is necessary to match the kernel-side policy of "self-mapping in a
+user namespace is fine, but you cannot drop groups" -- a policy that was
+created in order to stop user namespaces from allowing trivial privilege
+escalation by dropping supplementary groups that were "blacklisted" from
+certain paths.
+
+This is the simplest fix for the underlying issue, and effectively makes
+it so that unless a user has a valid mapping set in /etc/subgid (which
+only administrators can modify) -- and they are currently trying to use
+that mapping -- then /proc/$pid/setgroups will be set to deny. This
+workaround is only partial, because ideally it should be possible to set
+an "allow_setgroups" or "deny_setgroups" flag in /etc/subgid to allow
+administrators to further restrict newgidmap(1).
+
+We also don't write anything in the "allow" case because "allow" is the
+default, and users may have already written "deny" even if they
+technically are allowed to use setgroups. And we don't write anything if
+the setgroups policy is already "deny".
+
+Ref: https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1729357
+Fixes: CVE-2018-7169
+Reported-by: Craig Furman <craig.furman89@gmail.com>
+Signed-off-by: Aleksa Sarai <asarai@suse.de>
+---
+ src/newgidmap.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++------
+ 1 file changed, 80 insertions(+), 9 deletions(-)
+
+diff --git a/src/newgidmap.c b/src/newgidmap.c
+index b1e33513..59a2e75c 100644
+--- a/src/newgidmap.c
++++ b/src/newgidmap.c
+@@ -46,32 +46,37 @@
+ */
+ const char *Prog;
+
+-static bool verify_range(struct passwd *pw, struct map_range *range)
++
++static bool verify_range(struct passwd *pw, struct map_range *range, bool *allow_setgroups)
+ {
+ /* An empty range is invalid */
+ if (range->count == 0)
+ return false;
+
+- /* Test /etc/subgid */
+- if (have_sub_gids(pw->pw_name, range->lower, range->count))
++ /* Test /etc/subgid. If the mapping is valid then we allow setgroups. */
++ if (have_sub_gids(pw->pw_name, range->lower, range->count)) {
++ *allow_setgroups = true;
+ return true;
++ }
+
+- /* Allow a process to map its own gid */
+- if ((range->count == 1) && (pw->pw_gid == range->lower))
++ /* Allow a process to map its own gid. */
++ if ((range->count == 1) && (pw->pw_gid == range->lower)) {
++ /* noop -- if setgroups is enabled already we won't disable it. */
+ return true;
++ }
+
+ return false;
+ }
+
+ static void verify_ranges(struct passwd *pw, int ranges,
+- struct map_range *mappings)
++ struct map_range *mappings, bool *allow_setgroups)
+ {
+ struct map_range *mapping;
+ int idx;
+
+ mapping = mappings;
+ for (idx = 0; idx < ranges; idx++, mapping++) {
+- if (!verify_range(pw, mapping)) {
++ if (!verify_range(pw, mapping, allow_setgroups)) {
+ fprintf(stderr, _( "%s: gid range [%lu-%lu) -> [%lu-%lu) not allowed\n"),
+ Prog,
+ mapping->upper,
+@@ -89,6 +94,70 @@ static void usage(void)
+ exit(EXIT_FAILURE);
+ }
+
++void write_setgroups(int proc_dir_fd, bool allow_setgroups)
++{
++ int setgroups_fd;
++ char *policy, policy_buffer[4096];
++
++ /*
++ * Default is "deny", and any "allow" will out-rank a "deny". We don't
++ * forcefully write an "allow" here because the process we are writing
++ * mappings for may have already set themselves to "deny" (and "allow"
++ * is the default anyway). So allow_setgroups == true is a noop.
++ */
++ policy = "deny\n";
++ if (allow_setgroups)
++ return;
++
++ setgroups_fd = openat(proc_dir_fd, "setgroups", O_RDWR|O_CLOEXEC);
++ if (setgroups_fd < 0) {
++ /*
++ * If it's an ENOENT then we are on too old a kernel for the setgroups
++ * code to exist. Emit a warning and bail on this.
++ */
++ if (ENOENT == errno) {
++ fprintf(stderr, _("%s: kernel doesn't support setgroups restrictions\n"), Prog);
++ goto out;
++ }
++ fprintf(stderr, _("%s: couldn't open process setgroups: %s\n"),
++ Prog,
++ strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++
++ /*
++ * Check whether the policy is already what we want. /proc/self/setgroups
++ * is write-once, so attempting to write after it's already written to will
++ * fail.
++ */
++ if (read(setgroups_fd, policy_buffer, sizeof(policy_buffer)) < 0) {
++ fprintf(stderr, _("%s: failed to read setgroups: %s\n"),
++ Prog,
++ strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++ if (!strncmp(policy_buffer, policy, strlen(policy)))
++ goto out;
++
++ /* Write the policy. */
++ if (lseek(setgroups_fd, 0, SEEK_SET) < 0) {
++ fprintf(stderr, _("%s: failed to seek setgroups: %s\n"),
++ Prog,
++ strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++ if (dprintf(setgroups_fd, "%s", policy) < 0) {
++ fprintf(stderr, _("%s: failed to setgroups %s policy: %s\n"),
++ Prog,
++ policy,
++ strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++
++out:
++ close(setgroups_fd);
++}
++
+ /*
+ * newgidmap - Set the gid_map for the specified process
+ */
+@@ -103,6 +172,7 @@ int main(int argc, char **argv)
+ struct stat st;
+ struct passwd *pw;
+ int written;
++ bool allow_setgroups = false;
+
+ Prog = Basename (argv[0]);
+
+@@ -145,7 +215,7 @@ int main(int argc, char **argv)
+ (unsigned long) getuid ()));
+ return EXIT_FAILURE;
+ }
+-
++
+ /* Get the effective uid and effective gid of the target process */
+ if (fstat(proc_dir_fd, &st) < 0) {
+ fprintf(stderr, _("%s: Could not stat directory for target %u\n"),
+@@ -177,8 +247,9 @@ int main(int argc, char **argv)
+ if (!mappings)
+ usage();
+
+- verify_ranges(pw, ranges, mappings);
++ verify_ranges(pw, ranges, mappings, &allow_setgroups);
+
++ write_setgroups(proc_dir_fd, allow_setgroups);
+ write_mapping(proc_dir_fd, ranges, mappings, "gid_map");
+ sub_gid_close();
+
diff --git a/sys-apps/shadow/shadow-4.5-r1.ebuild b/sys-apps/shadow/shadow-4.5-r1.ebuild
new file mode 100644
index 000000000000..1e3d98f2593e
--- /dev/null
+++ b/sys-apps/shadow/shadow-4.5-r1.ebuild
@@ -0,0 +1,212 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit libtool pam multilib
+
+DESCRIPTION="Utilities to deal with user accounts"
+HOMEPAGE="https://github.com/shadow-maint/shadow http://pkg-shadow.alioth.debian.org/"
+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 ~s390 ~sh ~sparc ~x86"
+IUSE="acl audit +cracklib nls pam selinux skey 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 )
+
+RDEPEND="acl? ( sys-apps/acl:0= )
+ audit? ( >=sys-process/audit-2.6:0= )
+ cracklib? ( >=sys-libs/cracklib-2.7-r3:0= )
+ pam? ( virtual/pam:0= )
+ skey? ( sys-auth/skey:0= )
+ selinux? (
+ >=sys-libs/libselinux-1.28:0=
+ sys-libs/libsemanage:0=
+ )
+ nls? ( virtual/libintl )
+ xattr? ( sys-apps/attr:0= )"
+DEPEND="${RDEPEND}
+ app-arch/xz-utils
+ nls? ( sys-devel/gettext )"
+RDEPEND="${RDEPEND}
+ pam? ( >=sys-auth/pambase-20150213 )"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-4.1.3-dots-in-usernames.patch"
+ "${FILESDIR}/${P}-CVE-2018-7169.patch" #647790
+)
+
+src_prepare() {
+ default
+ #eautoreconf
+ elibtoolize
+}
+
+src_configure() {
+ local myeconfargs=(
+ --without-group-name-max-length
+ --without-tcb
+ --enable-shared=no
+ --enable-static=yes
+ $(use_with acl)
+ $(use_with audit)
+ $(use_with cracklib libcrack)
+ $(use_with pam libpam)
+ $(use_with skey)
+ $(use_with selinux)
+ $(use_enable nls)
+ $(use_with elibc_glibc nscd)
+ $(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
+
+ # 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}" || 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 \
+ '(' -name 'limits.5*' -o -name 'suauth.5*' ')' \
+ -delete
+
+ # Remove pam.d files provided by pambase.
+ rm "${ED%/}"/etc/pam.d/{login,passwd,su} || die
+ 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
+
+ einfo "The 'adduser' symlink to 'useradd' has been dropped."
+}