1/*
2 * Copyright (c) 2004-2005 Todd C. Miller <Todd.Miller@courtesan.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include <config.h>
18
19#include <sys/types.h>
20
21#include <errno.h>
22#ifndef HAVE_STRUCT_TIMESPEC
23# include <time.h>
24#endif
25#ifdef __STDC__
26# include <stdarg.h>
27#else
28# include <varargs.h>
29#endif
30#ifdef HAVE_SPAWN_H
31# include <spawn.h>
32#endif
33
34#include "missing.h"
35
36/*
37 * Dummy versions of the execve() family of syscalls.  We don't need
38 * to stub out all of them, just the ones that correspond to actual
39 * system calls (which varies by OS).  Note that it is still possible
40 * to access the real syscalls via the syscall() interface but very
41 * few programs actually do that.
42 */
43
44#define DUMMY_BODY				\
45{						\
46    errno = EACCES;				\
47    return -1;					\
48}
49
50#ifdef __STDC__
51
52#define DUMMY2(fn, t1, t2)			\
53int						\
54fn(t1 a1, t2 a2)				\
55DUMMY_BODY
56
57#define DUMMY3(fn, t1, t2, t3)			\
58int						\
59fn(t1 a1, t2 a2, t3 a3)				\
60DUMMY_BODY
61
62#define DUMMY6(fn, t1, t2, t3, t4, t5, t6)	\
63int						\
64fn(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6)	\
65DUMMY_BODY
66
67#define DUMMY_VA(fn, t1, t2)			\
68int						\
69fn(t1 a1, t2 a2, ...)				\
70DUMMY_BODY
71
72#else /* !__STDC__ */
73
74#define DUMMY2(fn, t1, t2)			\
75int						\
76fn(a1, a2)					\
77t1 a1; t2 a2;					\
78DUMMY_BODY
79
80#define DUMMY3(fn, t1, t2, t3)			\
81int						\
82fn(a1, a2, a3)					\
83t1 a1; t2 a2; t3 a3;				\
84DUMMY_BODY
85
86#define DUMMY_VA(fn, t1, t2)			\
87int						\
88fn(a1, a2, va_alist)				\
89t1 a1; t2 a2; va_dcl				\
90DUMMY_BODY
91
92#endif /* !__STDC__ */
93
94DUMMY_VA(execl, const char *, const char *)
95DUMMY_VA(_execl, const char *, const char *)
96DUMMY_VA(__execl, const char *, const char *)
97DUMMY_VA(execle, const char *, const char *)
98DUMMY_VA(_execle, const char *, const char *)
99DUMMY_VA(__execle, const char *, const char *)
100DUMMY_VA(execlp, const char *, const char *)
101DUMMY_VA(_execlp, const char *, const char *)
102DUMMY_VA(__execlp, const char *, const char *)
103DUMMY3(exect, const char *, char * const *, char * const *)
104DUMMY3(_exect, const char *, char * const *, char * const *)
105DUMMY3(__exect, const char *, char * const *, char * const *)
106DUMMY2(execv, const char *, char * const *)
107DUMMY2(_execv, const char *, char * const *)
108DUMMY2(__execv, const char *, char * const *)
109DUMMY2(execvp, const char *, char * const *)
110DUMMY2(_execvp, const char *, char * const *)
111DUMMY2(__execvp, const char *, char * const *)
112DUMMY3(execvP, const char *, const char *, char * const *)
113DUMMY3(_execvP, const char *, const char *, char * const *)
114DUMMY3(__execvP, const char *, const char *, char * const *)
115DUMMY3(execve, const char *, char * const *, char * const *)
116DUMMY3(_execve, const char *, char * const *, char * const *)
117DUMMY3(__execve, const char *, char * const *, char * const *)
118DUMMY3(execvpe, const char *, char * const *, char * const *)
119DUMMY3(_execvpe, const char *, char * const *, char * const *)
120DUMMY3(__execvpe, const char *, char * const *, char * const *)
121DUMMY3(fexecve, int , char * const *, char * const *)
122DUMMY3(_fexecve, int , char * const *, char * const *)
123DUMMY3(__fexecve, int , char * const *, char * const *)
124#ifdef HAVE_SPAWN_H
125DUMMY6(posix_spawn, pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *, char * const *, char * const *)
126DUMMY6(_posix_spawn, pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *, char * const *, char * const *)
127DUMMY6(__posix_spawn, pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *, char * const *, char * const *)
128DUMMY6(posix_spawnp, pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *, char * const *, char * const *)
129DUMMY6(_posix_spawnp, pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *, char * const *, char * const *)
130DUMMY6(__posix_spawnp, pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *, char * const *, char * const *)
131#endif /* HAVE_SPAWN_H */
132