| 1 | #ifndef SH_EXTERN_H
|
|---|
| 2 | #define SH_EXTERN_H
|
|---|
| 3 |
|
|---|
| 4 | typedef struct
|
|---|
| 5 | {
|
|---|
| 6 | char * command;
|
|---|
| 7 | int argc;
|
|---|
| 8 | char * argv[32];
|
|---|
| 9 | int envc;
|
|---|
| 10 | char * envv[32];
|
|---|
| 11 | char checksum[KEY_LEN + 1];
|
|---|
| 12 | #if 0
|
|---|
| 13 | uid_t trusted_users[32];
|
|---|
| 14 | #endif
|
|---|
| 15 | uid_t run_user_uid;
|
|---|
| 16 | gid_t run_user_gid;
|
|---|
| 17 | int privileged;
|
|---|
| 18 |
|
|---|
| 19 | int pipeFD;
|
|---|
| 20 | SL_TICKET pipeTI;
|
|---|
| 21 | pid_t pid;
|
|---|
| 22 | FILE * pipe;
|
|---|
| 23 | char rw;
|
|---|
| 24 | int exit_status;
|
|---|
| 25 | int fork_twice;
|
|---|
| 26 |
|
|---|
| 27 | int com_fd;
|
|---|
| 28 | SL_TICKET com_ti;
|
|---|
| 29 |
|
|---|
| 30 | } sh_tas_t;
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | /*
|
|---|
| 34 | * -- generic safe popen; returns 0 on success, -1 otherwise
|
|---|
| 35 | */
|
|---|
| 36 | int sh_ext_popen (sh_tas_t * task);
|
|---|
| 37 |
|
|---|
| 38 | /*
|
|---|
| 39 | * -- generic simple safe popen; returns 0 on success, -1 otherwise,
|
|---|
| 40 | * executes shell command
|
|---|
| 41 | */
|
|---|
| 42 | int sh_ext_popen_init (sh_tas_t * task, char * command);
|
|---|
| 43 |
|
|---|
| 44 | /*
|
|---|
| 45 | * -- Execute command, return first line of output
|
|---|
| 46 | */
|
|---|
| 47 | int sh_ext_system (char * command);
|
|---|
| 48 |
|
|---|
| 49 | /*
|
|---|
| 50 | * -- Execute command, return first line of output
|
|---|
| 51 | */
|
|---|
| 52 | char * sh_ext_popen_str (char * command);
|
|---|
| 53 |
|
|---|
| 54 | /*
|
|---|
| 55 | * -- close the pipe, clear and return task->exit_status
|
|---|
| 56 | */
|
|---|
| 57 | int sh_ext_pclose (sh_tas_t * task);
|
|---|
| 58 |
|
|---|
| 59 | /*
|
|---|
| 60 | * -- add CL argument, return # of arguments
|
|---|
| 61 | */
|
|---|
| 62 | int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val);
|
|---|
| 63 | /*
|
|---|
| 64 | * -- remove last CL argument
|
|---|
| 65 | */
|
|---|
| 66 | int sh_ext_tas_rm_argv(sh_tas_t * tas);
|
|---|
| 67 | /*
|
|---|
| 68 | * -- add environment variable, return # of variables
|
|---|
| 69 | */
|
|---|
| 70 | int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val);
|
|---|
| 71 | /*
|
|---|
| 72 | * -- set command
|
|---|
| 73 | */
|
|---|
| 74 | void sh_ext_tas_command(sh_tas_t * tas, const char * command);
|
|---|
| 75 | /*
|
|---|
| 76 | * -- initialize task structure
|
|---|
| 77 | */
|
|---|
| 78 | void sh_ext_tas_init (sh_tas_t * tas);
|
|---|
| 79 | /*
|
|---|
| 80 | * -- free task structure
|
|---|
| 81 | */
|
|---|
| 82 | void sh_ext_tas_free(sh_tas_t * tas);
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | #if defined(WITH_EXTERNAL)
|
|---|
| 86 |
|
|---|
| 87 | /*
|
|---|
| 88 | * -- start a new external command, and add it to the list
|
|---|
| 89 | */
|
|---|
| 90 | int sh_ext_setcommand(const char * cmd);
|
|---|
| 91 |
|
|---|
| 92 | /*
|
|---|
| 93 | * -- explicitely close a command
|
|---|
| 94 | */
|
|---|
| 95 | int sh_ext_close_command (const char * str);
|
|---|
| 96 |
|
|---|
| 97 | /*
|
|---|
| 98 | * -- clean up the command list
|
|---|
| 99 | */
|
|---|
| 100 | int sh_ext_cleanup(void);
|
|---|
| 101 |
|
|---|
| 102 | /*
|
|---|
| 103 | * -- set deadtime
|
|---|
| 104 | */
|
|---|
| 105 | int sh_ext_deadtime (const char * str);
|
|---|
| 106 |
|
|---|
| 107 | /*
|
|---|
| 108 | * -- add keywords to the OR filter
|
|---|
| 109 | */
|
|---|
| 110 | int sh_ext_add_or (const char * str);
|
|---|
| 111 |
|
|---|
| 112 | /*
|
|---|
| 113 | * -- add keywords to the AND filter
|
|---|
| 114 | */
|
|---|
| 115 | int sh_ext_add_and (const char * str);
|
|---|
| 116 |
|
|---|
| 117 | /*
|
|---|
| 118 | * -- add keywords to the NOT filter
|
|---|
| 119 | */
|
|---|
| 120 | int sh_ext_add_not (const char * str);
|
|---|
| 121 |
|
|---|
| 122 | /*
|
|---|
| 123 | * -- add keywords to the CL argument list
|
|---|
| 124 | */
|
|---|
| 125 | int sh_ext_add_argv (const char * str);
|
|---|
| 126 |
|
|---|
| 127 | /*
|
|---|
| 128 | * -- add a path to the environment
|
|---|
| 129 | */
|
|---|
| 130 | int sh_ext_add_default (const char * str);
|
|---|
| 131 |
|
|---|
| 132 | /*
|
|---|
| 133 | * -- add an environment variable
|
|---|
| 134 | */
|
|---|
| 135 | int sh_ext_add_environ (const char * str);
|
|---|
| 136 |
|
|---|
| 137 | /*
|
|---|
| 138 | * -- define type
|
|---|
| 139 | */
|
|---|
| 140 | int sh_ext_type (const char * str);
|
|---|
| 141 |
|
|---|
| 142 | /*
|
|---|
| 143 | * -- define checksum
|
|---|
| 144 | */
|
|---|
| 145 | int sh_ext_checksum (const char * str);
|
|---|
| 146 |
|
|---|
| 147 | /*
|
|---|
| 148 | * -- choose privileges
|
|---|
| 149 | */
|
|---|
| 150 | int sh_ext_priv (const char * c);
|
|---|
| 151 |
|
|---|
| 152 | /*
|
|---|
| 153 | * -- execute external script/program
|
|---|
| 154 | */
|
|---|
| 155 | int sh_ext_execute (char t1, char t2, char t3, /*@null@*/char * message,
|
|---|
| 156 | size_t msg_siz);
|
|---|
| 157 |
|
|---|
| 158 | #endif
|
|---|
| 159 |
|
|---|
| 160 | #endif
|
|---|