[BACK]Return to sudo.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / sudo

Annotation of src/usr.bin/sudo/sudo.h, Revision 1.9

1.1       millert     1: /*
1.7       millert     2:  * Copyright (c) 1993-1996,1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>
1.1       millert     3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  *
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  *
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  *
                     16:  * 3. The name of the author may not be used to endorse or promote products
                     17:  *    derived from this software without specific prior written permission.
                     18:  *
                     19:  * 4. Products derived from this software may not be called "Sudo" nor
                     20:  *    may "Sudo" appear in their names without specific prior written
                     21:  *    permission from the author.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
                     24:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
                     25:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
                     26:  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
                     27:  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     28:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     29:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     30:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     31:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                     32:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     33:  *
1.9     ! millert    34:  * $Sudo: sudo.h,v 1.184 2002/01/16 21:27:09 millert Exp $
1.1       millert    35:  */
                     36:
                     37: #ifndef _SUDO_SUDO_H
                     38: #define _SUDO_SUDO_H
                     39:
                     40: #include <pathnames.h>
                     41: #include "compat.h"
                     42: #include "defaults.h"
                     43: #include "logging.h"
                     44:
                     45: /*
                     46:  * Info pertaining to the invoking user.
                     47:  */
                     48: struct sudo_user {
                     49:     struct passwd *pw;
1.7       millert    50:     struct passwd *_runas_pw;
                     51:     char *path;
                     52:     char *shell;
1.1       millert    53:     char *tty;
                     54:     char  cwd[MAXPATHLEN];
                     55:     char *host;
                     56:     char *shost;
                     57:     char **runas;
                     58:     char *prompt;
                     59:     char *cmnd_safe;
                     60:     char *cmnd;
                     61:     char *cmnd_args;
1.4       millert    62:     char *class_name;
1.1       millert    63: };
                     64:
                     65: /*
                     66:  * Return values for sudoers_lookup(), also used as arguments for log_auth()
                     67:  * Note: cannot use '0' as a value here.
                     68:  */
                     69: /* XXX - VALIDATE_SUCCESS and VALIDATE_FAILURE instead? */
                     70: #define VALIDATE_ERROR          0x01
                     71: #define VALIDATE_OK            0x02
                     72: #define VALIDATE_NOT_OK                0x04
                     73: #define FLAG_NOPASS            0x10
                     74: #define FLAG_NO_USER           0x20
                     75: #define FLAG_NO_HOST           0x40
                     76: #define FLAG_NO_CHECK          0x80
                     77:
                     78: /*
                     79:  * Boolean values
                     80:  */
                     81: #undef TRUE
                     82: #define TRUE                     1
                     83: #undef FALSE
                     84: #define FALSE                    0
                     85:
                     86: /*
                     87:  * find_path()/load_cmnd() return values
                     88:  */
                     89: #define FOUND                    1
                     90: #define NOT_FOUND                0
                     91: #define NOT_FOUND_DOT          -1
                     92:
                     93: /*
                     94:  * Various modes sudo can be in (based on arguments) in octal
                     95:  */
1.7       millert    96: #define MODE_RUN                 000001
                     97: #define MODE_VALIDATE            000002
                     98: #define MODE_INVALIDATE          000004
                     99: #define MODE_KILL                000010
                    100: #define MODE_VERSION             000020
                    101: #define MODE_HELP                000040
                    102: #define MODE_LIST                000100
                    103: #define MODE_LISTDEFS            000200
                    104: #define MODE_BACKGROUND          000400
                    105: #define MODE_SHELL               001000
                    106: #define MODE_IMPLIED_SHELL       002000
                    107: #define MODE_RESET_HOME          004000
                    108: #define MODE_PRESERVE_GROUPS     010000
1.1       millert   109:
                    110: /*
                    111:  * Used with set_perms()
                    112:  */
                    113: #define PERM_ROOT                0x00
1.8       millert   114: #define PERM_FULL_ROOT           0x01
                    115: #define PERM_USER                0x02
1.9     ! millert   116: #define PERM_FULL_USER           0x03
        !           117: #define PERM_SUDOERS             0x04
        !           118: #define PERM_RUNAS               0x05
1.1       millert   119:
                    120: /*
                    121:  * Shortcuts for sudo_user contents.
                    122:  */
                    123: #define user_name              (sudo_user.pw->pw_name)
                    124: #define user_passwd            (sudo_user.pw->pw_passwd)
                    125: #define user_uid               (sudo_user.pw->pw_uid)
                    126: #define user_gid               (sudo_user.pw->pw_gid)
                    127: #define user_dir               (sudo_user.pw->pw_dir)
1.7       millert   128: #define user_shell             (sudo_user.shell)
1.1       millert   129: #define user_tty               (sudo_user.tty)
                    130: #define user_cwd               (sudo_user.cwd)
                    131: #define user_runas             (sudo_user.runas)
                    132: #define user_cmnd              (sudo_user.cmnd)
                    133: #define user_args              (sudo_user.cmnd_args)
1.7       millert   134: #define user_path              (sudo_user.path)
1.1       millert   135: #define user_prompt            (sudo_user.prompt)
                    136: #define user_host              (sudo_user.host)
                    137: #define user_shost             (sudo_user.shost)
                    138: #define safe_cmnd              (sudo_user.cmnd_safe)
1.4       millert   139: #define login_class            (sudo_user.class_name)
1.7       millert   140: #define runas_pw               (sudo_user._runas_pw)
1.1       millert   141:
                    142: /*
                    143:  * We used to use the system definition of PASS_MAX or _PASSWD_LEN,
                    144:  * but that caused problems with various alternate authentication
                    145:  * methods.  So, we just define our own and assume that it is >= the
                    146:  * system max.
                    147:  */
                    148: #define SUDO_PASS_MAX  256
                    149:
                    150: /*
                    151:  * Flags for lock_file()
                    152:  */
                    153: #define SUDO_LOCK      1               /* lock a file */
                    154: #define SUDO_TLOCK     2               /* test & lock a file (non-blocking) */
                    155: #define SUDO_UNLOCK    4               /* unlock a file */
1.3       millert   156:
                    157: /*
                    158:  * Flags for sudoers_lookup:
                    159:  *  PASSWD_NEVER:  user never has to give a passwd
                    160:  *  PASSWD_ALL:    no passwd needed if all entries for host have NOPASSWD flag
                    161:  *  PASSWD_ANY:    no passwd needed if any entry for host has a NOPASSWD flag
                    162:  *  PASSWD_ALWAYS: passwd always needed
                    163:  */
                    164: #define PWCHECK_NEVER  0x01
                    165: #define PWCHECK_ALL    0x02
                    166: #define PWCHECK_ANY    0x04
                    167: #define PWCHECK_ALWAYS 0x08
1.1       millert   168:
                    169: /*
1.4       millert   170:  * Flags for tgetpass()
                    171:  */
                    172: #define TGP_ECHO       0x01            /* leave echo on when reading passwd */
                    173: #define TGP_STDIN      0x02            /* read from stdin, not /dev/tty */
                    174:
                    175: /*
1.1       millert   176:  * Function prototypes
                    177:  */
                    178: #define YY_DECL int yylex __P((void))
                    179:
                    180: #ifndef HAVE_GETCWD
                    181: char *getcwd           __P((char *, size_t size));
                    182: #endif
                    183: #ifndef HAVE_SNPRINTF
                    184: int snprintf           __P((char *, size_t, const char *, ...));
                    185: #endif
                    186: #ifndef HAVE_VSNPRINTF
                    187: int vsnprintf          __P((char *, size_t, const char *, va_list));
                    188: #endif
                    189: #ifndef HAVE_ASPRINTF
                    190: int asprintf           __P((char **, const char *, ...));
                    191: #endif
                    192: #ifndef HAVE_VASPRINTF
                    193: int vasprintf          __P((char **, const char *, va_list));
                    194: #endif
                    195: #ifndef HAVE_STRCASECMP
                    196: int strcasecmp         __P((const char *, const char *));
                    197: #endif
                    198: char *sudo_goodpath    __P((const char *));
                    199: char *tgetpass         __P((const char *, int, int));
1.7       millert   200: int find_path          __P((char *, char **, char *));
1.1       millert   201: void check_user                __P((void));
1.5       millert   202: void verify_user       __P((struct passwd *, char *));
1.1       millert   203: int sudoers_lookup     __P((int));
1.7       millert   204: void set_perms_posix   __P((int, int));
                    205: void set_perms_fallback        __P((int, int));
1.1       millert   206: void remove_timestamp  __P((int));
                    207: int check_secureware   __P((char *));
                    208: void sia_attempt_auth  __P((void));
                    209: void pam_attempt_auth  __P((void));
                    210: int yyparse            __P((void));
                    211: void pass_warn         __P((FILE *));
                    212: VOID *emalloc          __P((size_t));
                    213: VOID *erealloc         __P((VOID *, size_t));
                    214: char *estrdup          __P((const char *));
1.5       millert   215: int easprintf          __P((char **, const char *, ...));
                    216: int evasprintf         __P((char **, const char *, va_list));
1.7       millert   217: void dump_badenv       __P((void));
1.1       millert   218: void dump_defaults     __P((void));
                    219: void dump_auth_methods __P((void));
1.7       millert   220: void init_envtables    __P((void));
1.1       millert   221: int lock_file          __P((int, int));
                    222: int touch              __P((char *, time_t));
1.4       millert   223: int user_is_exempt     __P((void));
1.2       millert   224: void set_fqdn          __P((void));
1.4       millert   225: char *sudo_getepw      __P((struct passwd *));
1.7       millert   226: int pam_prep_user      __P((struct passwd *));
1.1       millert   227: YY_DECL;
                    228:
                    229: /* Only provide extern declarations outside of sudo.c. */
                    230: #ifndef _SUDO_SUDO_C
                    231: extern struct sudo_user sudo_user;
1.5       millert   232: extern struct passwd *auth_pw;
1.1       millert   233:
                    234: extern int Argc;
                    235: extern char **Argv;
                    236: extern FILE *sudoers_fp;
1.4       millert   237: extern int tgetpass_flags;
1.7       millert   238:
                    239: extern void (*set_perms) __P((int, int));
1.1       millert   240: #endif
                    241: extern int errno;
                    242:
                    243: #endif /* _SUDO_SUDO_H */