2020-12-02 17:30:43 +01:00
|
|
|
From 017abdc7a59acf7e76109b7fd285f9856b4a9eee Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Wed, 6 May 2020 04:38:35 +0530
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 1/8] libc: add siginterrupt dummy
|
2020-05-07 21:45:55 +02:00
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
---
|
|
|
|
repos/libports/src/lib/libc/signal.cc | 3 +++
|
|
|
|
1 file changed, 3 insertions(+)
|
2020-05-07 21:45:55 +02:00
|
|
|
|
|
|
|
diff --git a/repos/libports/src/lib/libc/signal.cc b/repos/libports/src/lib/libc/signal.cc
|
2020-12-02 17:30:43 +01:00
|
|
|
index a08854a8c0..2d2def34d3 100644
|
2020-05-07 21:45:55 +02:00
|
|
|
--- a/repos/libports/src/lib/libc/signal.cc
|
|
|
|
+++ b/repos/libports/src/lib/libc/signal.cc
|
|
|
|
@@ -131,6 +131,9 @@ extern "C" int sigaction(int signum, const struct sigaction *act, struct sigacti
|
|
|
|
}
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
|
2020-05-07 21:45:55 +02:00
|
|
|
+extern "C" int siginterrupt(int sig, int flag) { return 0; };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
extern "C" int _sigaction(int, const struct sigaction *, struct sigaction *) __attribute__((weak, alias("sigaction")));
|
|
|
|
extern "C" int __sys_sigaction(int, const struct sigaction *, struct sigaction *) __attribute__((weak, alias("sigaction")));
|
|
|
|
extern "C" int __libc_sigaction(int, const struct sigaction *, struct sigaction *) __attribute__((weak, alias("sigaction")));
|
2020-12-02 17:30:43 +01:00
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|
2020-05-07 21:45:55 +02:00
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
From e73c873a6e329eef4dede312e0bd0e597c93adde Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Wed, 6 May 2020 04:59:56 +0530
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 2/8] libc: add upstream mbsinit
|
2020-05-07 21:45:55 +02:00
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
---
|
|
|
|
repos/libports/lib/mk/libc-locale.mk | 2 +-
|
|
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
2020-05-07 21:45:55 +02:00
|
|
|
|
|
|
|
diff --git a/repos/libports/lib/mk/libc-locale.mk b/repos/libports/lib/mk/libc-locale.mk
|
|
|
|
index 8e75e59589..2bb98b1456 100644
|
|
|
|
--- a/repos/libports/lib/mk/libc-locale.mk
|
|
|
|
+++ b/repos/libports/lib/mk/libc-locale.mk
|
|
|
|
@@ -6,7 +6,7 @@ CC_OPT += -D_Thread_local=""
|
|
|
|
FILTER_OUT = \
|
|
|
|
c16rtomb.c c32rtomb_iconv.c mbrtoc16_iconv.c mbrtoc32_iconv.c \
|
|
|
|
setlocale.c xlocale.c setrunelocale.c \
|
|
|
|
- ascii.c big5.c euc.co gb18030.c gb2312.c gbk.c mbsinit.c mskanji.c utf8.c \
|
|
|
|
+ ascii.c big5.c euc.co gb18030.c gb2312.c gbk.c mskanji.c utf8.c \
|
2020-12-02 17:30:43 +01:00
|
|
|
|
2020-05-07 21:45:55 +02:00
|
|
|
SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(LIBC_LOCALE_DIR)/*.c)))
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
--
|
|
|
|
2.29.2
|
2020-11-28 18:56:21 +01:00
|
|
|
|
2020-05-27 14:25:32 +02:00
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
From 98d8ef8e3fa37076fab524b6830229f347c89feb Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Wed, 27 May 2020 16:35:16 +0530
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 3/8] libc: add mlock and munlock dummies
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
---
|
|
|
|
repos/libports/src/lib/libc/dummies.cc | 10 ++++++++++
|
|
|
|
1 file changed, 10 insertions(+)
|
2020-05-27 14:25:32 +02:00
|
|
|
|
|
|
|
diff --git a/repos/libports/src/lib/libc/dummies.cc b/repos/libports/src/lib/libc/dummies.cc
|
2020-12-02 17:30:43 +01:00
|
|
|
index b01d95f717..f676b4979c 100644
|
2020-05-27 14:25:32 +02:00
|
|
|
--- a/repos/libports/src/lib/libc/dummies.cc
|
|
|
|
+++ b/repos/libports/src/lib/libc/dummies.cc
|
2020-12-02 17:30:43 +01:00
|
|
|
@@ -218,5 +218,15 @@ int __attribute__((weak)) madvise(void *addr, size_t length, int advice)
|
|
|
|
|
2020-05-27 14:25:32 +02:00
|
|
|
const struct res_sym __p_type_syms[] = { };
|
2020-12-02 17:30:43 +01:00
|
|
|
|
2020-05-27 14:25:32 +02:00
|
|
|
+#define DUMMY_EPERM(ret_type, ret_val, name, args) __attribute__((weak)) \
|
|
|
|
+ret_type name args \
|
|
|
|
+{ \
|
|
|
|
+ errno = EPERM; \
|
|
|
|
+ return ret_val; \
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+DUMMY_EPERM(int, -1, mlock, (const void *, size_t));
|
|
|
|
+DUMMY_EPERM(int, -1, munlock, (const void *, size_t));
|
|
|
|
+
|
|
|
|
} /* extern "C" */
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|
2020-11-28 18:56:21 +01:00
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
From a17d8387a9bbc7d340ed42cfcdc0adedce16f4dd Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Fri, 29 May 2020 09:26:50 +0530
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 4/8] libc: return 0 from getpgrp and getppid dummies
|
2020-05-29 05:59:28 +02:00
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
---
|
|
|
|
repos/libports/src/lib/libc/dummies.cc | 4 ++--
|
|
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
2020-05-29 05:59:28 +02:00
|
|
|
|
|
|
|
diff --git a/repos/libports/src/lib/libc/dummies.cc b/repos/libports/src/lib/libc/dummies.cc
|
2020-12-02 17:30:43 +01:00
|
|
|
index f676b4979c..9c568dcc77 100644
|
2020-05-29 05:59:28 +02:00
|
|
|
--- a/repos/libports/src/lib/libc/dummies.cc
|
|
|
|
+++ b/repos/libports/src/lib/libc/dummies.cc
|
|
|
|
@@ -109,8 +109,8 @@ DUMMY(char *, 0, _getlogin, (void))
|
|
|
|
DUMMY(int , -1, getnameinfo, (const sockaddr *, socklen_t, char *, size_t, char *, size_t, int))
|
|
|
|
DUMMY(struct servent *, 0, getservbyname, (const char *, const char *))
|
|
|
|
DUMMY(int , -1, getsid, (pid_t))
|
|
|
|
-DUMMY_SILENT(pid_t , -1, getppid, (void))
|
|
|
|
-DUMMY(pid_t , -1, getpgrp, (void))
|
|
|
|
+DUMMY_SILENT(pid_t , 0, getpgrp, (void))
|
|
|
|
+DUMMY_SILENT(pid_t , 0, getppid, (void))
|
|
|
|
DUMMY(int , -1, getpriority, (int, int))
|
|
|
|
DUMMY(int , -1, getrusage, (int, rusage *))
|
|
|
|
DUMMY_SILENT(uid_t , 0, getuid, (void))
|
2020-12-02 17:30:43 +01:00
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From 9f3375cdca705e3271f209de76beb19354a150e8 Mon Sep 17 00:00:00 2001
|
2020-11-23 01:21:38 +01:00
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Thu, 26 Nov 2020 12:47:30 +0100
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 5/8] libc: always set argv and envp to valid arrays
|
2020-11-23 01:21:38 +01:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
2020-11-28 18:56:21 +01:00
|
|
|
The arrays passed to main(…) must always be valid null-terminated arrays.
|
2020-11-23 01:21:38 +01:00
|
|
|
|
|
|
|
Fix #3955
|
|
|
|
---
|
2020-11-28 18:56:21 +01:00
|
|
|
repos/libports/include/libc/args.h | 19 +++++++++++++++----
|
|
|
|
1 file changed, 15 insertions(+), 4 deletions(-)
|
2020-11-23 01:21:38 +01:00
|
|
|
|
|
|
|
diff --git a/repos/libports/include/libc/args.h b/repos/libports/include/libc/args.h
|
2020-11-28 18:56:21 +01:00
|
|
|
index 76645d82cb..ca9a8fd38a 100644
|
2020-11-23 01:21:38 +01:00
|
|
|
--- a/repos/libports/include/libc/args.h
|
|
|
|
+++ b/repos/libports/include/libc/args.h
|
|
|
|
@@ -25,6 +25,7 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
|
|
|
{
|
|
|
|
using Genode::Xml_node;
|
|
|
|
using Genode::Xml_attribute;
|
|
|
|
+ using Genode::max;
|
|
|
|
|
|
|
|
env.config([&] (Xml_node const &node) {
|
|
|
|
|
2020-11-28 18:56:21 +01:00
|
|
|
@@ -40,12 +41,20 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
2020-11-23 01:21:38 +01:00
|
|
|
++envc;
|
|
|
|
});
|
|
|
|
|
|
|
|
- if (argc == 0 && envc == 0)
|
|
|
|
+ if (argc == 0 && envc == 0) {
|
|
|
|
+ /*
|
|
|
|
+ * If argc is zero then argv is still a NULL-terminated array.
|
|
|
|
+ */
|
2020-11-28 18:56:21 +01:00
|
|
|
+ static char const *args[] = { nullptr, nullptr };
|
2020-11-23 01:21:38 +01:00
|
|
|
+ argc = 0;
|
|
|
|
+ argv = (char**)&args;
|
|
|
|
+ envp = &argv[1];
|
|
|
|
return; /* from lambda */
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- /* arguments and environment are a contiguous array (but don't count on it) */
|
|
|
|
- argv = (char**)malloc((argc + envc + 1) * sizeof(char*));
|
|
|
|
- envp = &argv[argc];
|
|
|
|
+ /* arguments and environment are arranged System V style (but don't count on it) */
|
2020-11-28 18:56:21 +01:00
|
|
|
+ argv = (char**)malloc((argc + envc + 2) * sizeof(char*));
|
2020-11-23 01:21:38 +01:00
|
|
|
+ envp = &argv[argc+1];
|
|
|
|
|
|
|
|
/* read the arguments */
|
|
|
|
int arg_i = 0;
|
2020-11-28 18:56:21 +01:00
|
|
|
@@ -123,6 +132,8 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
2020-11-23 01:21:38 +01:00
|
|
|
catch (Xml_node::Nonexistent_attribute) { }
|
|
|
|
});
|
|
|
|
|
|
|
|
+ /* argv and envp are both NULL terminated */
|
|
|
|
+ argv[arg_i] = NULL;
|
|
|
|
envp[env_i] = NULL;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
From dd89c66247bf751c87b09fffc7af15c04a59fd91 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Wed, 2 Dec 2020 16:31:59 +0100
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 6/8] libc: implement if_nametoindex
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
---
|
|
|
|
.../libports/src/lib/libc/socket_fs_plugin.cc | 50 ++++++++++++++++++-
|
|
|
|
1 file changed, 49 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/repos/libports/src/lib/libc/socket_fs_plugin.cc b/repos/libports/src/lib/libc/socket_fs_plugin.cc
|
|
|
|
index d5db46ff83..fabaf68b5c 100644
|
|
|
|
--- a/repos/libports/src/lib/libc/socket_fs_plugin.cc
|
|
|
|
+++ b/repos/libports/src/lib/libc/socket_fs_plugin.cc
|
|
|
|
@@ -33,6 +33,8 @@
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <sys/socket.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
/* libc-internal includes */
|
|
|
|
@@ -1128,7 +1130,53 @@ extern "C" int getifaddrs(struct ifaddrs **ifap)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-extern "C" void freeifaddrs(struct ifaddrs *) { }
|
|
|
|
+extern "C" void freeifaddrs(struct ifaddrs *)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static char const * static_if_name = "eth0";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+extern "C" unsigned int
|
|
|
|
+if_nametoindex(const char *ifname)
|
|
|
|
+{
|
|
|
|
+ return ::strcmp(ifname, static_if_name) ? 0 : 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+extern "C" char *
|
|
|
|
+if_indextoname(unsigned int ifindex, char *ifname)
|
|
|
|
+{
|
|
|
|
+ if (ifindex == 1) {
|
|
|
|
+ strncpy(ifname, static_if_name, IFNAMSIZ);
|
|
|
|
+ return ifname;
|
|
|
|
+ }
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+extern "C" struct if_nameindex *
|
|
|
|
+if_nameindex(void)
|
|
|
|
+{
|
|
|
|
+ static struct if_nameindex if_ni_array[2] = {
|
|
|
|
+ {
|
|
|
|
+ .if_index = 1,
|
|
|
|
+ .if_name = (char *)static_if_name
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ .if_index = 0,
|
|
|
|
+ .if_name = NULL
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return if_ni_array;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+extern "C" void if_freenameindex(struct if_nameindex *ptr)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From 1f249e18ea3972911c1405deb40afd85b8d64dea Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Thu, 4 Jun 2020 01:03:37 +0530
|
2020-12-03 12:23:19 +01:00
|
|
|
Subject: [PATCH 7/8] libc: add readpassphrase
|
2020-12-02 17:30:43 +01:00
|
|
|
|
|
|
|
This symbol is already in the stub library.
|
|
|
|
---
|
|
|
|
repos/libports/lib/mk/libc-gen.inc | 1 -
|
|
|
|
1 file changed, 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/repos/libports/lib/mk/libc-gen.inc b/repos/libports/lib/mk/libc-gen.inc
|
|
|
|
index ab0ce929aa..1c7f84e800 100644
|
|
|
|
--- a/repos/libports/lib/mk/libc-gen.inc
|
|
|
|
+++ b/repos/libports/lib/mk/libc-gen.inc
|
|
|
|
@@ -40,7 +40,6 @@ FILTER_OUT_C += \
|
|
|
|
getentropy.c \
|
|
|
|
getutxent.c \
|
|
|
|
pututxline.c \
|
|
|
|
- readpassphrase.c \
|
|
|
|
scandir_b.c \
|
|
|
|
sem_new.c \
|
|
|
|
signal.c \
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|
2020-12-03 12:23:19 +01:00
|
|
|
|
|
|
|
From 708d1c11c1954636df4eef2efde8f1a5cc4afa7e Mon Sep 17 00:00:00 2001
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
Date: Wed, 2 Dec 2020 22:27:00 +0100
|
|
|
|
Subject: [PATCH 8/8] libc: replace strange errno values for O_NOFOLLOW
|
|
|
|
|
|
|
|
Do not replace ENOENT and EEXIST with ELOOP when open is called with
|
|
|
|
O_NOFOLLOW.
|
|
|
|
---
|
|
|
|
repos/libports/src/lib/libc/vfs_plugin.cc | 16 ----------------
|
|
|
|
1 file changed, 16 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc
|
|
|
|
index 0947e44740..3b34c134f8 100644
|
|
|
|
--- a/repos/libports/src/lib/libc/vfs_plugin.cc
|
|
|
|
+++ b/repos/libports/src/lib/libc/vfs_plugin.cc
|
|
|
|
@@ -319,10 +319,6 @@ Libc::File_descriptor *Libc::Vfs_plugin::open_from_kernel(const char *path, int
|
|
|
|
case Result::OPEN_ERR_UNACCESSIBLE:
|
|
|
|
{
|
|
|
|
if (!(flags & O_CREAT)) {
|
|
|
|
- if (flags & O_NOFOLLOW) {
|
|
|
|
- errno = ELOOP;
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
errno = ENOENT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
@@ -336,10 +332,6 @@ Libc::File_descriptor *Libc::Vfs_plugin::open_from_kernel(const char *path, int
|
|
|
|
case Result::OPEN_ERR_EXISTS:
|
|
|
|
|
|
|
|
/* file has been created by someone else in the meantime */
|
|
|
|
- if (flags & O_NOFOLLOW) {
|
|
|
|
- errno = ELOOP;
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
errno = EEXIST;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
@@ -451,10 +443,6 @@ Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags)
|
|
|
|
case Result::OPEN_ERR_UNACCESSIBLE:
|
|
|
|
{
|
|
|
|
if (!(flags & O_CREAT)) {
|
|
|
|
- if (flags & O_NOFOLLOW) {
|
|
|
|
- result_errno = ELOOP;
|
|
|
|
- return Fn::COMPLETE;
|
|
|
|
- }
|
|
|
|
result_errno = ENOENT;
|
|
|
|
return Fn::COMPLETE;
|
|
|
|
}
|
|
|
|
@@ -468,10 +456,6 @@ Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags)
|
|
|
|
case Result::OPEN_ERR_EXISTS:
|
|
|
|
|
|
|
|
/* file has been created by someone else in the meantime */
|
|
|
|
- if (flags & O_NOFOLLOW) {
|
|
|
|
- result_errno = ELOOP;
|
|
|
|
- return Fn::COMPLETE;
|
|
|
|
- }
|
|
|
|
result_errno = EEXIST;
|
|
|
|
return Fn::COMPLETE;
|
|
|
|
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
|