Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-dialup/mingetty/, net-dialup/mingetty/files/
Date: Tue, 01 Mar 2016 07:54:52
Message-Id: 1456818860.5941cbcb27255f6a84c64ed504221cad3b1bad1c.polynomial-c@gentoo
1 commit: 5941cbcb27255f6a84c64ed504221cad3b1bad1c
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 29 16:08:08 2016 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Tue Mar 1 07:54:20 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5941cbcb
7
8 net-dialup/mingetty: Fixed usage of unsafe chroot call (bug #339338).
9
10 Package-Manager: portage-2.2.27
11 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
12
13 .../mingetty-1.08-check_chroot_chdir_nice.patch | 36 ++++++++++++++++++++++
14 net-dialup/mingetty/mingetty-1.08-r1.ebuild | 34 ++++++++++++++++++++
15 2 files changed, 70 insertions(+)
16
17 diff --git a/net-dialup/mingetty/files/mingetty-1.08-check_chroot_chdir_nice.patch b/net-dialup/mingetty/files/mingetty-1.08-check_chroot_chdir_nice.patch
18 new file mode 100644
19 index 0000000..4c5d2b2
20 --- /dev/null
21 +++ b/net-dialup/mingetty/files/mingetty-1.08-check_chroot_chdir_nice.patch
22 @@ -0,0 +1,36 @@
23 +Check chdir() on chroot() syscalls (and similar) as chroot without proper
24 +chdir() allows to escape from changed root.
25 +
26 +http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597382
27 +http://sourceforge.net/tracker/?func=detail&aid=3095679&group_id=80387&atid=559616
28 +
29 +--- mingetty-1.08/mingetty.c
30 ++++ mingetty-1.08/mingetty.c
31 +@@ -422,12 +422,21 @@
32 + while ((logname = get_logname ()) == 0)
33 + /* do nothing */ ;
34 +
35 +- if (ch_root)
36 +- chroot (ch_root);
37 +- if (ch_dir)
38 +- chdir (ch_dir);
39 +- if (priority)
40 +- nice (priority);
41 ++ if (ch_root) {
42 ++ if (chroot (ch_root))
43 ++ error ("chroot(\"%s\") failed: %s", ch_root, strerror (errno));
44 ++ if (chdir("/"))
45 ++ error ("chdir(\"/\") failed: %s", strerror (errno));
46 ++ }
47 ++ if (ch_dir) {
48 ++ if (chdir (ch_dir))
49 ++ error ("chdir(\"%s\") failed: %s", ch_dir, strerror (errno));
50 ++ }
51 ++ if (priority) {
52 ++ errno = 0; /* see the nice(2) NOTES for why we do this */
53 ++ if ((nice (priority) == -1) && (errno != 0))
54 ++ error ("nice(%d) failed: %s", priority, strerror (errno));
55 ++ }
56 +
57 + execl (loginprog, loginprog, autologin? "-f" : "--", logname, NULL);
58 + error ("%s: can't exec %s: %s", tty, loginprog, strerror (errno));
59
60 diff --git a/net-dialup/mingetty/mingetty-1.08-r1.ebuild b/net-dialup/mingetty/mingetty-1.08-r1.ebuild
61 new file mode 100644
62 index 0000000..171a299
63 --- /dev/null
64 +++ b/net-dialup/mingetty/mingetty-1.08-r1.ebuild
65 @@ -0,0 +1,34 @@
66 +# Copyright 1999-2016 Gentoo Foundation
67 +# Distributed under the terms of the GNU General Public License v2
68 +# $Id$
69 +
70 +EAPI=6
71 +
72 +inherit toolchain-funcs eutils
73 +
74 +DESCRIPTION="A compact getty program for virtual consoles only"
75 +HOMEPAGE="http://sourceforge.net/projects/mingetty"
76 +SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
77 +
78 +LICENSE="GPL-2"
79 +SLOT="0"
80 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
81 +IUSE="unicode"
82 +
83 +PATCHES=(
84 + "${FILESDIR}/${PN}-1.08-check_chroot_chdir_nice.patch"
85 +)
86 +
87 +src_prepare() {
88 + use unicode && eapply "${FILESDIR}"/${PN}-1.08-utf8.patch
89 + default
90 +}
91 +
92 +src_compile() {
93 + emake CFLAGS="${CFLAGS} -Wall -W -pipe -D_GNU_SOURCE" CC="$(tc-getCC)"
94 +}
95 +
96 +src_install () {
97 + dodir /sbin /usr/share/man/man8
98 + emake DESTDIR="${D}" install
99 +}