Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/fakechroot/, sys-apps/fakechroot/files/
Date: Mon, 19 Apr 2021 21:14:24
Message-Id: 1618866837.7196d1665ae9b57cd3c063d868e281d8f733170d.floppym@gentoo
1 commit: 7196d1665ae9b57cd3c063d868e281d8f733170d
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Mon Apr 19 21:13:41 2021 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Mon Apr 19 21:13:57 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7196d166
7
8 sys-apps/fakechroot: fix build with glibc-2.33
9
10 Closes: https://bugs.gentoo.org/774666
11 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
12
13 sys-apps/fakechroot/fakechroot-2.20.1.ebuild | 4 +
14 .../files/fakechroot-2.20.1-glibc-2.33.patch | 469 +++++++++++++++++++++
15 2 files changed, 473 insertions(+)
16
17 diff --git a/sys-apps/fakechroot/fakechroot-2.20.1.ebuild b/sys-apps/fakechroot/fakechroot-2.20.1.ebuild
18 index 75ca647e8b9..f5bfa37c478 100644
19 --- a/sys-apps/fakechroot/fakechroot-2.20.1.ebuild
20 +++ b/sys-apps/fakechroot/fakechroot-2.20.1.ebuild
21 @@ -13,6 +13,10 @@ KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86"
22
23 RESTRICT="test"
24
25 +PATCHES=(
26 + "${FILESDIR}/fakechroot-2.20.1-glibc-2.33.patch"
27 +)
28 +
29 src_configure() {
30 econf --disable-static
31 }
32
33 diff --git a/sys-apps/fakechroot/files/fakechroot-2.20.1-glibc-2.33.patch b/sys-apps/fakechroot/files/fakechroot-2.20.1-glibc-2.33.patch
34 new file mode 100644
35 index 00000000000..31c2dd78439
36 --- /dev/null
37 +++ b/sys-apps/fakechroot/files/fakechroot-2.20.1-glibc-2.33.patch
38 @@ -0,0 +1,469 @@
39 +From 534e6d555736b97211523970d378dfb0db2608e9 Mon Sep 17 00:00:00 2001
40 +From: Ilya Lipnitskiy <ilya.lipnitskiy@×××××.com>
41 +Date: Mon, 22 Feb 2021 21:44:07 -0800
42 +Subject: [PATCH 1/6] tmpnam.c: fix heap overflow
43 +
44 +Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@×××××.com>
45 +---
46 + src/tmpnam.c | 2 +-
47 + 1 file changed, 1 insertion(+), 1 deletion(-)
48 +
49 +diff --git a/src/tmpnam.c b/src/tmpnam.c
50 +index ce60817..917ee6b 100644
51 +--- a/src/tmpnam.c
52 ++++ b/src/tmpnam.c
53 +@@ -42,7 +42,7 @@ wrapper(tmpnam, char *, (char * s))
54 +
55 + expand_chroot_path(ptr);
56 +
57 +- ptr2 = malloc(strlen(ptr));
58 ++ ptr2 = malloc(strlen(ptr) + 1);
59 + if (ptr2 == NULL) return NULL;
60 +
61 + strcpy(ptr2, ptr);
62 +
63 +From 75d7e6fa191c11a791faff06a0de86eaa7801d05 Mon Sep 17 00:00:00 2001
64 +From: Ilya Lipnitskiy <ilya.lipnitskiy@×××××.com>
65 +Date: Mon, 22 Feb 2021 21:46:36 -0800
66 +Subject: [PATCH 2/6] declare missing bufs, remove ver from lstat
67 +
68 +Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@×××××.com>
69 +---
70 + src/lstat.c | 8 +++++---
71 + src/lstat.h | 2 +-
72 + src/mknod.c | 2 ++
73 + src/stat.c | 2 ++
74 + src/stat64.c | 2 ++
75 + 5 files changed, 12 insertions(+), 4 deletions(-)
76 +
77 +diff --git a/src/lstat.c b/src/lstat.c
78 +index 3f6d819..54e3263 100644
79 +--- a/src/lstat.c
80 ++++ b/src/lstat.c
81 +@@ -28,9 +28,11 @@
82 + #include "lstat.h"
83 +
84 +
85 +-wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
86 ++wrapper(lstat, int, (const char * filename, struct stat * buf))
87 + {
88 +- debug("lstat(%d, \"%s\", &buf)", ver, filename);
89 ++ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
90 ++ char fakechroot_buf[FAKECHROOT_PATH_MAX];
91 ++ debug("lstat(\"%s\", &buf)", filename);
92 +
93 + if (!fakechroot_localdir(filename)) {
94 + if (filename != NULL) {
95 +@@ -40,7 +42,7 @@ wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
96 + }
97 + }
98 +
99 +- return lstat_rel(ver, filename, buf);
100 ++ return lstat_rel(filename, buf);
101 + }
102 +
103 +
104 +diff --git a/src/lstat.h b/src/lstat.h
105 +index 751c1ea..ee48303 100644
106 +--- a/src/lstat.h
107 ++++ b/src/lstat.h
108 +@@ -26,7 +26,7 @@
109 +
110 + #ifndef HAVE___LXSTAT
111 +
112 +-wrapper_proto(lstat, int, (int, const char *, struct stat *));
113 ++wrapper_proto(lstat, int, (const char *, struct stat *));
114 +
115 + int lstat_rel(const char *, struct stat *);
116 +
117 +diff --git a/src/mknod.c b/src/mknod.c
118 +index 52fd33b..2771037 100644
119 +--- a/src/mknod.c
120 ++++ b/src/mknod.c
121 +@@ -28,6 +28,8 @@
122 +
123 + wrapper(mknod, int, (const char * pathname, mode_t mode, dev_t dev))
124 + {
125 ++ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
126 ++ char fakechroot_buf[FAKECHROOT_PATH_MAX];
127 + debug("mknod(\"%s\", 0%o, %ld)", pathname, mode, dev);
128 + expand_chroot_path(pathname);
129 + return nextcall(mknod)(pathname, mode, dev);
130 +diff --git a/src/stat.c b/src/stat.c
131 +index 7845662..7b37793 100644
132 +--- a/src/stat.c
133 ++++ b/src/stat.c
134 +@@ -33,6 +33,8 @@
135 +
136 + wrapper(stat, int, (const char * file_name, struct stat * buf))
137 + {
138 ++ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
139 ++ char fakechroot_buf[FAKECHROOT_PATH_MAX];
140 + debug("stat(\"%s\", &buf)", file_name);
141 + expand_chroot_path(file_name);
142 + return nextcall(stat)(file_name, buf);
143 +diff --git a/src/stat64.c b/src/stat64.c
144 +index aac9c75..a360f66 100644
145 +--- a/src/stat64.c
146 ++++ b/src/stat64.c
147 +@@ -34,6 +34,8 @@
148 +
149 + wrapper(stat64, int, (const char * file_name, struct stat64 * buf))
150 + {
151 ++ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
152 ++ char fakechroot_buf[FAKECHROOT_PATH_MAX];
153 + debug("stat64(\"%s\", &buf)", file_name);
154 + expand_chroot_path(file_name);
155 + return nextcall(stat64)(file_name, buf);
156 +
157 +From 693a3597ea7fccfb62f357503ff177bd3e3d5a89 Mon Sep 17 00:00:00 2001
158 +From: Ilya Lipnitskiy <ilya.lipnitskiy@×××××.com>
159 +Date: Mon, 22 Feb 2021 21:47:09 -0800
160 +Subject: [PATCH 3/6] fix glibc 2.33+ compatibility
161 +
162 +Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@×××××.com>
163 +---
164 + configure.ac | 20 ++++++++++++++++++++
165 + src/ftw.c | 2 +-
166 + src/ftw64.c | 14 +++++++++++---
167 + src/libfakechroot.h | 15 +++++++++++++++
168 + src/lstat.c | 2 +-
169 + src/lstat.h | 2 +-
170 + src/lstat64.c | 2 +-
171 + src/mknod.c | 2 +-
172 + src/mknodat.c | 2 +-
173 + src/stat.c | 2 +-
174 + src/stat64.c | 2 +-
175 + 11 files changed, 54 insertions(+), 11 deletions(-)
176 +
177 +diff --git a/configure.ac b/configure.ac
178 +index f8cdb32..9cc2e77 100644
179 +--- a/configure.ac
180 ++++ b/configure.ac
181 +@@ -75,6 +75,26 @@ ACX_CHECK_C_ATTRIBUTE_VISIBILITY
182 + # Checks for libraries.
183 + AC_CHECK_LIB([dl], [dlsym])
184 +
185 ++AH_TEMPLATE([NEW_GLIBC], [glibc >= 2.33])
186 ++AC_MSG_CHECKING([for glibc 2.33+])
187 ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
188 ++ #include <sys/stat.h>
189 ++ ]], [[
190 ++#ifdef __GLIBC__
191 ++#if !__GLIBC_PREREQ(2,33)
192 ++#error glibc<2.33
193 ++#endif
194 ++#else
195 ++#error not glibc
196 ++#endif
197 ++ ]])],[
198 ++ AC_DEFINE(NEW_GLIBC,1)
199 ++ AC_MSG_RESULT([yes])
200 ++ ],[
201 ++ AC_DEFINE(NEW_GLIBC,0)
202 ++ AC_MSG_RESULT([no])
203 ++ ])
204 ++
205 + # Checks for header files.
206 + AC_HEADER_DIRENT
207 + AC_HEADER_STDC
208 +diff --git a/src/ftw.c b/src/ftw.c
209 +index 92fc126..a9abc85 100644
210 +--- a/src/ftw.c
211 ++++ b/src/ftw.c
212 +@@ -185,7 +185,7 @@ int rpl_lstat (const char *, struct stat *);
213 + # define NFTW_NEW_NAME __new_nftw
214 + # define INO_T ino_t
215 + # define STAT stat
216 +-# ifdef _LIBC
217 ++# if defined(_LIBC) && !NEW_GLIBC
218 + # define LXSTAT __lxstat
219 + # define XSTAT __xstat
220 + # define FXSTATAT __fxstatat
221 +diff --git a/src/ftw64.c b/src/ftw64.c
222 +index 7cc8cdf..cee1f2b 100644
223 +--- a/src/ftw64.c
224 ++++ b/src/ftw64.c
225 +@@ -18,6 +18,8 @@
226 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
227 + 02111-1307 USA. */
228 +
229 ++#include "config.h"
230 ++
231 + #define __FTW64_C
232 + #define FTW_NAME ftw64
233 + #define NFTW_NAME nftw64
234 +@@ -25,9 +27,15 @@
235 + #define NFTW_NEW_NAME __new_nftw64
236 + #define INO_T ino64_t
237 + #define STAT stat64
238 +-#define LXSTAT __lxstat64
239 +-#define XSTAT __xstat64
240 +-#define FXSTATAT __fxstatat64
241 ++#if NEW_GLIBC
242 ++# define LXSTAT(V,f,sb) lstat64 (f,sb)
243 ++# define XSTAT(V,f,sb) stat64 (f,sb)
244 ++# define FXSTATAT(V,d,f,sb,m) fstatat64 (d, f, sb, m)
245 ++#else
246 ++# define LXSTAT __lxstat64
247 ++# define XSTAT __xstat64
248 ++# define FXSTATAT __fxstatat64
249 ++#endif
250 + #define FTW_FUNC_T __ftw64_func_t
251 + #define NFTW_FUNC_T __nftw64_func_t
252 +
253 +diff --git a/src/libfakechroot.h b/src/libfakechroot.h
254 +index 4cf199f..64ff15f 100644
255 +--- a/src/libfakechroot.h
256 ++++ b/src/libfakechroot.h
257 +@@ -200,6 +200,21 @@
258 + # endif
259 + #endif
260 +
261 ++#ifndef _STAT_VER
262 ++ #if defined (__aarch64__)
263 ++ #define _STAT_VER 0
264 ++ #elif defined (__powerpc__) && __WORDSIZE == 64
265 ++ #define _STAT_VER 1
266 ++ #elif defined (__riscv) && __riscv_xlen==64
267 ++ #define _STAT_VER 0
268 ++ #elif defined (__s390x__)
269 ++ #define _STAT_VER 1
270 ++ #elif defined (__x86_64__)
271 ++ #define _STAT_VER 1
272 ++ #else
273 ++ #define _STAT_VER 3
274 ++ #endif
275 ++#endif
276 +
277 + typedef void (*fakechroot_wrapperfn_t)(void);
278 +
279 +diff --git a/src/lstat.c b/src/lstat.c
280 +index 54e3263..fa38323 100644
281 +--- a/src/lstat.c
282 ++++ b/src/lstat.c
283 +@@ -20,7 +20,7 @@
284 +
285 + #include <config.h>
286 +
287 +-#ifndef HAVE___LXSTAT
288 ++#if !defined(HAVE___LXSTAT) || NEW_GLIBC
289 +
290 + #include <sys/stat.h>
291 + #include <unistd.h>
292 +diff --git a/src/lstat.h b/src/lstat.h
293 +index ee48303..c46a2b9 100644
294 +--- a/src/lstat.h
295 ++++ b/src/lstat.h
296 +@@ -24,7 +24,7 @@
297 + #include <config.h>
298 + #include "libfakechroot.h"
299 +
300 +-#ifndef HAVE___LXSTAT
301 ++#if !defined(HAVE___LXSTAT) || NEW_GLIBC
302 +
303 + wrapper_proto(lstat, int, (const char *, struct stat *));
304 +
305 +diff --git a/src/lstat64.c b/src/lstat64.c
306 +index b6212fc..a332d7c 100644
307 +--- a/src/lstat64.c
308 ++++ b/src/lstat64.c
309 +@@ -20,7 +20,7 @@
310 +
311 + #include <config.h>
312 +
313 +-#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
314 ++#if defined(HAVE_LSTAT64) && (!defined(HAVE___LXSTAT64) || NEW_GLIBC)
315 +
316 + #define _LARGEFILE64_SOURCE
317 + #define _BSD_SOURCE
318 +diff --git a/src/mknod.c b/src/mknod.c
319 +index 2771037..aeb750b 100644
320 +--- a/src/mknod.c
321 ++++ b/src/mknod.c
322 +@@ -20,7 +20,7 @@
323 +
324 + #include <config.h>
325 +
326 +-#ifndef HAVE___XMKNOD
327 ++#if !defined(HAVE___XMKNOD) || NEW_GLIBC
328 +
329 + #include <sys/stat.h>
330 + #include "libfakechroot.h"
331 +diff --git a/src/mknodat.c b/src/mknodat.c
332 +index 732a22b..3239b35 100644
333 +--- a/src/mknodat.c
334 ++++ b/src/mknodat.c
335 +@@ -20,7 +20,7 @@
336 +
337 + #include <config.h>
338 +
339 +-#if defined(HAVE_MKNODAT) && !defined(HAVE___XMKNODAT)
340 ++#if defined(HAVE_MKNODAT) && (!defined(HAVE___XMKNODAT) || NEW_GLIBC)
341 +
342 + #define _ATFILE_SOURCE
343 + #include <sys/stat.h>
344 +diff --git a/src/stat.c b/src/stat.c
345 +index 7b37793..5ef57ba 100644
346 +--- a/src/stat.c
347 ++++ b/src/stat.c
348 +@@ -20,7 +20,7 @@
349 +
350 + #include <config.h>
351 +
352 +-#ifndef HAVE___XSTAT
353 ++#if !defined(HAVE___XSTAT) || NEW_GLIBC
354 +
355 + #define _BSD_SOURCE
356 + #define _DEFAULT_SOURCE
357 +diff --git a/src/stat64.c b/src/stat64.c
358 +index a360f66..993ce80 100644
359 +--- a/src/stat64.c
360 ++++ b/src/stat64.c
361 +@@ -20,7 +20,7 @@
362 +
363 + #include <config.h>
364 +
365 +-#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
366 ++#if defined(HAVE_STAT64) && (!defined(HAVE___XSTAT64) || NEW_GLIBC)
367 +
368 + #define _BSD_SOURCE
369 + #define _LARGEFILE64_SOURCE
370 +
371 +From e7c1f3a446e594a4d0cce5f5d499c9439ce1d5c5 Mon Sep 17 00:00:00 2001
372 +From: neok-m4700 <neok-m4700@××××××××××××××××××××.com>
373 +Date: Wed, 24 Feb 2021 17:36:57 +0100
374 +Subject: [PATCH 6/6] wrap fstatat and fstatat64
375 +
376 +---
377 + configure.ac | 2 ++
378 + src/Makefile.am | 2 ++
379 + src/fstatat.c | 42 ++++++++++++++++++++++++++++++++++++++++++
380 + src/fstatat64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
381 + 4 files changed, 89 insertions(+)
382 + create mode 100644 src/fstatat.c
383 + create mode 100644 src/fstatat64.c
384 +
385 +diff --git a/configure.ac b/configure.ac
386 +index 9cc2e77..5b3053e 100644
387 +--- a/configure.ac
388 ++++ b/configure.ac
389 +@@ -218,6 +218,8 @@ AC_CHECK_FUNCS(m4_normalize([
390 + freopen64
391 + fstat
392 + fstat64
393 ++ fstatat
394 ++ fstatat64
395 + fts_children
396 + fts_open
397 + fts_read
398 +diff --git a/src/Makefile.am b/src/Makefile.am
399 +index 6066345..eb311c0 100644
400 +--- a/src/Makefile.am
401 ++++ b/src/Makefile.am
402 +@@ -61,6 +61,8 @@ libfakechroot_la_SOURCES = \
403 + fopen64.c \
404 + freopen.c \
405 + freopen64.c \
406 ++ fstatat.c \
407 ++ fstatat64.c \
408 + fts.c \
409 + fts64.c \
410 + ftw.c \
411 +diff --git a/src/fstatat.c b/src/fstatat.c
412 +new file mode 100644
413 +index 0000000..ca7578b
414 +--- /dev/null
415 ++++ b/src/fstatat.c
416 +@@ -0,0 +1,42 @@
417 ++/*
418 ++ libfakechroot -- fake chroot environment
419 ++ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@××××××.org>
420 ++
421 ++ This library is free software; you can redistribute it and/or
422 ++ modify it under the terms of the GNU Lesser General Public
423 ++ License as published by the Free Software Foundation; either
424 ++ version 2.1 of the License, or (at your option) any later version.
425 ++
426 ++ This library is distributed in the hope that it will be useful,
427 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
428 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
429 ++ Lesser General Public License for more details.
430 ++
431 ++ You should have received a copy of the GNU Lesser General Public
432 ++ License along with this library; if not, write to the Free Software
433 ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
434 ++*/
435 ++
436 ++
437 ++#include <config.h>
438 ++
439 ++#ifdef HAVE_FSTATAT
440 ++
441 ++#define _ATFILE_SOURCE
442 ++#define _POSIX_C_SOURCE 200809L
443 ++#include <sys/stat.h>
444 ++#include <limits.h>
445 ++#include "libfakechroot.h"
446 ++
447 ++wrapper(fstatat, int, (int dirfd, const char *pathname, struct stat *buf, int flags))
448 ++{
449 ++ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
450 ++ char fakechroot_buf[FAKECHROOT_PATH_MAX];
451 ++ debug("fstatat(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
452 ++ expand_chroot_path_at(dirfd, pathname);
453 ++ return nextcall(fstatat)(dirfd, pathname, buf, flags);
454 ++}
455 ++
456 ++#else
457 ++typedef int empty_translation_unit;
458 ++#endif
459 +diff --git a/src/fstatat64.c b/src/fstatat64.c
460 +new file mode 100644
461 +index 0000000..1863372
462 +--- /dev/null
463 ++++ b/src/fstatat64.c
464 +@@ -0,0 +1,43 @@
465 ++/*
466 ++ libfakechroot -- fake chroot environment
467 ++ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@××××××.org>
468 ++
469 ++ This library is free software; you can redistribute it and/or
470 ++ modify it under the terms of the GNU Lesser General Public
471 ++ License as published by the Free Software Foundation; either
472 ++ version 2.1 of the License, or (at your option) any later version.
473 ++
474 ++ This library is distributed in the hope that it will be useful,
475 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
476 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
477 ++ Lesser General Public License for more details.
478 ++
479 ++ You should have received a copy of the GNU Lesser General Public
480 ++ License along with this library; if not, write to the Free Software
481 ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
482 ++*/
483 ++
484 ++
485 ++#include <config.h>
486 ++
487 ++#ifdef HAVE_FSTATAT64
488 ++
489 ++#define _ATFILE_SOURCE
490 ++#define _POSIX_C_SOURCE 200809L
491 ++#define _LARGEFILE64_SOURCE
492 ++#include <sys/stat.h>
493 ++#include <limits.h>
494 ++#include "libfakechroot.h"
495 ++
496 ++wrapper(fstatat64, int, (int dirfd, const char *pathname, struct stat64 *buf, int flags))
497 ++{
498 ++ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
499 ++ char fakechroot_buf[FAKECHROOT_PATH_MAX];
500 ++ debug("fstatat64(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
501 ++ expand_chroot_path_at(dirfd, pathname);
502 ++ return nextcall(fstatat64)(dirfd, pathname, buf, flags);
503 ++}
504 ++
505 ++#else
506 ++typedef int empty_translation_unit;
507 ++#endif