feat: ports - git port
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
diff --git a/common-main.c b/common-main.c
|
||||
index 0a22861f1..4653d18b5 100644
|
||||
--- a/common-main.c
|
||||
+++ b/common-main.c
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "cache.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "attr.h"
|
||||
+#include <montauk-init.h>
|
||||
|
||||
/*
|
||||
* Many parts of Git have subprograms communicate via pipe, expect the
|
||||
@@ -28,6 +29,13 @@ int main(int argc, const char **argv)
|
||||
int result;
|
||||
struct strbuf tmp = STRBUF_INIT;
|
||||
|
||||
+ /*
|
||||
+ * MontaukOS: fill in what the process environment cannot carry
|
||||
+ * (HOME). Must run before any config is read. See
|
||||
+ * compat/montauk-compat.c in the port.
|
||||
+ */
|
||||
+ montauk_startup();
|
||||
+
|
||||
trace2_initialize_clock();
|
||||
|
||||
/*
|
||||
@@ -0,0 +1,30 @@
|
||||
diff --git a/setup.c b/setup.c
|
||||
index c3301f5ab..6652c1dff 100644
|
||||
--- a/setup.c
|
||||
+++ b/setup.c
|
||||
@@ -1691,11 +1691,20 @@ const char *resolve_gitdir_gently(const char *suspect, int *return_error_code)
|
||||
/* if any standard file descriptor is missing open it to /dev/null */
|
||||
void sanitize_stdfds(void)
|
||||
{
|
||||
- int fd = xopen("/dev/null", O_RDWR);
|
||||
- while (fd < 2)
|
||||
- fd = xdup(fd);
|
||||
- if (fd > 2)
|
||||
- close(fd);
|
||||
+ /*
|
||||
+ * MontaukOS: nothing to sanitize, and nothing to sanitize it with.
|
||||
+ *
|
||||
+ * This guards against being started with 0/1/2 closed, so that a
|
||||
+ * later open() cannot land on a standard descriptor and have die()
|
||||
+ * write its message into a data file. On MontaukOS that cannot
|
||||
+ * happen: the kernel gives every process the terminal on 0/1/2 (the
|
||||
+ * libc routes those descriptors to SYS_PUTCHAR/SYS_GETCHAR rather
|
||||
+ * than to any handle), and a process is spawned, never forked with a
|
||||
+ * doctored descriptor table.
|
||||
+ *
|
||||
+ * The upstream body cannot run in any case -- there is no /dev/null,
|
||||
+ * so xopen() would die here and take every git invocation with it.
|
||||
+ */
|
||||
}
|
||||
|
||||
int daemonize(void)
|
||||
Reference in New Issue
Block a user