Skip to content

Commit

Permalink
openrc: update 0.47.1 -> 0.48
Browse files Browse the repository at this point in the history
Add a backported fix for building with glibc-2.38.

License-Update: copyright years updated
Signed-off-by: Justin Bronder <[email protected]>
  • Loading branch information
jsbronder committed Aug 30, 2023
1 parent d8ec64f commit 2e3ccda
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
From c1cd3c9830ce2c68dcf65342688e11a220723619 Mon Sep 17 00:00:00 2001
From: Sam James <[email protected]>
Date: Wed, 30 Aug 2023 02:32:13 +0100
Subject: [PATCH] Don't re-define strlcpy/strlcat with >=glibc-2.38

`>=glibc-2.38` implements strlcpy, strlcat, etc so check for those functions
with Meson and don't provide conflicting prototypes.

Technically, it doesn't need _GNU_SOURCE, but it's easier because it's not
clear right now what glibc wants to guard it with. Note that these are in
POSIX next anyway.

Fixes: https://github.com/OpenRC/openrc/issues/643
Signed-off-by: Sam James <[email protected]>

Upstream-Status: Backport https://github.com/OpenRC/openrc/commit/c1cd3c9830ce2c68dcf65342688e11a220723619
---
meson.build | 4 ++++
src/libeinfo/libeinfo.c | 5 +----
src/shared/helpers.h | 4 +---
3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/meson.build b/meson.build
index 3e94ce5d..73cb9778 100644
--- a/meson.build
+++ b/meson.build
@@ -203,6 +203,10 @@ if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd
add_project_arguments('-DHAVE_CLOSE_RANGE_CLOEXEC', language: 'c')
endif

+if cc.has_function('strlcpy', prefix: '#define _GNU_SOURCE\n#include <string.h>')
+ add_project_arguments('-DHAVE_STRLCPY', language: 'c')
+endif
+
incdir = include_directories('src/shared')
einfo_incdir = include_directories('src/libeinfo')
rc_incdir = include_directories('src/librc')
diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c
index fb8b6e3d..840233bd 100644
--- a/src/libeinfo/libeinfo.c
+++ b/src/libeinfo/libeinfo.c
@@ -146,9 +146,7 @@ static const char *const color_terms[] = {
};
#endif

-/* strlcat and strlcpy are nice, shame glibc does not define them */
-#ifdef __GLIBC__
-# if !defined (__UCLIBC__) && !defined (__dietlibc__)
+#ifndef HAVE_STRLCPY
static size_t
strlcat(char *dst, const char *src, size_t size)
{
@@ -176,7 +174,6 @@ strlcat(char *dst, const char *src, size_t size)

return dst_n + (s - src);
}
-# endif
#endif

static bool
diff --git a/src/shared/helpers.h b/src/shared/helpers.h
index 9cf263be..dee41b75 100644
--- a/src/shared/helpers.h
+++ b/src/shared/helpers.h
@@ -37,10 +37,8 @@

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

-#ifdef __GLIBC__
-# if !defined (__UCLIBC__) && !defined (__dietlibc__)
+#ifndef HAVE_STRLCPY
# define strlcpy(dst, src, size) snprintf(dst, size, "%s", src)
-# endif
#endif

#ifndef timespecsub
--
2.41.0

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
LICENSE = "BSD-2-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=2307fb28847883ac2b0b110b1c1f36e0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=18590035fb3f5120d3a5e4b781f9ae25"

SRCREV = "3e5420b911922a14dd6b5cc3d2143dc30559caf4"
SRCREV = "92662ddc44f6091e8085fcd4637d13f04e90c5ac"

SRC_URI = " \
git://github.com/openrc/openrc.git;nobranch=1;protocol=https \
file://volatiles.initd \
file://getty.confd \
file://getty.initd \
file://0001-Don-t-re-define-strlcpy-strlcat-with-glibc-2.38.patch \
"

S = "${WORKDIR}/git"
Expand Down

0 comments on commit 2e3ccda

Please sign in to comment.