blob: 27367e898426b02e07c3ec44b7527dc5085de9ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
diff --git a/src/sudo.c b/src/sudo.c
index 0ed053839..89d97b6e8 100644
--- a/src/sudo.c
+++ b/src/sudo.c
@@ -341,13 +341,48 @@ access_denied:
return EXIT_FAILURE;
}
+/*
+ * Set the time zone using tzset(3), removing the user's TZ
+ * environment variable. The original value of TZ may still
+ * be present in the command's environment, depending on sudoers.
+ */
+static void
+set_time_zone(void)
+{
+ /* Use system time zone, not user-specified. */
+ unsetenv("TZ");
+ (void) tzset();
+}
+
int
os_init_common(int argc, char *argv[], char *envp[])
{
+ extern char **environ;
+ int envc;
#ifdef STATIC_SUDOERS_PLUGIN
preload_static_symbols();
#endif
gc_init();
+
+ /*
+ * Make a copy of environ[] that is distinct from envp[].
+ * This allows us to remove variables from sudo's environment
+ * while still providing the original envp to the plugins.
+ */
+ for (envc = 0; envp[envc] != NULL; envc++)
+ continue;
+ if (envc != 0) {
+ char **new_env = reallocarray(NULL, sizeof(char *), envc + 1);
+ if (new_env == NULL || !gc_add(GC_PTR, new_env)) {
+ sudo_fatalx_nodebug(U_("%s: %s"), __func__,
+ U_("unable to allocate memory"));
+ }
+ for (envc = 0; envp[envc] != NULL; envc++)
+ new_env[envc] = envp[envc];
+ new_env[envc] = NULL;
+ environ = new_env;
+ }
+
return 0;
}
|