f06f03f53a3fb0b55357178d72e5efb0f1304dc4
[debian/sudo] / sudo_noexec.c
1 /*
2  * Copyright (c) 2004 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 <errno.h>
20
21 #ifndef lint
22 static const char rcsid[] = "$Sudo: sudo_noexec.c,v 1.5 2004/02/13 21:36:43 millert Exp $";
23 #endif /* lint */
24
25 /*
26  * Dummy versions of the execve() family of syscalls.  We don't need
27  * to stub out all of them, just the ones that correspond to actual
28  * system calls (which varies by OS).  Note that it is still possible
29  * to access the real syscalls via the syscall() interface but very
30  * few programs actually do that.
31  */
32
33 #ifndef errno
34 extern int errno;
35 #endif
36
37 #define DUMMY(fn, args, atypes) \
38 int                             \
39 fn args                         \
40     atypes                      \
41 {                               \
42     errno = EACCES;             \
43     return(-1);                 \
44 }
45
46 DUMMY(execve, (path, argv, envp),
47       const char *path; char *const argv[]; char *const envp[];)
48 DUMMY(_execve, (path, argv, envp),
49       const char *path; char *const argv[]; char *const envp[];)
50 DUMMY(execv, (path, argv, envp),
51       const char *path; char *const argv[];)
52 DUMMY(_execv, (path, argv, envp),
53       const char *path; char *const argv[];)
54 DUMMY(fexecve, (fd, argv, envp),
55       int fd; char *const argv[]; char *const envp[];)
56 DUMMY(_fexecve, (fd, argv, envp),
57       int fd; char *const argv[]; char *const envp[];)