note bug fixed in new upstream
[debian/sudo] / src / sudo_noexec.c
1 /*
2  * Copyright (c) 2004-2005, 2010-2011 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_TIMESPEC
23 # include <time.h>
24 #endif
25 #include <stdarg.h>
26
27 #include "missing.h"
28
29 /*
30  * Dummy versions of the execve() family of syscalls.  We don't need
31  * to stub out all of them, just the ones that correspond to actual
32  * system calls (which varies by OS).  Note that it is still possible
33  * to access the real syscalls via the syscall() interface but very
34  * few programs actually do that.
35  */
36
37 #ifndef errno
38 extern int errno;
39 #endif
40
41 #define DUMMY_BODY                              \
42 {                                               \
43     errno = EACCES;                             \
44     return -1;                                  \
45 }
46
47 #define DUMMY2(fn, t1, t2)                      \
48 int                                             \
49 fn(t1 a1, t2 a2)                                \
50 DUMMY_BODY
51
52 #define DUMMY3(fn, t1, t2, t3)                  \
53 int                                             \
54 fn(t1 a1, t2 a2, t3 a3)                         \
55 DUMMY_BODY
56
57 #define DUMMY_VA(fn, t1, t2)                    \
58 int                                             \
59 fn(t1 a1, t2 a2, ...)                           \
60 DUMMY_BODY
61
62 DUMMY_VA(execl, const char *, const char *)
63 DUMMY_VA(_execl, const char *, const char *)
64 DUMMY_VA(__execl, const char *, const char *)
65 DUMMY_VA(execle, const char *, const char *)
66 DUMMY_VA(_execle, const char *, const char *)
67 DUMMY_VA(__execle, const char *, const char *)
68 DUMMY_VA(execlp, const char *, const char *)
69 DUMMY_VA(_execlp, const char *, const char *)
70 DUMMY_VA(__execlp, const char *, const char *)
71 DUMMY2(execv, const char *, char * const *)
72 DUMMY2(_execv, const char *, char * const *)
73 DUMMY2(__execv, const char *, char * const *)
74 DUMMY2(execvp, const char *, char * const *)
75 DUMMY2(_execvp, const char *, char * const *)
76 DUMMY2(__execvp, const char *, char * const *)
77 DUMMY3(execvP, const char *, const char *, char * const *)
78 DUMMY3(_execvP, const char *, const char *, char * const *)
79 DUMMY3(__execvP, const char *, const char *, char * const *)
80 DUMMY3(execve, const char *, char * const *, char * const *)
81 DUMMY3(_execve, const char *, char * const *, char * const *)
82 DUMMY3(__execve, const char *, char * const *, char * const *)
83 DUMMY3(fexecve, int , char * const *, char * const *)
84 DUMMY3(_fexecve, int , char * const *, char * const *)
85 DUMMY3(__fexecve, int , char * const *, char * const *)