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