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 | * -- close the pipe, clear and return task->exit_status
|
---|
40 | */
|
---|
41 | int sh_ext_pclose (sh_tas_t * task);
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * -- add CL argument, return # of arguments
|
---|
45 | */
|
---|
46 | int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val);
|
---|
47 | /*
|
---|
48 | * -- remove last CL argument
|
---|
49 | */
|
---|
50 | int sh_ext_tas_rm_argv(sh_tas_t * tas);
|
---|
51 | /*
|
---|
52 | * -- add environment variable, return # of variables
|
---|
53 | */
|
---|
54 | int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val);
|
---|
55 | /*
|
---|
56 | * -- set command
|
---|
57 | */
|
---|
58 | void sh_ext_tas_command(sh_tas_t * tas, const char * command);
|
---|
59 | /*
|
---|
60 | * -- initialize task structure
|
---|
61 | */
|
---|
62 | void sh_ext_tas_init (sh_tas_t * tas);
|
---|
63 | /*
|
---|
64 | * -- free task structure
|
---|
65 | */
|
---|
66 | void sh_ext_tas_free(sh_tas_t * tas);
|
---|
67 |
|
---|
68 |
|
---|
69 | #if defined(WITH_EXTERNAL)
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * -- start a new external command, and add it to the list
|
---|
73 | */
|
---|
74 | int sh_ext_setcommand(const char * cmd);
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * -- explicitely close a command
|
---|
78 | */
|
---|
79 | int sh_ext_close_command (const char * str);
|
---|
80 |
|
---|
81 | /*
|
---|
82 | * -- clean up the command list
|
---|
83 | */
|
---|
84 | int sh_ext_cleanup(void);
|
---|
85 |
|
---|
86 | /*
|
---|
87 | * -- set deadtime
|
---|
88 | */
|
---|
89 | int sh_ext_deadtime (const char * str);
|
---|
90 |
|
---|
91 | /*
|
---|
92 | * -- add keywords to the OR filter
|
---|
93 | */
|
---|
94 | int sh_ext_add_or (const char * str);
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * -- add keywords to the AND filter
|
---|
98 | */
|
---|
99 | int sh_ext_add_and (const char * str);
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * -- add keywords to the NOT filter
|
---|
103 | */
|
---|
104 | int sh_ext_add_not (const char * str);
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * -- add keywords to the CL argument list
|
---|
108 | */
|
---|
109 | int sh_ext_add_argv (const char * str);
|
---|
110 |
|
---|
111 | /*
|
---|
112 | * -- add a path to the environment
|
---|
113 | */
|
---|
114 | int sh_ext_add_default (const char * str);
|
---|
115 |
|
---|
116 | /*
|
---|
117 | * -- add an environment variable
|
---|
118 | */
|
---|
119 | int sh_ext_add_environ (const char * str);
|
---|
120 |
|
---|
121 | /*
|
---|
122 | * -- define type
|
---|
123 | */
|
---|
124 | int sh_ext_type (const char * str);
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * -- define checksum
|
---|
128 | */
|
---|
129 | int sh_ext_checksum (const char * str);
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * -- choose privileges
|
---|
133 | */
|
---|
134 | int sh_ext_priv (const char * c);
|
---|
135 |
|
---|
136 | /*
|
---|
137 | * -- execute external script/program
|
---|
138 | */
|
---|
139 | int sh_ext_execute (char t1, char t2, char t3, /*@null@*/char * message,
|
---|
140 | size_t msg_siz);
|
---|
141 |
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | #endif
|
---|