|
version 1.1, 2012/02/21 16:23:02
|
version 1.1.1.6, 2014/06/15 16:12:55
|
|
Line 1
|
Line 1
|
| /* |
/* |
| * Copyright (c) 1993-1996, 1998-2005, 2007-2011 | * Copyright (c) 1993-1996, 1998-2005, 2007-2013 |
| * Todd C. Miller <Todd.Miller@courtesan.com> |
* Todd C. Miller <Todd.Miller@courtesan.com> |
| * |
* |
| * Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
|
Line 17
|
Line 17
|
| * Sponsored in part by the Defense Advanced Research Projects |
* Sponsored in part by the Defense Advanced Research Projects |
| * Agency (DARPA) and Air Force Research Laboratory, Air Force |
* Agency (DARPA) and Air Force Research Laboratory, Air Force |
| * Materiel Command, USAF, under agreement number F39502-99-1-0512. |
* Materiel Command, USAF, under agreement number F39502-99-1-0512. |
| * |
|
| * $Sudo: sudo.h,v 1.290 2009/12/12 16:12:26 millert Exp $ |
|
| */ |
*/ |
| |
|
| #ifndef _SUDO_SUDO_H |
#ifndef _SUDO_SUDO_H |
|
Line 26
|
Line 24
|
| |
|
| #include <limits.h> |
#include <limits.h> |
| #include <pathnames.h> |
#include <pathnames.h> |
| |
#ifdef HAVE_STDBOOL_H |
| |
# include <stdbool.h> |
| |
#else |
| |
# include "compat/stdbool.h" |
| |
#endif /* HAVE_STDBOOL_H */ |
| |
|
| |
#include "gettext.h" /* must be included before missing.h */ |
| |
|
| #include "missing.h" |
#include "missing.h" |
| #include "alloc.h" |
#include "alloc.h" |
| #include "error.h" | #include "fatal.h" |
| #include "fileops.h" |
#include "fileops.h" |
| #include "list.h" | #include "sudo_conf.h" |
| #include "gettext.h" | #include "sudo_debug.h" |
| | #include "sudo_util.h" |
| |
|
| |
#ifdef HAVE_PRIV_SET |
| |
# include <priv.h> |
| |
#endif |
| |
|
| #ifdef __TANDEM |
#ifdef __TANDEM |
| # define ROOT_UID 65535 | # define ROOT_UID 65535 |
| #else |
#else |
| # define ROOT_UID 0 | # define ROOT_UID 0 |
| #endif |
#endif |
| |
|
| /* |
/* |
| * Pseudo-boolean values |
|
| */ |
|
| #undef TRUE |
|
| #define TRUE 1 |
|
| #undef FALSE |
|
| #define FALSE 0 |
|
| |
|
| /* |
|
| * Various modes sudo can be in (based on arguments) in hex |
* Various modes sudo can be in (based on arguments) in hex |
| */ |
*/ |
| #define MODE_RUN 0x00000001 |
#define MODE_RUN 0x00000001 |
|
Line 75
|
Line 77
|
| #define MODE_LONG_LIST 0x01000000 |
#define MODE_LONG_LIST 0x01000000 |
| |
|
| /* |
/* |
| * We used to use the system definition of PASS_MAX or _PASSWD_LEN, |
|
| * but that caused problems with various alternate authentication |
|
| * methods. So, we just define our own and assume that it is >= the |
|
| * system max. |
|
| */ |
|
| #define SUDO_PASS_MAX 256 |
|
| |
|
| /* |
|
| * Flags for tgetpass() |
* Flags for tgetpass() |
| */ |
*/ |
| #define TGP_NOECHO 0x00 /* turn echo off reading pw (default) */ |
#define TGP_NOECHO 0x00 /* turn echo off reading pw (default) */ |
|
Line 93
|
Line 87
|
| #define TGP_NOECHO_TRY 0x10 /* turn off echo if possible */ |
#define TGP_NOECHO_TRY 0x10 /* turn off echo if possible */ |
| |
|
| struct user_details { |
struct user_details { |
| |
pid_t pid; |
| |
pid_t ppid; |
| |
pid_t pgid; |
| |
pid_t tcpgid; |
| |
pid_t sid; |
| uid_t uid; |
uid_t uid; |
| uid_t euid; |
uid_t euid; |
| uid_t gid; |
uid_t gid; |
|
Line 122 struct user_details {
|
Line 121 struct user_details {
|
| #define CD_RBAC_ENABLED 0x0800 |
#define CD_RBAC_ENABLED 0x0800 |
| #define CD_USE_PTY 0x1000 |
#define CD_USE_PTY 0x1000 |
| #define CD_SET_UTMP 0x2000 |
#define CD_SET_UTMP 0x2000 |
| |
#define CD_EXEC_BG 0x4000 |
| |
|
| |
struct preserved_fd { |
| |
TAILQ_ENTRY(preserved_fd) entries; |
| |
int lowfd; |
| |
int highfd; |
| |
int flags; |
| |
}; |
| |
TAILQ_HEAD(preserved_fd_list, preserved_fd); |
| |
|
| struct command_details { |
struct command_details { |
| uid_t uid; |
uid_t uid; |
| uid_t euid; |
uid_t euid; |
|
Line 134 struct command_details {
|
Line 142 struct command_details {
|
| int ngroups; |
int ngroups; |
| int closefrom; |
int closefrom; |
| int flags; |
int flags; |
| |
struct preserved_fd_list preserved_fds; |
| |
struct passwd *pw; |
| GETGROUPS_T *groups; |
GETGROUPS_T *groups; |
| const char *command; |
const char *command; |
| const char *cwd; |
const char *cwd; |
|
Line 144 struct command_details {
|
Line 154 struct command_details {
|
| const char *utmp_user; |
const char *utmp_user; |
| char **argv; |
char **argv; |
| char **envp; |
char **envp; |
| |
#ifdef HAVE_PRIV_SET |
| |
priv_set_t *privs; |
| |
priv_set_t *limitprivs; |
| |
#endif |
| }; |
}; |
| |
|
| /* Status passed between parent and child via socketpair */ |
/* Status passed between parent and child via socketpair */ |
|
Line 152 struct command_status {
|
Line 166 struct command_status {
|
| #define CMD_ERRNO 1 |
#define CMD_ERRNO 1 |
| #define CMD_WSTATUS 2 |
#define CMD_WSTATUS 2 |
| #define CMD_SIGNO 3 |
#define CMD_SIGNO 3 |
| |
#define CMD_PID 4 |
| int type; |
int type; |
| int val; |
int val; |
| }; |
}; |
| |
|
| struct timeval; |
struct timeval; |
| |
|
| /* For error() and errorx() (XXX - needed?) */ | /* For fatal() and fatalx() (XXX - needed?) */ |
| void cleanup(int); |
void cleanup(int); |
| |
|
| /* tgetpass.c */ |
/* tgetpass.c */ |
| char *tgetpass(const char *, int, int); |
char *tgetpass(const char *, int, int); |
| int tty_present(void); |
int tty_present(void); |
| extern const char *askpass_path; |
|
| extern const char *noexec_path; |
|
| |
|
| /* zero_bytes.c */ |
|
| void zero_bytes(volatile void *, size_t); |
|
| |
|
| /* exec.c */ |
/* exec.c */ |
| int sudo_execve(struct command_details *details, struct command_status *cstat); | int pipe_nonblock(int fds[2]); |
| void save_signals(void); | int sudo_execute(struct command_details *details, struct command_status *cstat); |
| void restore_signals(void); | |
| |
|
| /* term.c */ |
|
| int term_cbreak(int); |
|
| int term_copy(int, int); |
|
| int term_noecho(int); |
|
| int term_raw(int, int); |
|
| int term_restore(int, int); |
|
| |
|
| /* fmt_string.h */ |
|
| char *fmt_string(const char *var, const char *value); |
|
| |
|
| /* atobool.c */ |
|
| int atobool(const char *str); |
|
| |
|
| /* parse_args.c */ |
/* parse_args.c */ |
| int parse_args(int argc, char **argv, int *nargc, char ***nargv, |
int parse_args(int argc, char **argv, int *nargc, char ***nargv, |
| char ***settingsp, char ***env_addp); |
char ***settingsp, char ***env_addp); |
|
Line 196 extern int tgetpass_flags;
|
Line 192 extern int tgetpass_flags;
|
| /* get_pty.c */ |
/* get_pty.c */ |
| int get_pty(int *master, int *slave, char *name, size_t namesz, uid_t uid); |
int get_pty(int *master, int *slave, char *name, size_t namesz, uid_t uid); |
| |
|
| /* ttysize.c */ |
|
| void get_ttysize(int *rowp, int *colp); |
|
| |
|
| /* sudo.c */ |
/* sudo.c */ |
| int exec_setup(struct command_details *details, const char *ptyname, int ptyfd); | bool exec_setup(struct command_details *details, const char *ptyname, int ptyfd); |
| | int policy_init_session(struct command_details *details); |
| int run_command(struct command_details *details); |
int run_command(struct command_details *details); |
| void sudo_debug(int level, const char *format, ...) __printflike(2, 3); | int os_init_common(int argc, char *argv[], char *envp[]); |
| extern int debug_level; | extern const char *list_user; |
| extern const char *list_user, *runas_user, *runas_group; | |
| extern struct user_details user_details; |
extern struct user_details user_details; |
| |
|
| /* sudo_edit.c */ |
/* sudo_edit.c */ |
|
Line 213 int sudo_edit(struct command_details *details);
|
Line 206 int sudo_edit(struct command_details *details);
|
| /* parse_args.c */ |
/* parse_args.c */ |
| void usage(int); |
void usage(int); |
| |
|
| |
/* openbsd.c */ |
| |
int os_init_openbsd(int argc, char *argv[], char *envp[]); |
| |
|
| /* selinux.c */ |
/* selinux.c */ |
| int selinux_restore_tty(void); |
int selinux_restore_tty(void); |
| int selinux_setup(const char *role, const char *type, const char *ttyn, |
int selinux_setup(const char *role, const char *type, const char *ttyn, |
| int ttyfd); |
int ttyfd); |
| void selinux_execve(const char *path, char *argv[], char *envp[]); | void selinux_execve(const char *path, char *const argv[], char *const envp[], |
| | int noexec); |
| |
|
| /* aix.c */ | /* solaris.c */ |
| void aix_prep_user(char *user, const char *tty); | void set_project(struct passwd *); |
| void aix_restoreauthdb(void); | int os_init_solaris(int argc, char *argv[], char *envp[]); |
| void aix_setauthdb(char *user); | |
| |
|
| |
/* hooks.c */ |
| |
/* XXX - move to sudo_plugin_int.h? */ |
| |
struct sudo_hook; |
| |
int register_hook(struct sudo_hook *hook); |
| |
int deregister_hook(struct sudo_hook *hook); |
| |
int process_hooks_getenv(const char *name, char **val); |
| |
int process_hooks_setenv(const char *name, const char *value, int overwrite); |
| |
int process_hooks_putenv(char *string); |
| |
int process_hooks_unsetenv(const char *name); |
| |
|
| |
/* env_hooks.c */ |
| |
char *getenv_unhooked(const char *name); |
| |
|
| /* interfaces.c */ |
/* interfaces.c */ |
| int get_net_ifs(char **addrinfo); |
int get_net_ifs(char **addrinfo); |
| |
|
| /* setgroups.c */ | /* ttyname.c */ |
| int sudo_setgroups(int ngids, const GETGROUPS_T *gids); | char *get_process_ttyname(void); |
| | |
| | /* signal.c */ |
| | struct sigaction; |
| | extern int signal_pipe[2]; |
| | int sudo_sigaction(int signo, struct sigaction *sa, struct sigaction *osa); |
| | void init_signals(void); |
| | void restore_signals(void); |
| | void save_signals(void); |
| | |
| | /* preload.c */ |
| | void preload_static_symbols(void); |
| | |
| | /* preserve_fds.c */ |
| | int add_preserved_fd(struct preserved_fd_list *pfds, int fd); |
| | void closefrom_except(int startfd, struct preserved_fd_list *pfds); |
| | void parse_preserved_fds(struct preserved_fd_list *pfds, const char *fdstr); |
| |
|
| #endif /* _SUDO_SUDO_H */ |
#endif /* _SUDO_SUDO_H */ |