[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.5

1.1       millert     1: /*
1.3       millert     2:  * Copyright (c) 1994-1996,1998-2000 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.4       millert    34:  * $Sudo: sudo.h,v 1.172 2000/03/07 04:29:46 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;
                     50:     char *tty;
                     51:     char  cwd[MAXPATHLEN];
                     52:     char *host;
                     53:     char *shost;
                     54:     char **runas;
                     55:     char *prompt;
                     56:     char *cmnd_safe;
                     57:     char *cmnd;
                     58:     char *cmnd_args;
1.4       millert    59:     char *class_name;
1.1       millert    60: };
                     61:
                     62: /*
                     63:  * Return values for sudoers_lookup(), also used as arguments for log_auth()
                     64:  * Note: cannot use '0' as a value here.
                     65:  */
                     66: /* XXX - VALIDATE_SUCCESS and VALIDATE_FAILURE instead? */
                     67: #define VALIDATE_ERROR          0x01
                     68: #define VALIDATE_OK            0x02
                     69: #define VALIDATE_NOT_OK                0x04
                     70: #define FLAG_NOPASS            0x10
                     71: #define FLAG_NO_USER           0x20
                     72: #define FLAG_NO_HOST           0x40
                     73: #define FLAG_NO_CHECK          0x80
                     74:
                     75: /*
                     76:  * Boolean values
                     77:  */
                     78: #undef TRUE
                     79: #define TRUE                     1
                     80: #undef FALSE
                     81: #define FALSE                    0
                     82:
                     83: /*
                     84:  * find_path()/load_cmnd() return values
                     85:  */
                     86: #define FOUND                    1
                     87: #define NOT_FOUND                0
                     88: #define NOT_FOUND_DOT          -1
                     89:
                     90: /*
                     91:  * Various modes sudo can be in (based on arguments) in octal
                     92:  */
                     93: #define MODE_RUN                 00001
                     94: #define MODE_VALIDATE            00002
                     95: #define MODE_INVALIDATE          00004
                     96: #define MODE_KILL                00010
                     97: #define MODE_VERSION             00020
                     98: #define MODE_HELP                00040
                     99: #define MODE_LIST                00100
                    100: #define MODE_LISTDEFS            00200
                    101: #define MODE_BACKGROUND          00400
                    102: #define MODE_SHELL               01000
1.3       millert   103: #define MODE_IMPLIED_SHELL       02000
                    104: #define MODE_RESET_HOME          04000
1.1       millert   105:
                    106: /*
                    107:  * Used with set_perms()
                    108:  */
                    109: #define PERM_ROOT                0x00
                    110: #define PERM_USER                0x01
                    111: #define PERM_FULL_USER           0x02
                    112: #define PERM_SUDOERS             0x03
                    113: #define PERM_RUNAS              0x04
                    114:
                    115: /*
                    116:  * Shortcuts for sudo_user contents.
                    117:  */
                    118: #define user_name              (sudo_user.pw->pw_name)
                    119: #define user_passwd            (sudo_user.pw->pw_passwd)
                    120: #define user_uid               (sudo_user.pw->pw_uid)
                    121: #define user_gid               (sudo_user.pw->pw_gid)
                    122: #define user_shell             (sudo_user.pw->pw_shell)
                    123: #define user_dir               (sudo_user.pw->pw_dir)
                    124: #define user_tty               (sudo_user.tty)
                    125: #define user_cwd               (sudo_user.cwd)
                    126: #define user_runas             (sudo_user.runas)
                    127: #define user_cmnd              (sudo_user.cmnd)
                    128: #define user_args              (sudo_user.cmnd_args)
                    129: #define user_prompt            (sudo_user.prompt)
                    130: #define user_host              (sudo_user.host)
                    131: #define user_shost             (sudo_user.shost)
                    132: #define safe_cmnd              (sudo_user.cmnd_safe)
1.4       millert   133: #define login_class            (sudo_user.class_name)
1.1       millert   134:
                    135: /*
                    136:  * We used to use the system definition of PASS_MAX or _PASSWD_LEN,
                    137:  * but that caused problems with various alternate authentication
                    138:  * methods.  So, we just define our own and assume that it is >= the
                    139:  * system max.
                    140:  */
                    141: #define SUDO_PASS_MAX  256
                    142:
                    143: /*
                    144:  * Flags for lock_file()
                    145:  */
                    146: #define SUDO_LOCK      1               /* lock a file */
                    147: #define SUDO_TLOCK     2               /* test & lock a file (non-blocking) */
                    148: #define SUDO_UNLOCK    4               /* unlock a file */
1.3       millert   149:
                    150: /*
                    151:  * Flags for sudoers_lookup:
                    152:  *  PASSWD_NEVER:  user never has to give a passwd
                    153:  *  PASSWD_ALL:    no passwd needed if all entries for host have NOPASSWD flag
                    154:  *  PASSWD_ANY:    no passwd needed if any entry for host has a NOPASSWD flag
                    155:  *  PASSWD_ALWAYS: passwd always needed
                    156:  */
                    157: #define PWCHECK_NEVER  0x01
                    158: #define PWCHECK_ALL    0x02
                    159: #define PWCHECK_ANY    0x04
                    160: #define PWCHECK_ALWAYS 0x08
1.1       millert   161:
                    162: /*
1.4       millert   163:  * Flags for tgetpass()
                    164:  */
                    165: #define TGP_ECHO       0x01            /* leave echo on when reading passwd */
                    166: #define TGP_STDIN      0x02            /* read from stdin, not /dev/tty */
                    167:
                    168: /*
1.1       millert   169:  * Function prototypes
                    170:  */
                    171: #define YY_DECL int yylex __P((void))
                    172:
                    173: #ifndef HAVE_GETCWD
                    174: char *getcwd           __P((char *, size_t size));
                    175: #endif
                    176: #if !defined(HAVE_PUTENV) && !defined(HAVE_SETENV)
                    177: int putenv             __P((const char *));
                    178: #endif
                    179: #ifndef HAVE_SNPRINTF
                    180: int snprintf           __P((char *, size_t, const char *, ...));
                    181: #endif
                    182: #ifndef HAVE_VSNPRINTF
                    183: int vsnprintf          __P((char *, size_t, const char *, va_list));
                    184: #endif
                    185: #ifndef HAVE_ASPRINTF
                    186: int asprintf           __P((char **, const char *, ...));
                    187: #endif
                    188: #ifndef HAVE_VASPRINTF
                    189: int vasprintf          __P((char **, const char *, va_list));
                    190: #endif
                    191: #ifndef HAVE_STRCASECMP
                    192: int strcasecmp         __P((const char *, const char *));
                    193: #endif
                    194: char *sudo_goodpath    __P((const char *));
                    195: int sudo_setenv                __P((char *, char *));
                    196: char *tgetpass         __P((const char *, int, int));
                    197: int find_path          __P((char *, char **));
                    198: void check_user                __P((void));
1.5     ! millert   199: void verify_user       __P((struct passwd *, char *));
1.1       millert   200: int sudoers_lookup     __P((int));
                    201: void set_perms         __P((int, int));
                    202: void remove_timestamp  __P((int));
                    203: int check_secureware   __P((char *));
                    204: void sia_attempt_auth  __P((void));
                    205: void pam_attempt_auth  __P((void));
                    206: int yyparse            __P((void));
                    207: void pass_warn         __P((FILE *));
                    208: VOID *emalloc          __P((size_t));
                    209: VOID *erealloc         __P((VOID *, size_t));
                    210: char *estrdup          __P((const char *));
1.5     ! millert   211: int easprintf          __P((char **, const char *, ...));
        !           212: int evasprintf         __P((char **, const char *, va_list));
1.1       millert   213: void dump_defaults     __P((void));
                    214: void dump_auth_methods __P((void));
                    215: int lock_file          __P((int, int));
                    216: int touch              __P((char *, time_t));
1.4       millert   217: int user_is_exempt     __P((void));
1.2       millert   218: void set_fqdn          __P((void));
1.4       millert   219: char *sudo_getepw      __P((struct passwd *));
1.1       millert   220: YY_DECL;
                    221:
                    222: /* Only provide extern declarations outside of sudo.c. */
                    223: #ifndef _SUDO_SUDO_C
                    224: extern struct sudo_user sudo_user;
1.5     ! millert   225: extern struct passwd *auth_pw;
1.1       millert   226:
                    227: extern int Argc;
                    228: extern char **Argv;
                    229: extern FILE *sudoers_fp;
1.4       millert   230: extern int tgetpass_flags;
1.1       millert   231: #endif
                    232: extern int errno;
                    233:
                    234: #endif /* _SUDO_SUDO_H */