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