Annotation of src/usr.bin/sudo/sudo_noexec.c, Revision 1.2
1.1 millert 1: /*
1.2 ! millert 2: * Copyright (c) 2004-2005 Todd C. Miller <Todd.Miller@courtesan.com>
1.1 millert 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>
1.2 ! millert 20: #ifdef __STDC__
! 21: # include <stdarg.h>
! 22: #else
! 23: # include <varargs.h>
! 24: #endif
1.1 millert 25:
26: #ifndef lint
1.2 ! millert 27: static const char rcsid[] = "$Sudo: sudo_noexec.c,v 1.11 2005/03/10 15:09:28 millert Exp $";
1.1 millert 28: #endif /* lint */
29:
30: /*
31: * Dummy versions of the execve() family of syscalls. We don't need
32: * to stub out all of them, just the ones that correspond to actual
33: * system calls (which varies by OS). Note that it is still possible
34: * to access the real syscalls via the syscall() interface but very
35: * few programs actually do that.
36: */
37:
38: #ifndef errno
39: extern int errno;
40: #endif
41:
1.2 ! millert 42: #define DUMMY_BODY \
! 43: { \
! 44: errno = EACCES; \
! 45: return(-1); \
1.1 millert 46: }
47:
1.2 ! millert 48: #ifdef __STDC__
! 49:
! 50: #define DUMMY2(fn, t1, t2) \
! 51: int \
! 52: fn(t1 a1, t2 a2) \
! 53: DUMMY_BODY
! 54:
! 55: #define DUMMY3(fn, t1, t2, t3) \
! 56: int \
! 57: fn(t1 a1, t2 a2, t3 a3) \
! 58: DUMMY_BODY
! 59:
! 60: #define DUMMY_VA(fn, t1, t2) \
! 61: int \
! 62: fn(t1 a1, t2 a2, ...) \
! 63: DUMMY_BODY
! 64:
! 65: #else /* !__STDC__ */
! 66:
! 67: #define DUMMY2(fn, t1, t2) \
! 68: int \
! 69: fn(a1, a2) \
! 70: t1 a1; t2 a2; \
! 71: DUMMY_BODY
! 72:
! 73: #define DUMMY3(fn, t1, t2, t3) \
! 74: int \
! 75: fn(a1, a2, a3) \
! 76: t1 a1; t2 a2; t3 a3; \
! 77: DUMMY_BODY
! 78:
! 79: #define DUMMY_VA(fn, t1, t2) \
! 80: int \
! 81: fn(a1, a2, va_alist) \
! 82: t1 a1; t2 a2; va_dcl \
! 83: DUMMY_BODY
! 84:
! 85: #endif /* !__STDC__ */
! 86:
! 87: DUMMY_VA(execl, const char *, const char *)
! 88: DUMMY_VA(_execl, const char *, const char *)
! 89: DUMMY_VA(__execl, const char *, const char *)
! 90: DUMMY_VA(execle, const char *, const char *)
! 91: DUMMY_VA(_execle, const char *, const char *)
! 92: DUMMY_VA(__execle, const char *, const char *)
! 93: DUMMY_VA(execlp, const char *, const char *)
! 94: DUMMY_VA(_execlp, const char *, const char *)
! 95: DUMMY_VA(__execlp, const char *, const char *)
! 96: DUMMY2(execv, const char *, char * const *)
! 97: DUMMY2(_execv, const char *, char * const *)
! 98: DUMMY2(__execv, const char *, char * const *)
! 99: DUMMY2(execvp, const char *, char * const *)
! 100: DUMMY2(_execvp, const char *, char * const *)
! 101: DUMMY2(__execvp, const char *, char * const *)
! 102: DUMMY3(execvP, const char *, const char *, char * const *)
! 103: DUMMY3(_execvP, const char *, const char *, char * const *)
! 104: DUMMY3(__execvP, const char *, const char *, char * const *)
! 105: DUMMY3(execve, const char *, char * const *, char * const *)
! 106: DUMMY3(_execve, const char *, char * const *, char * const *)
! 107: DUMMY3(__execve, const char *, char * const *, char * const *)
! 108: DUMMY3(fexecve, int , char * const *, char * const *)
! 109: DUMMY3(_fexecve, int , char * const *, char * const *)
! 110: DUMMY3(__fexecve, int , char * const *, char * const *)