summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/uclibc/uclibc-git/uclibc-execvpe.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/uclibc/uclibc-git/uclibc-execvpe.patch')
-rw-r--r--meta/recipes-core/uclibc/uclibc-git/uclibc-execvpe.patch160
1 files changed, 160 insertions, 0 deletions
diff --git a/meta/recipes-core/uclibc/uclibc-git/uclibc-execvpe.patch b/meta/recipes-core/uclibc/uclibc-git/uclibc-execvpe.patch
new file mode 100644
index 0000000000..cd90a09205
--- /dev/null
+++ b/meta/recipes-core/uclibc/uclibc-git/uclibc-execvpe.patch
@@ -0,0 +1,160 @@
1From d20556adadea03bff0bba051172caf0314a35471 Mon Sep 17 00:00:00 2001
2From: Henning Heinold <heinold@inf.fu-berlin.de>
3Date: Sat, 4 Jun 2011 21:23:15 +0200
4Subject: [PATCH 2/2] libc: add non standard execvpe function
5
6
7Signed-off-by: Henning Heinold <heinold@inf.fu-berlin.de>
8---
9 include/unistd.h | 6 ++++++
10 libc/unistd/exec.c | 38 +++++++++++++++++++++++++++++++++-----
11 libc/unistd/execvpe.c | 7 +++++++
12 3 files changed, 46 insertions(+), 5 deletions(-)
13 create mode 100644 libc/unistd/execvpe.c
14
15diff --git a/include/unistd.h b/include/unistd.h
16index 9568790..070e4f2 100644
17--- a/include/unistd.h
18+++ b/include/unistd.h
19@@ -557,6 +557,12 @@ extern int execvp (__const char *__file, char *__const __argv[])
20 __THROW __nonnull ((1));
21 libc_hidden_proto(execvp)
22
23+/* Execute FILE, searching in the `PATH' environment variable if it contains
24+ no slashes, with arguments ARGV and environment from a pointer */
25+extern int execvpe (__const char *__file, char *__const __argv[], char *__const __envp[])
26+ __THROW __nonnull ((1));
27+libc_hidden_proto(execvpe)
28+
29 /* Execute FILE, searching in the `PATH' environment variable if
30 it contains no slashes, with all arguments after FILE until a
31 NULL pointer and environment from `environ'. */
32diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c
33index 7d24072..802a174 100644
34--- a/libc/unistd/exec.c
35+++ b/libc/unistd/exec.c
36@@ -32,6 +32,8 @@
37 /**********************************************************************/
38 #define EXEC_FUNC_COMMON 0
39 #define EXEC_FUNC_EXECVP 1
40+#define EXEC_FUNC_EXECVPE 2
41+
42 #if defined(__ARCH_USE_MMU__)
43
44 /* We have an MMU, so use alloca() to grab space for buffers and arg lists. */
45@@ -58,6 +60,7 @@
46 * execle(a) -> execve(-)
47 * execv(-) -> execve(-)
48 * execvp(a) -> execve(-)
49+ * execvpe(a) -> execve(-)
50 */
51
52 # define EXEC_ALLOC_SIZE(VAR) /* nothing to do */
53@@ -219,15 +222,18 @@ libc_hidden_def(execlp)
54
55 #endif
56 /**********************************************************************/
57-#ifdef L_execvp
58+#if defined (L_execvp) || defined(L_execvpe)
59
60
61 /* Use a default path that matches glibc behavior, since SUSv3 says
62 * this is implementation-defined. The default is current working dir,
63 * /bin, and then /usr/bin. */
64 static const char default_path[] = ":/bin:/usr/bin";
65-
66+#if defined (L_execvp)
67 int execvp(const char *path, char *const argv[])
68+#elif defined (L_execvpe)
69+int execvpe(const char *path, char *const argv[], char *const envp[])
70+#endif
71 {
72 char *buf = NULL;
73 char *p;
74@@ -245,7 +251,11 @@ int execvp(const char *path, char *const argv[])
75 }
76
77 if (strchr(path, '/')) {
78+#if defined (L_execvp)
79 execve(path, argv, __environ);
80+#elif defined (L_execvpe)
81+ execve(path, argv, envp);
82+#endif
83 if (errno == ENOEXEC) {
84 char **nargv;
85 EXEC_ALLOC_SIZE(size2) /* Do NOT add a semicolon! */
86@@ -254,11 +264,19 @@ int execvp(const char *path, char *const argv[])
87 /* Need the dimension - 1. We omit counting the trailing
88 * NULL but we actually omit the first entry. */
89 for (n=0 ; argv[n] ; n++) {}
90+#if defined (L_execvp)
91 nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVP);
92+#elif defined (L_execvpe)
93+ nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVPE);
94+#endif
95 nargv[0] = argv[0];
96 nargv[1] = (char *)path;
97 memcpy(nargv+2, argv+1, n*sizeof(char *));
98+#if defined (L_execvp)
99 execve("/bin/sh", nargv, __environ);
100+#elif defined (L_execvpe)
101+ execve("/bin/sh", nargv, envp);
102+#endif
103 EXEC_FREE(nargv, size2);
104 }
105 } else {
106@@ -277,8 +295,11 @@ int execvp(const char *path, char *const argv[])
107 return -1;
108 }
109 len = (FILENAME_MAX - 1) - plen;
110-
111+#if defined (L_execvp)
112 buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVP);
113+#elif defined (L_execvpe)
114+ buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVPE);
115+#endif
116 {
117 int seen_small = 0;
118 s0 = buf + len;
119@@ -300,8 +321,11 @@ int execvp(const char *path, char *const argv[])
120 s[plen-1] = '/';
121 }
122
123+#if defined (L_execvp)
124 execve(s, argv, __environ);
125-
126+#elif defined (L_execvpe)
127+ execve(s, argv, envp);
128+#endif
129 seen_small = 1;
130
131 if (errno == ENOEXEC) {
132@@ -325,7 +349,11 @@ int execvp(const char *path, char *const argv[])
133
134 return -1;
135 }
136+#if defined (L_execvp)
137 libc_hidden_def(execvp)
138-
139+#elif defined (L_execvpe)
140+libc_hidden_def(execvpe)
141 #endif
142+
143+#endif /* #if defined (L_execvp) || defined(L_execvpe) */
144 /**********************************************************************/
145diff --git a/libc/unistd/execvpe.c b/libc/unistd/execvpe.c
146new file mode 100644
147index 0000000..5c1ce06
148--- /dev/null
149+++ b/libc/unistd/execvpe.c
150@@ -0,0 +1,7 @@
151+/* Copyright (C) 2011 Hennning Heinold <heinold@inf.fu-berlin.de>
152+ *
153+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
154+ */
155+
156+#define L_execvpe
157+#include "exec.c"
158--
1591.7.5.3
160