Gentoo Archives: gentoo-commits

From: Mikle Kolyada <zlogene@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/util-linux/, sys-apps/util-linux/files/
Date: Sat, 29 Dec 2018 17:45:56
Message-Id: 1546105547.b3fc94e26e94fdd3db193a8e77a4f0977d1591a4.zlogene@gentoo
1 commit: b3fc94e26e94fdd3db193a8e77a4f0977d1591a4
2 Author: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 29 17:45:26 2018 +0000
4 Commit: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 29 17:45:47 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b3fc94e2
7
8 sys-apps/util-linux: fix set_arch detection for sparc
9
10 Signed-off-by: Mikle Kolyada <zlogene <AT> gentoo.org>
11 Package-Manager: Portage-2.3.51, Repoman-2.3.11
12
13 .../files/util-linux-2.33-sparc-setarch.patch | 80 ++++++++++++++++++++++
14 sys-apps/util-linux/util-linux-2.33.ebuild | 3 +-
15 2 files changed, 82 insertions(+), 1 deletion(-)
16
17 diff --git a/sys-apps/util-linux/files/util-linux-2.33-sparc-setarch.patch b/sys-apps/util-linux/files/util-linux-2.33-sparc-setarch.patch
18 new file mode 100644
19 index 00000000000..cbae6c0f263
20 --- /dev/null
21 +++ b/sys-apps/util-linux/files/util-linux-2.33-sparc-setarch.patch
22 @@ -0,0 +1,80 @@
23 +From 3fa06e049012218d883d0e1251df86bafbc446bf Mon Sep 17 00:00:00 2001
24 +From: Karel Zak <kzak@××××××.com>
25 +Date: Thu, 22 Nov 2018 11:03:35 +0100
26 +Subject: [PATCH] setarch: fix obscure sparc32bash use-case
27 +
28 +Reported-by: Carlos Santos <casantos@×××××××××××.br>
29 +Signed-off-by: Karel Zak <kzak@××××××.com>
30 +---
31 + sys-utils/setarch.c | 28 ++++++++++++++++++----------
32 + 1 file changed, 18 insertions(+), 10 deletions(-)
33 +
34 +diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
35 +index a733f7b3c..7c0a63fbb 100644
36 +--- a/sys-utils/setarch.c
37 ++++ b/sys-utils/setarch.c
38 +@@ -268,6 +268,7 @@ int main(int argc, char *argv[])
39 + int c;
40 + struct arch_domain *doms, *target;
41 + unsigned long pers_value = 0;
42 ++ char *shell = NULL, *shell_arg = NULL;
43 +
44 + /* Options without equivalent short options */
45 + enum {
46 +@@ -310,14 +311,14 @@ int main(int argc, char *argv[])
47 + archwrapper = strcmp(program_invocation_short_name, "setarch") != 0;
48 + if (archwrapper) {
49 + arch = program_invocation_short_name; /* symlinks to setarch */
50 +-#if defined(__sparc64__) || defined(__sparc__)
51 ++
52 ++ /* Don't use ifdef sparc here, we get "Unrecognized architecture"
53 ++ * error message later if necessary */
54 + if (strcmp(arch, "sparc32bash") == 0) {
55 +- if (set_arch(arch, 0L, 0))
56 +- err(EXIT_FAILURE, _("Failed to set personality to %s"), arch);
57 +- execl("/bin/bash", "", NULL);
58 +- errexec("/bin/bash");
59 ++ shell = "/bin/bash";
60 ++ shell_arg = "";
61 ++ goto set_arch;
62 + }
63 +-#endif
64 + } else {
65 + if (1 < argc && *argv[1] != '-') {
66 + arch = argv[1];
67 +@@ -391,6 +392,7 @@ int main(int argc, char *argv[])
68 + argc -= optind;
69 + argv += optind;
70 +
71 ++set_arch:
72 + /* get execution domain (architecture) */
73 + if (arch) {
74 + doms = init_arch_domains();
75 +@@ -422,17 +424,23 @@ int main(int argc, char *argv[])
76 + if (arch)
77 + verify_arch_domain(target, arch);
78 +
79 ++ if (!argc) {
80 ++ shell = "/bin/sh";
81 ++ shell_arg = "-sh";
82 ++ }
83 + if (verbose) {
84 +- printf(_("Execute command `%s'.\n"), argc ? argv[0] : "/bin/sh");
85 ++ printf(_("Execute command `%s'.\n"), shell ? shell : argv[0]);
86 + /* flush all output streams before exec */
87 + fflush(NULL);
88 + }
89 +
90 +- if (!argc) {
91 +- execl("/bin/sh", "-sh", NULL);
92 +- errexec("/bin/sh");
93 ++ /* Execute shell */
94 ++ if (shell) {
95 ++ execl(shell, shell_arg, NULL);
96 ++ errexec(shell);
97 + }
98 +
99 ++ /* Execute on command line specified command */
100 + execvp(argv[0], argv);
101 + errexec(argv[0]);
102 + }
103
104 diff --git a/sys-apps/util-linux/util-linux-2.33.ebuild b/sys-apps/util-linux/util-linux-2.33.ebuild
105 index c95e045cc20..cf66f3c521b 100644
106 --- a/sys-apps/util-linux/util-linux-2.33.ebuild
107 +++ b/sys-apps/util-linux/util-linux-2.33.ebuild
108 @@ -1,4 +1,4 @@
109 -# Copyright 1999-2018 Gentoo Foundation and others
110 +# Copyright 1999-2018 Gentoo Authors and others
111 # Copyright 2018 Sony Interactive Entertainment Inc.
112 # Distributed under the terms of the GNU General Public License v2
113
114 @@ -65,6 +65,7 @@ S="${WORKDIR}/${MY_P}"
115
116 PATCHES=(
117 "${FILESDIR}/util-linux-2.32.1-skip-oids-test-when-uuidgen-is-not-available.patch"
118 + "${FILESDIR}/${P}-sparc-setarch.patch"
119 )
120
121 src_prepare() {