mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-04 05:56:14 +01:00
0e7389fcbd
Signed-off-by: magic_rb <magic_rb@redalder.org>
47 lines
1.5 KiB
Diff
47 lines
1.5 KiB
Diff
From 761f4fdc1165da91d3b758caa853f8a9f6ff61a2 Mon Sep 17 00:00:00 2001
|
|
From: magic_rb <richard@brezak.sk>
|
|
Date: Tue, 6 Aug 2024 19:05:09 +0200
|
|
Subject: [PATCH 2/3] Call scripts with the same environ as pppd
|
|
|
|
Signed-off-by: magic_rb <richard@brezak.sk>
|
|
---
|
|
pppd/main.c | 15 ++++++++++++++-
|
|
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/pppd/main.c b/pppd/main.c
|
|
index de6d6f4..defb002 100644
|
|
--- a/pppd/main.c
|
|
+++ b/pppd/main.c
|
|
@@ -125,6 +125,8 @@
|
|
#include "atcp.h"
|
|
#endif
|
|
|
|
+extern char** environ;
|
|
+
|
|
/* interface vars */
|
|
char ifname[IFNAMSIZ]; /* Interface name */
|
|
int ifunit; /* Interface unit number */
|
|
@@ -1962,7 +1964,18 @@ run_program(char *prog, char * const *args, int must_exist, void (*done)(void *)
|
|
|
|
/* run the program */
|
|
update_script_environment();
|
|
- execve(prog, args, script_env);
|
|
+
|
|
+ /* combine environs */
|
|
+ size_t stock_environ_length = strlen(environ);
|
|
+ size_t script_environ_length = strlen(script_env);
|
|
+ char** combined_environ = calloc(stock_environ_length + script_environ_length + 1, sizeof(*combined_environ));
|
|
+ memcpy(combined_environ, script_env, script_environ_length);
|
|
+ memcpy(combined_environ + script_environ_length, environ, stock_environ_length);
|
|
+
|
|
+ printf("invoking with %ul env vars\n", combined_environ);
|
|
+
|
|
+ execve(prog, args, environ);
|
|
+ free(combined_environ);
|
|
if (must_exist || errno != ENOENT) {
|
|
/* have to reopen the log, there's nowhere else
|
|
for the message to go. */
|
|
--
|
|
2.44.1
|
|
|