source: trunk/include/sh_extern.h@ 473

Last change on this file since 473 was 415, checked in by katerina, 12 years ago

Fixes for tickets #314, #315, #316, #317, #318, #319, #320, and #321.

File size: 2.9 KB
Line 
1#ifndef SH_EXTERN_H
2#define SH_EXTERN_H
3
4#include <stdarg.h>
5
6typedef 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];
14#if 0
15 uid_t trusted_users[32];
16#endif
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 */
38int sh_ext_popen (sh_tas_t * task);
39
40/*
41 * -- generic simple safe popen; returns 0 on success, -1 otherwise,
42 * executes shell command
43 */
44int sh_ext_popen_init (sh_tas_t * task, char * command, char * argv0, ...) SH_GNUC_SENTINEL;
45
46/*
47 * -- Execute command, return first line of output
48 */
49int sh_ext_system (char * command, char * argv0, ...) SH_GNUC_SENTINEL;
50
51/*
52 * -- Execute command, return first line of output
53 */
54char * sh_ext_popen_str (char * command);
55
56/*
57 * -- close the pipe, clear and return task->exit_status
58 */
59int sh_ext_pclose (sh_tas_t * task);
60
61/*
62 * -- add CL argument, return # of arguments
63 */
64int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val);
65/*
66 * -- remove last CL argument
67 */
68int sh_ext_tas_rm_argv(sh_tas_t * tas);
69/*
70 * -- add environment variable, return # of variables
71 */
72int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val);
73/*
74 * -- set command
75 */
76void sh_ext_tas_command(sh_tas_t * tas, const char * command);
77/*
78 * -- initialize task structure
79 */
80void sh_ext_tas_init (sh_tas_t * tas);
81/*
82 * -- free task structure
83 */
84void 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 */
92int sh_ext_setcommand(const char * cmd);
93
94/*
95 * -- explicitely close a command
96 */
97int sh_ext_close_command (const char * str);
98
99/*
100 * -- clean up the command list
101 */
102int sh_ext_cleanup(void);
103
104/*
105 * -- set deadtime
106 */
107int sh_ext_deadtime (const char * str);
108
109/*
110 * -- add keywords to the OR filter
111 */
112int sh_ext_add_or (const char * str);
113
114/*
115 * -- add keywords to the AND filter
116 */
117int sh_ext_add_and (const char * str);
118
119/*
120 * -- add keywords to the NOT filter
121 */
122int sh_ext_add_not (const char * str);
123
124/*
125 * -- add keywords to the CL argument list
126 */
127int sh_ext_add_argv (const char * str);
128
129/*
130 * -- add a path to the environment
131 */
132int sh_ext_add_default (const char * str);
133
134/*
135 * -- add an environment variable
136 */
137int sh_ext_add_environ (const char * str);
138
139/*
140 * -- define type
141 */
142int sh_ext_type (const char * str);
143
144/*
145 * -- define checksum
146 */
147int sh_ext_checksum (const char * str);
148
149/*
150 * -- choose privileges
151 */
152int sh_ext_priv (const char * c);
153
154/*
155 * -- execute external script/program
156 */
157int sh_ext_execute (char t1, char t2, char t3, /*@null@*/char * message,
158 size_t msg_siz);
159
160#endif
161
162#endif
Note: See TracBrowser for help on using the repository browser.