1 |
commit: 77c6aa5ac90ebe5ef18bf7f6afe44833b383c974 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 28 02:30:08 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 28 02:30:42 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77c6aa5a |
7 |
|
8 |
sys-libs/gpm: fix build with musl, misc upstream backports |
9 |
|
10 |
- Backport musl patches |
11 |
- Backport include path fix |
12 |
- Backport signedness fix |
13 |
|
14 |
Closes: https://bugs.gentoo.org/829581 |
15 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
16 |
|
17 |
sys-libs/gpm/files/gpm-1.20.7-gcc-include.patch | 18 +++ |
18 |
sys-libs/gpm/files/gpm-1.20.7-musl.patch | 143 ++++++++++++++++++++++++ |
19 |
sys-libs/gpm/files/gpm-1.20.7-signedness.patch | 20 ++++ |
20 |
sys-libs/gpm/gpm-1.20.7-r4.ebuild | 112 +++++++++++++++++++ |
21 |
4 files changed, 293 insertions(+) |
22 |
|
23 |
diff --git a/sys-libs/gpm/files/gpm-1.20.7-gcc-include.patch b/sys-libs/gpm/files/gpm-1.20.7-gcc-include.patch |
24 |
new file mode 100644 |
25 |
index 000000000000..51d047c465cc |
26 |
--- /dev/null |
27 |
+++ b/sys-libs/gpm/files/gpm-1.20.7-gcc-include.patch |
28 |
@@ -0,0 +1,18 @@ |
29 |
+https://github.com/telmich/gpm/commit/80cac2a2bd7eed7e80626559f792f37319030729 |
30 |
+ |
31 |
+From: "Desmond O. Chang" <dochang@×××××.com> |
32 |
+Date: Wed, 13 Apr 2016 21:17:48 +0800 |
33 |
+Subject: [PATCH] Add gcc include path |
34 |
+ |
35 |
+Close #13 |
36 |
+--- a/src/Makefile.in |
37 |
++++ b/src/Makefile.in |
38 |
+@@ -96,7 +96,7 @@ $(DEPFILE) dep: prog/gpm-root.c |
39 |
+ |
40 |
+ # create dependencies |
41 |
+ for DEPS in `echo *.c */*.c`; do \ |
42 |
+- $(CC) -I. -I $(srcdir) -M @CPPFLAGS@ $(CPPFLAGS) $$DEPS | \ |
43 |
++ $(CC) -I. -I $(srcdir) -I $(srcdir)/headers -M @CPPFLAGS@ $(CPPFLAGS) $$DEPS | \ |
44 |
+ $(SED) 's/^\(.*\)\.o\([ :]+\)/\1.o \1.lo\2/g' >> $(DEPFILE) ; done |
45 |
+ |
46 |
+ ### INSTALL |
47 |
|
48 |
diff --git a/sys-libs/gpm/files/gpm-1.20.7-musl.patch b/sys-libs/gpm/files/gpm-1.20.7-musl.patch |
49 |
new file mode 100644 |
50 |
index 000000000000..37f8542a87aa |
51 |
--- /dev/null |
52 |
+++ b/sys-libs/gpm/files/gpm-1.20.7-musl.patch |
53 |
@@ -0,0 +1,143 @@ |
54 |
+https://github.com/telmich/gpm/commit/d88fb1de5803c366ab62f7de9ee5d83207fb2afe |
55 |
+https://github.com/telmich/gpm/commit/4a938233fbe6de7af05aabc74891b68d4bae40f8 |
56 |
+https://bugs.gentoo.org/829581 |
57 |
+ |
58 |
+From: Dima Krasner <dima@×××××××××××.com> |
59 |
+Date: Wed, 12 Nov 2014 23:06:46 +0200 |
60 |
+Subject: [PATCH] Added musl support to libgpm and the daemon. |
61 |
+ |
62 |
+--- a/src/daemon/open_console.c |
63 |
++++ b/src/daemon/open_console.c |
64 |
+@@ -21,6 +21,7 @@ |
65 |
+ |
66 |
+ #include <fcntl.h> /* open and co. */ |
67 |
+ #include <sys/stat.h> /* stat() */ |
68 |
++#include <sys/types.h> /* major() */ |
69 |
+ #include <sys/ioctl.h> /* ioctl */ |
70 |
+ |
71 |
+ /* Linux specific (to be outsourced in gpm2 */ |
72 |
+--- a/src/prog/display-buttons.c |
73 |
++++ b/src/prog/display-buttons.c |
74 |
+@@ -36,6 +36,7 @@ |
75 |
+ #include <stdio.h> /* printf() */ |
76 |
+ #include <time.h> /* time() */ |
77 |
+ #include <errno.h> /* errno */ |
78 |
++#include <sys/select.h> /* fd_set and FD_* */ |
79 |
+ #include <gpm.h> /* gpm information */ |
80 |
+ |
81 |
+ /* display resulting data */ |
82 |
+--- a/src/prog/display-coords.c |
83 |
++++ b/src/prog/display-coords.c |
84 |
+@@ -38,6 +38,7 @@ |
85 |
+ #include <stdio.h> /* printf() */ |
86 |
+ #include <time.h> /* time() */ |
87 |
+ #include <errno.h> /* errno */ |
88 |
++#include <sys/select.h> /* fd_set and FD_* */ |
89 |
+ #include <gpm.h> /* gpm information */ |
90 |
+ |
91 |
+ /* display resulting data */ |
92 |
+--- a/src/prog/gpm-root.y |
93 |
++++ b/src/prog/gpm-root.y |
94 |
+@@ -1199,9 +1199,9 @@ int main(int argc, char **argv) |
95 |
+ #if defined(__GLIBC__) |
96 |
+ __sigemptyset(&childaction.sa_mask); |
97 |
+ #else /* __GLIBC__ */ |
98 |
+- childaction.sa_mask=0; |
99 |
++ sigemptyset(&childaction.sa_mask); |
100 |
+ #endif /* __GLIBC__ */ |
101 |
+- childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */ |
102 |
++ childaction.sa_flags=0; |
103 |
+ sigaction(SIGCHLD,&childaction,NULL); |
104 |
+ |
105 |
+ /*....................................... Connect and get your buffer */ |
106 |
+ |
107 |
+From: Kurt Nalty <46026992+kurtnalty@××××××××××××××××××××.com> |
108 |
+Date: Sat, 29 Dec 2018 23:44:24 -0600 |
109 |
+Subject: [PATCH 1/4] Update gpm.c |
110 |
+ |
111 |
+--- a/src/daemon/gpm.c |
112 |
++++ b/src/daemon/gpm.c |
113 |
+@@ -29,7 +29,7 @@ |
114 |
+ #include <signal.h> /* SIGPIPE */ |
115 |
+ #include <time.h> /* time() */ |
116 |
+ #include <sys/param.h> |
117 |
+-#include <sys/fcntl.h> /* O_RDONLY */ |
118 |
++#include <fcntl.h> /* O_RDONLY */ |
119 |
+ #include <sys/wait.h> /* wait() */ |
120 |
+ #include <sys/stat.h> /* mkdir() */ |
121 |
+ #include <sys/time.h> /* timeval */ |
122 |
+ |
123 |
+From: Kurt Nalty <46026992+kurtnalty@××××××××××××××××××××.com> |
124 |
+Date: Sat, 29 Dec 2018 23:47:17 -0600 |
125 |
+Subject: [PATCH 2/4] Add include <string.h> |
126 |
+ |
127 |
+Added |
128 |
+ line 28, #include <string.h> /* strcpy, bzero */ |
129 |
+for musl compilation |
130 |
+--- a/src/daemon/old_main.c |
131 |
++++ b/src/daemon/old_main.c |
132 |
+@@ -25,6 +25,7 @@ |
133 |
+ #include <signal.h> /* guess again */ |
134 |
+ #include <errno.h> /* guess again */ |
135 |
+ #include <unistd.h> /* unlink */ |
136 |
++#include <string.h> /* strcpy, bzero */ |
137 |
+ #include <sys/stat.h> /* chmod */ |
138 |
+ |
139 |
+ #include <linux/kd.h> /* linux hd* */ |
140 |
+ |
141 |
+From: Kurt Nalty <46026992+kurtnalty@××××××××××××××××××××.com> |
142 |
+Date: Sat, 29 Dec 2018 23:52:58 -0600 |
143 |
+Subject: [PATCH 3/4] Update liblow.c for musl compatible |
144 |
+ |
145 |
+Changed #include <sys/fcntl.h> to #include <fcntl.h> |
146 |
+Changed SA_NOMASK to SA_NODEFER on lines 176, 367 |
147 |
+--- a/src/lib/liblow.c |
148 |
++++ b/src/lib/liblow.c |
149 |
+@@ -33,7 +33,7 @@ |
150 |
+ #include <sys/types.h> /* socket() */ |
151 |
+ #include <sys/socket.h> /* socket() */ |
152 |
+ #include <sys/un.h> /* struct sockaddr_un */ |
153 |
+-#include <sys/fcntl.h> /* O_RDONLY */ |
154 |
++#include <fcntl.h> /* O_RDONLY */ |
155 |
+ #include <sys/stat.h> /* stat() */ |
156 |
+ |
157 |
+ #ifdef SIGTSTP /* true if BSD system */ |
158 |
+@@ -173,7 +173,7 @@ static void gpm_suspend_hook (int signum) |
159 |
+ /* Reincarnation. Prepare for another death early. */ |
160 |
+ sigemptyset(&sa.sa_mask); |
161 |
+ sa.sa_handler = gpm_suspend_hook; |
162 |
+- sa.sa_flags = SA_NOMASK; |
163 |
++ sa.sa_flags = SA_NODEFER; |
164 |
+ sigaction (SIGTSTP, &sa, 0); |
165 |
+ |
166 |
+ /* Pop the gpm stack by closing the useless connection */ |
167 |
+@@ -364,7 +364,7 @@ int Gpm_Open(Gpm_Connect *conn, int flag) |
168 |
+ |
169 |
+ /* if signal was originally ignored, job control is not supported */ |
170 |
+ if (gpm_saved_suspend_hook.sa_handler != SIG_IGN) { |
171 |
+- sa.sa_flags = SA_NOMASK; |
172 |
++ sa.sa_flags = SA_NODEFER; |
173 |
+ sa.sa_handler = gpm_suspend_hook; |
174 |
+ sigaction(SIGTSTP, &sa, 0); |
175 |
+ } |
176 |
+ |
177 |
+From: Kurt Nalty <46026992+kurtnalty@××××××××××××××××××××.com> |
178 |
+Date: Mon, 31 Dec 2018 18:41:19 -0600 |
179 |
+Subject: [PATCH 4/4] Aligned comments |
180 |
+ |
181 |
+--- a/src/lib/liblow.c |
182 |
++++ b/src/lib/liblow.c |
183 |
+@@ -29,11 +29,12 @@ |
184 |
+ #include <string.h> /* strncmp */ |
185 |
+ #include <unistd.h> /* select(); */ |
186 |
+ #include <errno.h> |
187 |
++#include <fcntl.h> /* O_RDONLY */ |
188 |
++ |
189 |
+ #include <sys/time.h> /* timeval */ |
190 |
+ #include <sys/types.h> /* socket() */ |
191 |
+ #include <sys/socket.h> /* socket() */ |
192 |
+ #include <sys/un.h> /* struct sockaddr_un */ |
193 |
+-#include <fcntl.h> /* O_RDONLY */ |
194 |
+ #include <sys/stat.h> /* stat() */ |
195 |
+ |
196 |
+ #ifdef SIGTSTP /* true if BSD system */ |
197 |
|
198 |
diff --git a/sys-libs/gpm/files/gpm-1.20.7-signedness.patch b/sys-libs/gpm/files/gpm-1.20.7-signedness.patch |
199 |
new file mode 100644 |
200 |
index 000000000000..3904bfd6cca3 |
201 |
--- /dev/null |
202 |
+++ b/sys-libs/gpm/files/gpm-1.20.7-signedness.patch |
203 |
@@ -0,0 +1,20 @@ |
204 |
+https://github.com/telmich/gpm/commit/4337fd9fc2d2ea83654f2ca69245503730231ac3 |
205 |
+ |
206 |
+From: iljavs <ivansprundel@××××××××.com> |
207 |
+Date: Mon, 27 Jun 2016 01:17:57 -0700 |
208 |
+Subject: [PATCH] fix signedness issue |
209 |
+ |
210 |
+This commit fixes a signedness issue, where a negative vc coming from a malicious client could possibly cause memory corruption. |
211 |
+--- a/src/daemon/processconn.c |
212 |
++++ b/src/daemon/processconn.c |
213 |
+@@ -67,7 +67,8 @@ int processConn(int fd) |
214 |
+ return -1; |
215 |
+ } |
216 |
+ |
217 |
+- if((vc = request->vc) > MAX_VC) { |
218 |
++ vc = request->vc; |
219 |
++ if(vc > MAX_VC || vc < 0) { |
220 |
+ gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_VC); |
221 |
+ free(info); |
222 |
+ close(newfd); |
223 |
+ |
224 |
|
225 |
diff --git a/sys-libs/gpm/gpm-1.20.7-r4.ebuild b/sys-libs/gpm/gpm-1.20.7-r4.ebuild |
226 |
new file mode 100644 |
227 |
index 000000000000..d554df614508 |
228 |
--- /dev/null |
229 |
+++ b/sys-libs/gpm/gpm-1.20.7-r4.ebuild |
230 |
@@ -0,0 +1,112 @@ |
231 |
+# Copyright 1999-2022 Gentoo Authors |
232 |
+# Distributed under the terms of the GNU General Public License v2 |
233 |
+ |
234 |
+# emacs support disabled due to #99533 #335900 |
235 |
+ |
236 |
+EAPI=7 |
237 |
+ |
238 |
+inherit autotools linux-info systemd usr-ldscript multilib-minimal |
239 |
+ |
240 |
+DESCRIPTION="Console-based mouse driver" |
241 |
+HOMEPAGE="https://www.nico.schottelius.org/software/gpm/" |
242 |
+SRC_URI=" |
243 |
+ https://www.nico.schottelius.org/software/${PN}/archives/${P}.tar.lzma |
244 |
+ mirror://gentoo/${P}-docs.patch.xz" |
245 |
+ |
246 |
+LICENSE="GPL-2" |
247 |
+SLOT="0" |
248 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" |
249 |
+IUSE="selinux" |
250 |
+ |
251 |
+RDEPEND=" |
252 |
+ sys-libs/ncurses:=[${MULTILIB_USEDEP}] |
253 |
+ selinux? ( sec-policy/selinux-gpm )" |
254 |
+DEPEND="${RDEPEND}" |
255 |
+BDEPEND=" |
256 |
+ app-arch/xz-utils |
257 |
+ sys-apps/texinfo |
258 |
+ virtual/yacc" |
259 |
+ |
260 |
+CONFIG_CHECK="~INPUT_MOUSEDEV" |
261 |
+ERROR_INPUT_MOUSEDEV="CONFIG_INPUT_MOUSEDEV:\tis not set (required to expose mice for GPM)" |
262 |
+ |
263 |
+pkg_pretend() { |
264 |
+ check_extra_config |
265 |
+} |
266 |
+ |
267 |
+src_prepare() { |
268 |
+ eapply "${FILESDIR}"/${P}-sysmacros.patch |
269 |
+ |
270 |
+ # Hack up the docs until we get this sorted upstream. |
271 |
+ # https://github.com/telmich/gpm/issues/8 |
272 |
+ eapply "${WORKDIR}"/${P}-docs.patch |
273 |
+ touch -r . doc/* || die |
274 |
+ |
275 |
+ # bug #629774 |
276 |
+ eapply "${FILESDIR}"/${P}-glibc-2.26.patch |
277 |
+ # bug #705878 |
278 |
+ eapply "${FILESDIR}"/${P}-gcc-10.patch |
279 |
+ # bug #829581 |
280 |
+ eapply "${FILESDIR}"/${P}-musl.patch |
281 |
+ # |
282 |
+ eapply "${FILESDIR}"/${P}-gcc-include.patch |
283 |
+ eapply "${FILESDIR}"/${P}-signedness.patch |
284 |
+ |
285 |
+ eapply_user |
286 |
+ |
287 |
+ # fix ABI values |
288 |
+ sed -i \ |
289 |
+ -e '/^abi_lev=/s:=.*:=1:' \ |
290 |
+ -e '/^abi_age=/s:=.*:=20:' \ |
291 |
+ configure.ac.footer || die |
292 |
+ # Rebuild autotools since release doesn't include them. |
293 |
+ # Should be fixed with the next release though. |
294 |
+ # https://github.com/telmich/gpm/pull/15 |
295 |
+ sed -i -e '/ACLOCAL/,$d' autogen.sh || die |
296 |
+ ./autogen.sh |
297 |
+ eautoreconf |
298 |
+ |
299 |
+ # Out-of-tree builds are broken. |
300 |
+ # https://github.com/telmich/gpm/issues/16 |
301 |
+ multilib_copy_sources |
302 |
+} |
303 |
+ |
304 |
+multilib_src_configure() { |
305 |
+ econf \ |
306 |
+ --disable-static \ |
307 |
+ --sysconfdir="${EPREFIX}"/etc/gpm \ |
308 |
+ emacs="${BROOT}"/bin/false |
309 |
+} |
310 |
+ |
311 |
+_emake() { |
312 |
+ emake \ |
313 |
+ EMACS=: ELISP="" \ |
314 |
+ $(multilib_is_native_abi || echo "PROG= ") \ |
315 |
+ "$@" |
316 |
+} |
317 |
+ |
318 |
+multilib_src_compile() { |
319 |
+ _emake |
320 |
+} |
321 |
+ |
322 |
+multilib_src_test() { |
323 |
+ _emake check |
324 |
+} |
325 |
+ |
326 |
+multilib_src_install() { |
327 |
+ _emake DESTDIR="${D}" install |
328 |
+ |
329 |
+ dosym libgpm.so.1 /usr/$(get_libdir)/libgpm.so |
330 |
+ gen_usr_ldscript -a gpm |
331 |
+} |
332 |
+ |
333 |
+multilib_src_install_all() { |
334 |
+ insinto /etc/gpm |
335 |
+ doins conf/gpm-*.conf |
336 |
+ |
337 |
+ dodoc README TODO doc/Announce doc/FAQ doc/README* |
338 |
+ |
339 |
+ newinitd "${FILESDIR}"/gpm.rc6-2 gpm |
340 |
+ newconfd "${FILESDIR}"/gpm.conf.d gpm |
341 |
+ systemd_dounit "${FILESDIR}"/gpm.service |
342 |
+} |