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